def print_metrics_regression(y_true, predictions, verbose=1):
predictions = np.array(predictions)
predictions = np.maximum(predictions, 0).flatten()
y_true = np.array(y_true)
y_true_bins = [get_bin_custom(x, CustomBins.nbins) for x in y_true]
prediction_bins = [get_bin_custom(x, CustomBins.nbins) for x in predictions]
cf = metrics.confusion_matrix(y_true_bins, prediction_bins)
if verbose:
print "Custom bins confusion matrix:"
print cf
kappa = metrics.cohen_kappa_score(y_true_bins, prediction_bins,
weights='linear')
mad = metrics.mean_absolute_error(y_true, predictions)
mse = metrics.mean_squared_error(y_true, predictions)
mape = mean_absolute_percentage_error(y_true, predictions)
if verbose:
print "Mean absolute deviation (MAD) =", mad
print "Mean squared error (MSE) =", mse
print "Mean absolute percentage error (MAPE) =", mape
print "Cohen kappa score =", kappa
return {"mad": mad,
"mse": mse,
"mape": mape,
"kappa": kappa}
评论列表
文章目录