2017-01-05 5 views
1

Pythonコードを実行しようとしているときに表示されるエラーコードは以下のとおりです。私のインストールに問題はありますか? 私はPython 64ビット3.6.0をインストールしましたが、私はsci-kitの64ビットバージョンをインストールしたと確信しています。私はまた、前置きとしてインストールされている、気味悪い、scipyを持っています。SciKit-Pythonパッケージにエラーがあります。

Traceback (most recent call last): 
    File "C:/Users/kevinshen/Desktop/Kaggle/GettingStarted/makeSubmission.py", line 1, in <module> 
    from sklearn.ensemble import RandomForestClassifier 
    File "C:\Users\kevinshen\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\__init__.py", line 57, in <module> 
    from .base import clone 
    File "C:\Users\kevinshen\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\base.py", line 12, in <module> 
    from .utils.fixes import signature 
    File "C:\Users\kevinshen\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module> 
    from .validation import (as_float_array, 
    File "C:\Users\kevinshen\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 18, in <module> 
    from ..utils.fixes import signature 
    File "C:\Users\kevinshen\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\fixes.py", line 406, in <module> 
    if np_version < (1, 12, 0): 
TypeError: '<' not supported between instances of 'str' and 'int 

Pythonのコード:

from sklearn.ensemble import RandomForestClassifier 
from numpy import genfromtxt, savetxt 

def main(): 
    #create the training & test sets, skipping the header row with [1:] 
    dataset = genfromtxt(open('Data/train.csv','r'), delimiter=',', dtype='f8')[1:] 
    target = [x[0] for x in dataset] 
    train = [x[1:] for x in dataset] 
    test = genfromtxt(open('Data/test.csv','r'), delimiter=',', dtype='f8')[1:] 

    #create and train the random forest 
    #multi-core CPUs can use: rf = RandomForestClassifier(n_estimators=100, n_jobs=2) 
    rf = RandomForestClassifier(n_estimators=100) 
    rf.fit(train, target) 
    predicted_probs = [x[1] for x in rf.predict_proba(test)] 

    savetxt('Data/submission.csv', predicted_probs, delimiter=',', fmt='%f') 

if __name__=="__main__": 
    main() 
+0

あなたのコードの最初の行はエラーを生成しますので、あなたはそれのいずれかのより多くを投稿してはいけません。 https://stackoverflow.com/help/mcveを参照してください。 –

答えて

3

あなたは、おそらくそれはSTRとINT(0B1と0)との比較について不平を言う理由ですnumpyの1.12ベータ(1.12.0b1)を持っています。

fixes.pyの最後のバージョンは、この問題を修正: https://github.com/scikit-learn/scikit-learn/commit/1f278e1c231e6b9b3cf813377819e25e87b6c8b6

+0

ありがとうございました! –

+0

作品!物事をありがとう!私はpython/kaggleには全く新しいので、手がかりはありませんでした。 –

+0

それは動作します!私はhttp://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn py3.6 win32からsklearnをインストールしました。すぐにファイルを修正してくれることを願っています。 –

関連する問題