Python Forum
python code will not interpret
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python code will not interpret
#1
The following code generates an error when I try to interpret it with python.

svm_c = GridSearchCV(
    cv=TimeSeriesSplit(gap=0, max_train_size=None, n_splits=5, test_size=None),
    estimator=SGDClassifier(n_jobs=-1, random_stat=21),
    n_jobs=-1,
    param_grid={"alpha": [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000]},
    return_train_score=True,
    scoring="f1_macro",
)
The error is:

TypeError                                 Traceback (most recent call last)
Input In [187], in <cell line: 1>()
      1 svm_c = GridSearchCV(
      2     cv=TimeSeriesSplit(gap=0, max_train_size=None, n_splits=5, test_size=None),
----> 3     estimator=SGDClassifier(n_jobs=-1, random_stat=21),
      4     n_jobs=-1,
      5     param_grid={"alpha": [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000]},
      6     return_train_score=True,
      7     scoring="f1_macro",
      8 )

TypeError: SGDClassifier.__init__() got an unexpected keyword argument 'random_stat'
I am not sure why. I googled the error, and it claimed that scikit-learn was the problem. I have version 1.1.1. It says that
I need version 0.18. I upgraded scikit-learn to 1.1.2 and got the same error when I tried to interpret it.

I should emphasize that I am only running this code snippet. It is part of a larger program, but I am just working it this piece now.

I cannot upgrade scikit-learn to version 0.18. That is impossible.

I used the command

pip install scikit-learn==0.18 --force upgrade 
and all it did was give a lot of errors. Why is this error that I discussed above happening? I am using
python 3.10.4.

I suspect it has to do with a specific version of scikit-learn.


Respectfully,

Led_Zepplin
Reply
#2
SGDClassifier expects random_state but you gave random_stat
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020