Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sklearn.exceptions.NotFittedError: This SGDClassifier instance is not fitted yet #17

Open
yonatanbitton opened this issue Jan 19, 2020 · 1 comment

Comments

@yonatanbitton
Copy link

Hello

This is the code i'm trying to run:

    X_train, y_train = prepare_data_for_ml(X_train, y_train)
    y_train, y_test = prepare_data_for_ml(X_test, y_test)

    clf = HungaBungaClassifier()
    clf.fit(X_train, y_train)

    clf.predict(X_test)

That's the error:

100%|██████████| 15/15 [00:00<00:00, 43.02it/s]
Traceback (most recent call last):
  File "/Users/yonatab/PycharmProjects/VisualFitnessUtils/activate_ml/activate_ml_on_joints.py", line 62, in <module>
    main()
  File "/Users/yonatab/PycharmProjects/VisualFitnessUtils/activate_ml/activate_ml_on_joints.py", line 43, in main
    clf.predict(X_test)
  File "/Users/yonatab/opt/anaconda3/envs/CondaEnv/lib/python3.7/site-packages/hunga_bunga/classification.py", line 202, in predict
    return self.model.predict(x)
  File "/Users/yonatab/opt/anaconda3/envs/CondaEnv/lib/python3.7/site-packages/sklearn/linear_model/base.py", line 289, in predict
    scores = self.decision_function(X)
  File "/Users/yonatab/opt/anaconda3/envs/CondaEnv/lib/python3.7/site-packages/sklearn/linear_model/base.py", line 263, in decision_function
    "yet" % {'name': type(self).__name__})
sklearn.exceptions.NotFittedError: This SGDClassifier instance is not fitted yet

Am I missing something?

Thanks

@sreichl
Copy link

sreichl commented Mar 23, 2020

Hi,
I think you overwrite the variable y_train involuntarily (second line), there should probably be X_test.
Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants