Home > Blockchain >  ValueError: Found input variables with inconsistent numbers of samples: [105, 180]
ValueError: Found input variables with inconsistent numbers of samples: [105, 180]

Time:03-29

ValueError: Found input variables with inconsistent numbers of samples: [105, 180]

I don't understand what happened

feature = iris.drop("species", axis=1)
target = iris["species"]


from sklearn.model_selection import train_test_split
xtrain,ytrain,xtest,ytest = train_test_split(feature,target, test_size=0.3, random_state=101)

from sklearn.svm import SVC
model = SVC()
model.fit(xtrain,ytrain.values.ravel())

CodePudding user response:

It seems you've mixed up the order of the output list of train_test_split, see https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html. Try xtrain,xtest,ytrain,ytest = train_test_split(feature,target, test_size=0.3, random_state=101).

  • Related