Sklearn SGDC partial_fit ValueError: classes should include all valid labels that can be in y

爷,独闯天下 提交于 2019-12-12 04:01:51

问题


loaded already trained SGDC model and tried to again partial_fit with new features set and data. but received ValueError: classes should include all valid labels that can be in y and my class_weights = None and wanted to have each class equal weights.

model_predicted_networktype = joblib.load(f)
new_training_data_count_matrix 
=count_vect_predicted_networktype.transform(training_dataset)
new_training_tf_idf = tf_idf(new_training_data_count_matrix)
model_predicted_networktype.partial_fit(new_training_tf_idf,training_labels)

I got the issue has I am adding new features to my already trained model and those are different what previously have fitted, but I need to add new features to already partial_fit data?


回答1:


Do classes=numpy.arange(some_estimated_max_number) in your first call to partial_fit and map the numbers to actual labels. This way you can add your data on the fly.



来源:https://stackoverflow.com/questions/44075801/sklearn-sgdc-partial-fit-valueerror-classes-should-include-all-valid-labels-tha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!