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

chap09-9.4 将电影评论分类器转换为网络应用:代码编译不过 #128

Open
fgghhsha123 opened this issue Sep 20, 2020 · 1 comment

Comments

@fgghhsha123
Copy link

[2020-09-20 17:08:04,956] ERROR in app: Exception on /thanks [POST]
Traceback (most recent call last):
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_compat.py", line 39, in reraise
raise value
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "E:\机器学习\python-machine-learning-book-2nd-edition-master\code\ch09\movieclassifier\app.py", line 73, in feedback
train(review, y)
File "E:\机器学习\python-machine-learning-book-2nd-edition-master\code\ch09\movieclassifier\app.py", line 30, in train
clf.partial_fit(X, [y])

File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\linear_model_stochastic_gradient.py", line 680, in partial_fit
self._validate_params(for_partial_fit=True)
File "C:\Users\fw_hh\AppData\Local\Programs\Python\Python38\lib\site-packages\sklearn\linear_model_stochastic_gradient.py", line 128, in _validate_params
if not isinstance(self.early_stopping, bool):
AttributeError: 'SGDClassifier' object has no attribute 'early_stopping'

@rasbt
Copy link
Owner

rasbt commented Oct 2, 2020

Hi there. As far as I know, the early_stopping parameter was added in scikit-learn 0.20. So, my possible explanation for this error could be that the pickle file of the trained SGDClassifier you created in the previous chapter uses a different scikit-learn version than the scikit-learn version that is used when running the web app.

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