July 2017
Intermediate to advanced
382 pages
9h 13m
English
Believe it or not, OpenCV does not offer any good implementation of linear regression. Some people online say that you can use cv2.fitLine, but that is different. This is a perfect opportunity to get familiar with scikit-learn's API:
In [6]: linreg = linear_model.LinearRegression()
In the preceding command, we want to split the data into training and test sets. We are free to make the split as we see fit, but usually it is a good idea to reserve between 10 percent and 30 percent for testing. Here, we choose 10 percent, using the test_size argument:
In [7]: X_train, X_test, y_train, y_test = modsel.train_test_split(... boston.data, boston.target, test_size=0.1,... random_state=42... )
In scikit-learn, the train function ...
Read now
Unlock full access