本文整理匯總了Python中sklearn.metrics.regression.mean_squared_error方法的典型用法代碼示例。如果您正苦於以下問題:Python regression.mean_squared_error方法的具體用法?Python regression.mean_squared_error怎麽用?Python regression.mean_squared_error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.metrics.regression
的用法示例。
在下文中一共展示了regression.mean_squared_error方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: score
# 需要導入模塊: from sklearn.metrics import regression [as 別名]
# 或者: from sklearn.metrics.regression import mean_squared_error [as 別名]
def score(self, X, y, step=1, method="r2"):
"""
Produce multi-step prediction of y, and compute the metrics against y.
Nan is ignored when computing the metrics.
:param array-like X: exogenous input time series, shape = (n_samples,
n_exog_inputs)
:param array-like y: target time series to predict, shape = (n_samples)
:param int step: prediction step.
:param string method: could be "r2" (R Square) or "mse" (Mean Square
Error).
:return: prediction metric. Nan is ignored when computing the metrics.
"""
ypred = self.predict(X, y, step=step)
mask = np.isnan(y) | np.isnan(ypred)
if method == "r2":
return r2_score(y[~mask], ypred[~mask])
elif method == "mse":
return mean_squared_error(y[~mask], ypred[~mask])
示例2: plot_predictions_by_dimension
# 需要導入模塊: from sklearn.metrics import regression [as 別名]
# 或者: from sklearn.metrics.regression import mean_squared_error [as 別名]
def plot_predictions_by_dimension(data_x, data_y, data_test):
score_y_by_dimension = predictions_by_dimension(data_y, data_test)
score_x_by_dimension = predictions_by_dimension(data_x, data_test)
mse = mean_squared_error(score_x_by_dimension, score_y_by_dimension)
return score_x_by_dimension, score_y_by_dimension, mse
示例3: plot_predictions_by_categorical
# 需要導入模塊: from sklearn.metrics import regression [as 別名]
# 或者: from sklearn.metrics.regression import mean_squared_error [as 別名]
def plot_predictions_by_categorical(data_x, data_y, data_test, variable_sizes):
score_y_by_categorical = predictions_by_categorical(data_y, data_test, variable_sizes)
score_x_by_categorical = predictions_by_categorical(data_x, data_test, variable_sizes)
mse = mean_squared_error(score_x_by_categorical, score_y_by_categorical)
return score_x_by_categorical, score_y_by_categorical, mse
示例4: mse_probabilities_by_dimension
# 需要導入模塊: from sklearn.metrics import regression [as 別名]
# 或者: from sklearn.metrics.regression import mean_squared_error [as 別名]
def mse_probabilities_by_dimension(data_x, data_y):
p_x_by_dimension = probabilities_by_dimension(data_x)
p_y_by_dimension = probabilities_by_dimension(data_y)
mse = mean_squared_error(p_x_by_dimension, p_y_by_dimension)
return p_x_by_dimension, p_y_by_dimension, mse