model = LinearSVR()
Now, we are initializing the model using the LinearSVR class.
kfold = KFold(n_splits=10, shuffle=True, random_state=1)
Then, we initialize the k-fold cross-validation using 10 splits. We are shuffling the data before splitting and random_state is used to initialize the pseudo-random number generator that is used for shuffling the data.
scores = cross_val_score(model, X, y, cv=kfold, scoring="r2")
print("R2: ", scores.mean())
Now, we can estimate the performance of the model using cross_val_score(). We are using the r2 score here (What is R-squared in machine learning?). We will get the r2 score for each iteration of the k-fold cross-validation. We are printing the average r2 score.
The output of the given program will be:
R2: 0.9999999966902978








































0 Comments