0

I got this error:

could not convert string to float: '4,49E+09

when I ran my KNN code.

Here is my code:

import pandas as pd 
import matplotlib.pyplot as plt
import numpy as np

data = pd.read_csv("TotalFeatureRatio2.csv",';')

y = data.AHI 
list = ['AHI', 'Epworth', 'Id'] 
x_data = data.drop(list, axis=1)

x = (x_data - np.min(x_data))/(np.max(x_data)-np.min(x_data))

from sklearn.model_selection import train_test_split 
x_train, x_test, y_train, y_test = train_test_split(x_data, y, test_size=0.3, random_state=1)

from sklearn.neighbors import KNeighborsClassifier 
knn = KNeighborsClassifier(n_neighbors = 5) # n_neighbors = k
knn.fit(x_train,y_train) prediction = 
knn.predict(x_test) print(" {} nn score: {} ".format(5, knn.score(x_test, y_test)))
dedObed
  • 1,117
  • 9
  • 17
  • This question has (most likely) nothing to do with KNNs. Please improve the question to be minimal -- and if that means the `data = pd.read_csv(...)` line, then include a representative sample of your input. And see if perhaps [this questions](https://stackoverflow.com/questions/7106417/convert-decimal-mark) solves your problem. – dedObed Mar 14 '19 at 20:50
  • 1
    Possible duplicate of [convert decimal mark](https://stackoverflow.com/questions/7106417/convert-decimal-mark) – dedObed Mar 14 '19 at 21:11

0 Answers0