1
$\begingroup$

I practice XGBClassifier() to predict the target in iris dataset. here is the code:

#iris dataset, set data to X and target to y
iris = datasets.load_iris()
X = iris.data
y = iris.target
#import datasets from sklearn, train_test_split from sklearn.model_selection
X_train, x_test , y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=1)

model = XGBClassifier(n_estimators = 100, learning_rate = 0.1,verbosity = 1, random_state = 1)

model.fit(X_train, y_train)

y_pred = model.predict(X_test)

from sklearn.metrics import mean_squared_error as MSE
rmse = np.sqrt(MSE(y_train,y_pred))
print(rmse)

when I use mean_squared_error from sklean.metrics I get an error

ValueError: Found input variables with inconsistent numbers of samples: [120, 30]

$\endgroup$
1
  • $\begingroup$ You are comparing the ground truth values of your training set with the predicted values on your test set, which is impossible since they have a different number of observations. Make sure to compare to use the same data split in both instances. $\endgroup$
    – Oxbowerce
    Feb 6 at 18:55

0

Your Answer

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