2017-11-01 2 views
0

Ich versuche, ein Python-Programm auszuführen, das verwendet Scikit-Learn eine binäre Klassifikation eines ‚gewinnen‘ zu tun oder "Verlust" eines Hockeyspiels, basierend auf 2 Feldern: 1 Feld von Statistiken (wie currentInjuries und Goals Against) für jedes Team, das das Hockeyspiel spielt. Ich bin es gewohnt, Java zu debuggen, aber in Python ist der Stack-Trace viel länger als das, was ich gewohnt bin.Python Scikit Erfahren Fehler: Valueerror: ‚Gefunden Eingangsvariablen mit inkonsistenter Anzahl von Proben: [4, 10]‘

Sollte ich mir die gesamte Stack-Trace, oder einfach nur die relevanteste Fehler und konzentrieren sich auf die Lösung? Ie) der Fehler ganz am Ende, das ist:

File "C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 181, in check_consistent_length 
    " samples: %r" % [int(l) for l in lengths]) 
ValueError: Found input variables with inconsistent numbers of samples: [4, 10] 

Hier ist der gesamte Stack-Trace:

pydev debugger: process 1084 is connecting 

C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20. 
    "This module will be removed in 0.20.", DeprecationWarning) 
C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\lda.py:6: DeprecationWarning: lda.LDA has been moved to discriminant_analysis.LinearDiscriminantAnalysis in 0.17 and will be removed in 0.19 
    "in 0.17 and will be removed in 0.19", DeprecationWarning) 
canucks_stats: [3, 11, 2, 2] 
opposing_stats: [1, 4, 4, 15] 
Backend Qt5Agg is interactive backend. Turning interactive mode on. 
Traceback (most recent call last): 
    File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\pydevd.py", line 1596, in <module> 
    globals = debugger.run(setup['file'], None, None, is_module) 
    File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\pydevd.py", line 974, in run 
    pydev_imports.execfile(file, globals, locals) # execute the script 
    File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile 
    exec(compile(contents+"\n", file, 'exec'), glob, loc) 
    File "C:/Users/Thomas/Desktop/!UFV/CIS480/project/NHL-Predictor.py", line 196, in <module> 
    for name, (X, y) in [('moon', toms_make_moons(noise=0.3, random_state=0))#, 
    File "C:/Users/Thomas/Desktop/!UFV/CIS480/project/NHL-Predictor.py", line 113, in toms_make_moons 
    X, y = util_shuffle(X, y, random_state=generator) 
    File "C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 285, in shuffle 
    return resample(*arrays, **options) 
    File "C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 204, in resample 
    check_consistent_length(*arrays) 
    File "C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 181, in check_consistent_length 
    " samples: %r" % [int(l) for l in lengths]) 
ValueError: Found input variables with inconsistent numbers of samples: [4, 10] 

Process finished with exit code 1 
+2

Der Fehler am unteren Ende können Sie zeigen, Was ist der Fehler? Und die gesamte Stack-Trace hilft Ihnen, den Fehler zu finden. – xiaoyi

Antwort

-1

Der Fehler am unteren Ende zeigen kann, was der Fehler ist. Der gesamte Stack-Trace hilft Ihnen, den Fehlerort zu finden.

Und wenn Sie Ihre Frage posten, postet bitte immer der volle Stack-Trace (wissen, in welcher Zeile Sie den Fehler bekommen). Siehe how to ask

Über den Fehler ValueError: Found input variables with inconsistent numbers of samples: [4, 10]:

x sollte ein 2-dimensionales Array der Größe sein [number_of_samples, number_of_features] Sie können es überprüfen kann.

und es gibt einige Hinweise:

ref1: ValueError: Found arrays with inconsistent numbers of samples [ 6 1786]

ref2: Loading jpg of different sizes into numpy.array - ValueError: Found input variables with inconsistent numbers of samples

ref3: Number of features of the model must match the input

ref4: Found input variables with inconsistent numbers of samples

Verwandte Themen