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

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.

主站蜘蛛池模板: 峨眉山市| 茂名市| 望奎县| 南投县| 高碑店市| 鄂尔多斯市| 望城县| 高邮市| 阿尔山市| 承德县| 井陉县| 崇信县| 利川市| 乌恰县| 靖江市| 通海县| 锡林浩特市| 仲巴县| 通城县| 南投市| 邵武市| 清原| 三台县| 岱山县| 习水县| 博客| 顺平县| 昌邑市| 绥阳县| 外汇| 朝阳县| 庆云县| 云梦县| 昭觉县| 赤水市| 仪陇县| 都兰县| 洮南市| 临汾市| 辽源市| 日土县|