Last active
May 14, 2019 16:40
-
-
Save linkerzx/b7865d5b8d544d90c743d8cc22b78089 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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