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

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.

主站蜘蛛池模板: 河东区| 静宁县| 海城市| 镇沅| 肥东县| 中牟县| 龙井市| 娄底市| 福州市| 文登市| 页游| 甘德县| 都匀市| 公安县| 亳州市| 井冈山市| 珲春市| 鄂温| 晴隆县| 济源市| 抚顺市| 平利县| 连城县| 通榆县| 梓潼县| 获嘉县| 延长县| 喀喇沁旗| 辰溪县| 都安| 五莲县| 黄平县| 阿拉尔市| 马鞍山市| 黎川县| 资兴市| 马山县| 昌都县| 松桃| 收藏| 白沙|