0

I am getting this error in the below code. I error that I receive doesn't give me any clue to address. Please help.

Error: TypeError: '<' not supported between instances of 'str' and 'int'

Code:

from pandas import read_csv
from numpy import set_printoptions
from sklearn.preprocessing import MinMaxScaler
filename = 'Data/pima-indians-diabetes.csv'
names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
df = read_csv(filename,names=names)
array = df.values
X = array[:,:8]
Y = array[:,8]
scaler = MinMaxScaler(feature_range=(0,1))
reScaledX = scaler.fit_transform(X)
print(reScaledX)
Keatinge
  • 4,330
  • 6
  • 25
  • 44
Chakra
  • 15
  • 5

1 Answers1

0

It seems that when you are using the MinMaxScaler, the values X that you are using from your CSV are string instead of integers that's why you are getting a TypeError. Try parsing your read values using int(). This should solve this error.

Guillem
  • 54
  • 10