0
$\begingroup$

On running below code on python 3.7, I am getting the following response: 'DataFrame' object has no attribute 'n_splits'.
How to get rid of this?

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sklearn.model_selection as train_test_split
from sklearn.tree import DecisionTreeClassifier
%matplotlib inline
import seaborn as sns
sns.set()
from sklearn.neighbors import KNeighborsClassifier

from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score

train=pd.read_csv(r"C:\Users\Pranjal Pathak\Desktop\kaggle-titanic-master\Digit recognizer kaggle\train.csv")
test=pd.read_csv(r"C:\Users\Pranjal Pathak\Desktop\kaggle-titanic-master\Digit recognizer kaggle\test.csv")

train1=train.drop('label',axis=1)
test1=train['label']

Kfold=KFold(n_splits=30,shuffle=True,random_state=0)

clf=KNeighborsClassifier(n_neighbors = 20)
scoring='accuracy'

score=cross_val_score(clf,train1,test1,cv=KFold,n_jobs=1,scoring=scoring)

$\endgroup$
0
$\begingroup$

There is a typo error in the below line. Change KFold to Kfold below and try.

score=cross_val_score(clf,train1,test1,cv=KFold,n_jobs=1,scoring=scoring)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.