Cross_Validated_Predictions

Plotting Cross-Validated Predictions

Adapted from http://scikit-learn.org/stable/auto_examples/plot_cv_predict.html

This example shows how to use cross_val_predict to visualize prediction errors.

1
2
3
4
5
6
using ScikitLearn
using ScikitLearn.CrossValidation: cross_val_predict

@sk_import datasets: load_boston
@sk_import linear_model: LinearRegression
using PyPlot
1
2
3
4
5
6
7
8
9
10
11
12
lr = LinearRegression()
boston = load_boston()
y = boston["target"]

# cross_val_predict returns an array of the same size as `y` where each entry
# is a prediction obtained by cross validated:
predicted = cross_val_predict(lr, boston["data"], y, cv=10)

scatter(y, predicted)
plot([minimum(y), maximum(y)], [minimum(y), maximum(y)], "k--", lw=4)
xlabel("Measured")
ylabel("Predicted");

png

文章作者: Monad Kai
文章链接: onlookerliu.github.io/2017/12/29/Cross-Validated-Predictions/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Code@浮生记
支付宝打赏
微信打赏