Curvingo · Made in India

Glossary

Select one of the keywords on the left…

Testing Your AICode with Python

Reading time: ~5 min

In scikit-learn, KFold cuts the data into folds and cross_val_score trains and scores one model per fold. To fit a curve of degree 2 we give LinearRegression two columns for every farm, x and x²; the "straight line" through both is then a parabola. scikit-learn always treats a bigger score as better, so it reports errors as negative numbers — hence the minus signs. Run it, then try another k.

The Fold Loop, by Hand

Without scikit-learn, cross-validation is one loop: for each fold, train on the other farms and score on this one. np.array_split cuts the farm numbers 0 to 19 into k folds, and np.setdiff1d finds every farm that is not in the fold. Run it and compare with the output above.

To reveal more content, you have to complete all the activities and exercises above. 
Are you stuck? or reveal all steps

Next up:
Summary
Sina