X_train, X_test, y_train, y_test = train_test_split(df_features, df_target["target"], shuffle=True, random_state=1)
Now, we are initializing the regressor using the SVR class from the sklearn.svm module. Please note that the SVR class by default, uses the radial basis function (rbf) kernel.
The fit() method is then used to learn from the dataset. And the predict() method is used to predict the target variable in the test set.
regressor = SVR() regressor.fit(X_train, y_train) y_test_pred = regressor.predict(X_test)
Now, we can compare y_test_pred and y_test and measure the performance of the model. In this example, we are using Mean Absolute Error (What is the Mean Absolute Error or MAE?) and Root Mean Square Error (What is the Root Mean Square Error?)
mae = mean_absolute_error(y_test, y_test_pred) rmse = mean_squared_error(y_test, y_test_pred, squared=False)
The output of the above program will be:
Mean Absolute Error: 54.334985690336865 Root Mean Square Error: 66.12446097403694








































0 Comments