Search code examples
pythonclassificationsklearn-pandas

sklearn.neighbors.KNeighborsClassifier could not convert string to float


I am trying to clean my data in python using sklearn.neighbors.KNeighborsClassifier. In the fit function of classifier I have provide training data in the form of a DataTable generated by Pandas from a csv file.

The fit function throws an error

could not convert string to float : "training data's first cell value".

How can I use the training data of tabular form of strings?

I am working on Kaggle Titanic dataset.


Solution

  • You have to define a metrics for your classifier. Otherwise, the clustering does not have a clue, what he has to do with strings. Look at this thread, which is probably the same:

    https://stackoverflow.com/a/35283104/2151532