September 2019
Intermediate to advanced
420 pages
10h 29m
English
Creating a logistic regression classifier involves pretty much the same steps as setting up k-NN:
In [14]: lr = cv2.ml.LogisticRegression_create()
We then have to specify the desired training method. Here, we can choose cv2.ml.LogisticRegression_BATCH or cv2.ml.LogisticRegression_MINI_BATCH. For now, all we need to know is that we want to update the model after every data point, which can be achieved with the following code:
In [15]: lr.setTrainMethod(cv2.ml.LogisticRegression_MINI_BATCH)... lr.setMiniBatchSize(1)
We also want to specify the number of iterations the algorithm should run before it terminates:
In [16]: lr.setIterations(100)
We can then call the train method of the object (in the exact same way as we ...
Read now
Unlock full access