Search code examples
pythonpandasjupyter-notebooksklearn-pandasperceptron

Unknown label type error while I'm trying to fit x_train and y_train to Perceptron and MLPClassifier using Sklearn


This is a snippet of my code, I can't add more for some reason but,

per = Perceptron()

per.fit(x_train,y_train)

and this is the following error

ValueError: Unknown label type: (array([0.055, 0.09 , 0.095, 0.1  , 0.105, 0.11 , 0.115, 0.12 , 0.125,
   0.13 , 0.135, 0.14 , 0.145, 0.15 , 0.155, 0.16 , 0.165, 0.17 ,
   0.175, 0.18 , 0.185, 0.19 , 0.195, 0.2  , 0.205, 0.21 , 0.215,
   0.22 , 0.225, 0.23 , 0.235, 0.24 , 0.245, 0.25 , 0.255, 0.26 ,
   0.265, 0.27 , 0.275, 0.28 , 0.285, 0.29 , 0.295, 0.3  , 0.305,
   0.31 , 0.315, 0.32 , 0.325, 0.33 , 0.335, 0.34 , 0.345, 0.35 ,
   0.355, 0.36 , 0.365, 0.37 , 0.375, 0.38 , 0.385, 0.39 , 0.395,
   0.4  , 0.405, 0.41 , 0.415, 0.42 , 0.425, 0.43 , 0.435, 0.44 ,
   0.445, 0.45 , 0.455, 0.46 , 0.465, 0.47 , 0.475, 0.48 , 0.485,
   0.49 , 0.495, 0.5  , 0.505, 0.51 , 0.515, 0.52 , 0.525, 0.53 ,
   0.535, 0.54 , 0.545, 0.55 , 0.555, 0.56 , 0.565, 0.57 , 0.575,
   0.58 , 0.585, 0.59 , 0.595, 0.6  , 0.605, 0.61 , 0.62 , 0.625,
   0.63 , 0.65 ]),)

I really don't know how to fix this "Unknown label type: array", I've been researching for hours on how to fix this error. I'm pretty new to all of this, so apologies if there is a lot of error in the code.


Solution

  • I think there was something wrong with the file I was loading, I changed my csv file and now per.fit() works!