Validasi Python Cross
from sklearn.model_selection import cross_val_score
scores = cross_val_score(model # Ridge(alpha=1)
, X_train # scaler.fit_transform(x_train)
, y_train # scaler.fit_transform(y_train)
, scoring='neg_mean_squared_error' # depends on model more at https://scikit-learn.org/stable/modules/model_evaluation.html
, cv=5) # 5 fold cross validation
mean(scores) # negMSE (higher=better), adj hyper params to optimize
model.fit(x_train, y_train) # make sure to fit the model again after
y_final_test_pred = model.predict(x_test) # Final predictions
mean_squared_error(y_test, y_final_test_pred) # Final MSE on 'new' data
Trained Tuna