官术网_书友最值得收藏!

Cross-validation

And now we come to the final part—in order to compare models, we would like to cross-validate the model. We've already set aside a portion of the data. Now, we will have to test the model on the data that was set aside, and compute a score.

The score we'll be using is a Root Mean Square Error. It's used because it's simple and straightforward to understand:

  // VERY simple cross validation
var MSE float64
for i, row := range testingSet {
pred, err := r.Predict(row)
mHandleErr(err)
correct := testingYs[i]
eStar := correct - pred
e2 := eStar * eStar
MSE += e2
}
MSE /= float64(len(testingSet))
fmt.Printf("RMSE: %v\n", math.Sqrt(MSE))

With this, now we're really ready to run the regression analysis.

主站蜘蛛池模板: 萨嘎县| 阿克| 炎陵县| 宝鸡市| 九江县| 虞城县| 江山市| 清流县| 桃园县| 南溪县| 通许县| 桃园市| 津市市| 海盐县| 伽师县| 平潭县| 罗江县| 明星| 吴川市| 揭西县| 邻水| 图们市| 都兰县| 东明县| 富平县| 汤阴县| 郎溪县| 龙岩市| 仁布县| 河间市| 澄城县| 高青县| 桂阳县| 盐边县| 张家界市| 柞水县| 大埔县| 韩城市| 泰宁县| 阿合奇县| 丁青县|