Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

My code below is giving me the following error "IndexError: too many indices for array". I am quite new to machine learning so I do not have any idea about how to solve this. Any kind of help would be appreciated.

train = pandas.read_csv("D:/...input/train.csv")

xTrain = train.iloc[:,0:54]

yTrain = train.iloc[:,54:]

from sklearn.cross_validation import cross_val_score

clf = LogisticRegression(multi_class='multinomial')

scores = cross_val_score(clf, xTrain, yTrain, cv=10, scoring='accuracy')

print('****Results****')

print(scores.mean())

1 Answer

0 votes
by (41.4k points)

Here, you have declared contents for your array that don't fit it. There is no declaration of your array.If we assume it to be one dimensional and the program is opposing to  treat it like a 2 dimensional.

So, check your declarations whether they are correct or not and also test the code by printing the values after you've set them to double check they are what you intend them to be.

To Learn what is data science and how to be a data scientist visit the data scientist course by Intellipaat.

Browse Categories

...