This is the code I'm using to compare performance metrics of different regression models on my timeseries data (basically I'm trying to predict certain values based off the month & day of the year)
import sklearn.metrics as metrics
def regression_results(y_true, y_pred):
predictions=y_pred
test_labels=y_true
errors = abs(predictions - test_labels)
# Print out the mean absolute error (mae)
print('Mean Absolute Error:', round(np.mean(errors), 2))
# Calculate mean absolute percentage error (MAPE)
mape = 100 * (errors / test_labels)
# Calculate and display accuracy
accuracy = 100 - np.mean(mape)
print('Accuracy:', round(accuracy, 2), '%.')
# Regression metrics
explained_variance=metrics.explained_variance_score(y_true, y_pred)
mean_absolute_error=metrics.mean_absolute_error(y_true, y_pred)
mse=metrics.mean_squared_error(y_true, y_pred)
mean_squared_log_error=metrics.mean_squared_log_error(y_true, y_pred)
median_absolute_error=metrics.median_absolute_error(y_true, y_pred)
r2=metrics.r2_score(y_true, y_pred)
print('explained_variance: ', round(explained_variance,4))
print('mean_squared_log_error: ', round(mean_squared_log_error,4))
print('r2: ', round(r2,4))
print('MAE: ', round(mean_absolute_error,4))
print('MSE: ', round(mse,4))
print('RMSE: ', round(np.sqrt(mse),4))
These are the results I'm getting for randomforestregressor model (and all other regression models display similar results, including the negative explained variance value).
Mean Absolute Error: 0.02
Accuracy: 98.41 %.
explained_variance: -0.4901
mean_squared_log_error: 0.0001
r2: -0.5035
MAE: 0.0163
MSE: 0.0004
RMSE: 0.0205
Does this mean my data is bad?