Skip to content

Instantly share code, notes, and snippets.

@linkerzx
Last active May 14, 2019 16:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save linkerzx/b7865d5b8d544d90c743d8cc22b78089 to your computer and use it in GitHub Desktop.
Save linkerzx/b7865d5b8d544d90c743d8cc22b78089 to your computer and use it in GitHub Desktop.
import pandas as pd
from sklearn import linear_model
X_0 = pd.DataFrame([[0,0], [1,0]] )
y_0 = pd.DataFrame([[0], [0]])
X_1 = pd.DataFrame([[0,1], [1,1], [1,1]])
y_1 = pd.DataFrame([[1], [1], [1]])
clf = linear_model.SGDClassifier()
clf.partial_fit(X_0, y_0, classes=[0,1])
print(clf.predict([[0,0]])) # -> 0
print(clf.predict([[0,1]])) # -> 0
clf.partial_fit(X_1, y_1, classes=[0,1])
print(clf.predict([[0,0]])) # -> 0
print(clf.predict([[0,1]])) # -> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment