olpy.classifiers
The repository of all the binary classifiers implemented with the package.
This module exposes a series of online machine learning models that can be used for binary classification. The models learn by taking one data point at a time and can achieve very good accuracy results.
One of the features of the models is to allow for usage of class weights during the training process. They also permit to train using a single data point with the partial_fit method.
Examples
Training a model
>>> from olpy.classifiers import AROW
>>> from olpy.datasets import load_a1a
>>> from sklearn.metrics import accuracy_score
>>> a1a = load_a1a()
>>> model = AROW(random_state = 32)
>>> _ = model.fit(a1a.train_data, a1a.train_target)
>>> prediction = model.predict(a1a.test_data)
>>> accuracy_score(a1a.test_target, prediction)
0.8379312572683809
Using the weights to change the performance
>>> model = AROW(random_state=32, class_weight=np.list([0.4, 0.6]))
>>> _ = model.fit(a1a.train_data, a1a.train_target)
>>> prediction = model.predict(a1a.test_data)
>>> accuracy_score(a1a.test_target, prediction)
0.838254296417262
Doing a partial learn (meant for active learning processes)
>>> import random
>>> import numpy as np
>>> random.seed(32)
>>> model = AROW(random_state = 32)
>>> for i in random.sample(range(a1a.train_data.shape[0]), k=10):
... model = model.partial_fit(np.expand_dims(a1a.train_data[i], axis=0), [a1a.train_target[i]])
>>> prediction = model.predict(a1a.test_data)
>>> accuracy_score(a1a.test_target, prediction)
0.13551492440883836
Classes
A New Approximate Maximal Margin Classification Algorithm. |
|
The Adaptive Regularization of Weight vectors model. |
|
The Confidence-Weighted model. |
|
The Exact convex confidence-weighted learning model. |
|
The Improved Ellipsoid model. |
|
New adaptive algorithms for online classification |
|
Gaussian Herding model. |
|
Online Gradient Descent model. |
|
Passive-Aggressive Model. |
|
Passive Aggressive-I Model. |
|
Passive Aggressive-II Model. |
|
The Perceptron model. |
|
The Relaxed Online Maximum Margin Algorithm. |
|
Soft Confidence Weighted model. |
|
Soft Confidence Weighted variant 2 model. |
|
Second Order Perceptron model. |
|
The (Aggressive) Relaxed Online Maximum Margin Algorithm. |