Mean square error regression loss
format:
sklearm.mean_squared_error (y_true, y_pred, sample_weight=None, multioutput= ‘uniform_average’)
parameter:
y_true: true value.
y_pred: predicted value.
sample_weight: sample weight.
multioutput: multi-dimensional input and output, default is’ uniform_average ‘, calculates the mean square error of all elements, returns as a scalar; Alternatively, ‘raw_values’ computes the mean square error of the corresponding column and returns a one-dimensional array with the same number of columns.
example:
from sklearn.metrics import mean_squared_error
y_true = [3, -1, 2, 7]
y_pred = [2, 0.0, 2, 8]
mean_squared_error(y_true, y_pred)
# Output: 0.75
y_true = [[0.5, 1],[-1, 1],[7, -6]]
y_pred = [[0, 2],[-1, 2],[8, -5]]
mean_squared_error(y_true, y_pred)
# Output: 0.7083333333333334
mean_squared_error(y_true, y_pred, multioutput='raw_values')
# Output: array([0.41666667, 1. ])
mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7])
# Output: 0.825
# multioutput=[0.3, 0.7]返回将array([0.41666667, 1. ])按照0.3*0.41666667+0.7*1.0计算所得的结果
mean_squared_error(y_true, y_pred, multioutput='uniform_average')
# Output: 0.7083333333333334
Refer to the link: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html
Read More:
- ImportError: cannot import name ‘calinski_harabaz_score‘ from ‘sklearn.metrics‘
- RMSE(Root Mean Squared Error) & RMSLE(Root Mean Squared Logarithmic Error)
- NoClassDefFoundError: org/apache/flink/metrics/MetricGroup
- ImportError: cannot import name ‘cross_validation’ from ‘sklearn’
- ModuleNotFoundError: No module named ‘sklearn.datasets.samples_generator‘
- Installing sklearn (scikit learn) module related to Python machine learning in Windows
- Anaconda upgrade sklearn version
- No module named sklearn.neighbors_ typedefs
- In machine learning, the prediction errors in sklearn, such as mean square error, etc
- Sklearn.datasets.base import error [How to Solve]
- Anaconda builds a new environment and installs sklearn, numpy and other modules
- Sklearn ValueError: empty vocabulary; perhaps the documents only contain stop words
- cannot import name ‘cross_validation‘ from ‘sklearn‘
- How to Fix Sklearn ValueError: This solver needs samples of at least 2 classes in the data, but the data
- [problem solving] target is multiclass but average =’binary ‘. Please choose another average setting
- Convergence warning: lbfgs failed to converge (status=1): Stop: total no. of iterations reached L
- Two dimensional array and pointer to one dimensional array
- Error in scikit learn installation of CONDA
- ConnectionResetError: [Errno 104] Connection reset by peer
- Pandas get column name