online-machine-learning
online-machine-learning copied to clipboard
Implementation of an online learning algorithm to do classification under concept drift
trafficstars
This is the implementation of an algorithm to do classification when the distribution of the data generating process changes with time [to be published, https://experiencor.github.io/ftrl_adp.html].
In the following gif, the blue line signifies the decision line to separate two classes. The decision line is adaptive to the centers of the classes, which shift in time.
Code structure
- ftrl_adp.py => the implementation of FTRL-ADP
- Algorithm Visualization.ipynb => visualization that shows the online learning process of FTRL-ADP
- dataset.txt => a simulated classification dataset that contains dynamic concept drifting behavior
Usage
cd ftrl_adp
from ftrl_adp import FTRL_ADP
X_input, Y_label = load_svmlight_file('dataset.txt')
ftrl_adp = FTRL_ADP(L1=1., L2=1., LP = 1., adaptive=True, n_inputs=X_input.shape[1])
for i in xrange(X_input.shape[0]):
indices = X_input[row].indices
x = X_input[row].data
y = y_label[i]
p, decay = classifier.fit(indices, x, y)
error = [int(np.abs(y-p)>0.5)]
