python-machine-learning-book-2nd-edition icon indicating copy to clipboard operation
python-machine-learning-book-2nd-edition copied to clipboard

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

Open fgghhsha123 opened this issue 3 years ago • 1 comments

[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'

fgghhsha123 avatar Sep 20 '20 09:09 fgghhsha123

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.

rasbt avatar Oct 02 '20 21:10 rasbt