I tried to predict label of my newly added data through SGDClassifer.partial_fit as below:
from sklearn import neighbors, linear_model
import numpy as np
def train_predict():
X = [[1, 1], [2, 2.5], [2, 6.8], [4, 7]]
y = [1, 2, 3, 4]
sgd_clf = linear_model.SGDClassifier(loss="log")
sgd_clf.fit(X, y)
X1 = [[6,9]]
y1=[5]
f1 = sgd_clf.partial_fit(X1,y1)
f1.predict([[6,9]])
return f1
if __name__ == "__main__":
clf = train_predict()
fit perfectly predicts the labels. However, prediction with partial fit results in error as:
in compute_class_weight
raise ValueError("classes should include all valid labels that can be in y")
similar to Sklearn SGDC partial_fit ValueError: classes should include all valid labels that can be in y, I read partial_fit manual, http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html#sklearn.linear_model.SGDClassifier.partial_fit
But i am still not able to figure out how to set the parameters of partial_fit so that i can be able to predict the data added on the fly.
Any references or ideas ?