after predicting the target value for the classification problem trying to get the predicted values in a .csv file along with the id of particular data instance but getting the unnecessary row numbers.
JavaScript
x
9
1
x_train,x_test,y_train,y_test = train_test_split(x,y, random_state=101,strtify =y)
2
3
cls = DecisionTreeClassifier()
4
cls.fit(x_train,y_train)
5
6
pred = cls.predict(x_test)
7
prediction = pd.DataFrame({'id':x_test['id'],'target':pred})
8
prediction.to_csv("path/prediction.csv")
9
Advertisement
Answer
You index=False
, doc specifies this argument
JavaScript
1
2
1
prediction.to_csv("path/prediction.csv",index=False)
2