X, y = make_regression(n_samples=200, n_features=5, n_targets=2, shuffle=True, random_state=1)
Now, we are initializing a linear regressor using the LinearRegression class. We are also initializing the k-fold cross-validation using 10 splits.
model = LinearRegression() kfold = KFold(n_splits=10, shuffle=True, random_state=1)
Now, we can use the cross_val_score() function and print the average r2 score of the model. The output of the given program will be:
R2: 1.0
However, some regressors like the Support Vector Machine regressor do not support multioutput regression natively. We need to use direct multioutput regression or chained multioutput regression with those regressors in that case. Interested readers who want to know more, please refer to the following articles:
What is direct multioutput regression?
What is chained multioutput regression?








































0 Comments