python - ValueError: Unknown label type array in scikit-learn -
i trying use scikit-learn train , test dataset. first of all, here's dataset (i show top 4 rows of 800 rows) :
full,id,id & ppdb,id & words sequence,id & synonyms,id & hypernyms,id & hyponyms,gold standard 1.667,0.476,0.952,0.476,1.429,0.952,0.476,2.345 3.056,1.111,1.667,1.111,3.056,1.389,1.111,1.9 1.765,1.176,1.176,1.176,1.765,1.176,1.176,2.2 0.714,0.714,0.714,0.714,0.714,0.714,0.714,0.0 and divided columns features , label, label "gold standard". here's code :
import pandas pd import numpy np sklearn.model_selection import cross_val_score sklearn.model_selection import train_test_split sklearn.neural_network import mlpclassifier dataset = pd.read_csv("datasupervised.csv") columns = ["full","id","id & ppdb","id & words sequence","id & synonyms","id & hypernyms","id & hyponyms"] label = dataset["gold standard"].values features = dataset[list(columns)].values x = features y = label print(x.shape) print(y.shape) print dframe = pd.dataframe(x, y).head(800) print dframe print x_train, x_test, y_train, y_test = train_test_split(features, labels, test_size=0.2, random_state=4) per = mlpclassifier() print(per.fit(x_train, y_train)) but said :
file "c:\python27\lib\site-packages\sklearn\utils\multiclass.py", line 98, in unique_labels raise valueerror("unknown label type: %s" % repr(ys)) valueerror: unknown label type: (array([ 5. , 5. , 2.682, 3.375, 5. , 2.2 , 3.125, 1.5 , i don't understand why did so? can explain? thanks
Comments
Post a Comment