Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# training an SVR model
from sklearn.svm import SVR
# measuring RMSE score
from sklearn.metrics import mean_squared_error
# SVR
svr = SVR(kernel='rbf',C=5)
rmse = []
# raw, normalized and standardized training and testing data
trainX = [X_train, X_train_norm, X_train_stand]
testX = [X_test, X_test_norm, X_test_stand]
# model fitting and measuring RMSE
for i in range(len(trainX)):
# fit
svr.fit(trainX[i],y_train)
# predict
pred = svr.predict(testX[i])
# RMSE
rmse.append(np.sqrt(mean_squared_error(y_test,pred)))
# visualizing the result
df_svr = pd.DataFrame({'RMSE':rmse},index=['Original','Normalized','Standardized'])
df_svr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment