This is the lines:
from sklearn import tree
X = [[181,80,44], [177, 70, 43], [160, 60, 38], 154, 54, 37],
[166,64,40], [190,90,47], [175,64,39],[177,70,40],[159,55,37],
[171,75,42],[181,85,43]
Y = ['male', 'female', 'female', 'female', 'male', 'male', 'male',
'female', 'male', 'female', 'male']
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X,Y)
prediction = clf.predict([[182,78,43]])
print (prediction)
Result:
Traceback (most recent call last):
File "C:\Python\code\test.py", line 14, in <module>
clf = clf.fit(X,Y)
File "C:\Python\lib\site-packages\sklearn\tree\tree.py", line 790, in fit
X_idx_sorted=X_idx_sorted)
File "C:\Python\lib\site-packages\sklearn\tree\tree.py", line 116, in fit
X = check_array(X, dtype=DTYPE, accept_sparse="csc")
File "C:\Python\lib\site-packages\sklearn\utils\validation.py", line 402,
in check_array
array = np.array(array, dtype=dtype, order=order, copy=copy)
in check_array
array = np.array(array, dtype=dtype, order=order, copy=copy)
ValueError: setting an array element with a sequence.
[Finished in 0.5s]
Expected result:
Should display gender predicted from body measurements: "182,78,43"
Example: male or female
Run with Python 3.6 using sklearn, numpy+mkl and scipy on Sublime.
The code is originally from: https://www.youtube.com/watch?v=T5pRlIbr6gg. No answer in the whole youtube comment section to this. Appreciate if answer can be found here, could not find any answer.