r2=r2_score(X_test['score'],X_test['pred']) mape=mean_absolute_percentage_error(X_test['score'],X_test['pred']) print(r2) print(mape)
时间: 2024-05-31 12:07:34 浏览: 94
As an AI language model, I cannot run this code because the variables (X_test, score, pred) are not defined. However, I can explain what this code does:
- r2_score() is a function from the scikit-learn library that calculates the coefficient of determination (R-squared) between the actual values (score) and the predicted values (pred).
- mean_absolute_percentage_error() is a custom function that calculates the mean absolute percentage error (MAPE) between the actual values and the predicted values.
- X_test['score'] and X_test['pred'] are two columns of a Pandas DataFrame that contain the actual scores and the predicted scores, respectively.
- The r2_score() function is called with the actual scores and the predicted scores as arguments, and the resulting R-squared value is stored in the variable r2.
- The mean_absolute_percentage_error() function is called with the actual scores and the predicted scores as arguments, and the resulting MAPE value is stored in the variable mape.
- Finally, the R-squared value and the MAPE value are printed to the console.
阅读全文