导入 top2vec 时我不断收到此错误。
TypeError Traceback (most recent call last)
Cell In [1], line 1
----> 1 from top2vec import Top2Vec
File ~\AppData\Roaming\Python\Python39\site-packages\top2vec\__init__.py:1
----> 1 from top2vec.Top2Vec import Top2Vec
3 __version__ = '1.0.27'
File ~\AppData\Roaming\Python\Python39\site-packages\top2vec\Top2Vec.py:12
10 from gensim.models.phrases import Phrases
11 import umap
---> 12 import hdbscan
13 from wordcloud import WordCloud
14 import matplotlib.pyplot as plt
File ~\AppData\Roaming\Python\Python39\site-packages\hdbscan\__init__.py:1
----> 1 from .hdbscan_ import HDBSCAN, hdbscan
2 from .robust_single_linkage_ import RobustSingleLinkage, robust_single_linkage
3 from .validity import validity_index
File ~\AppData\Roaming\Python\Python39\site-packages\hdbscan\hdbscan_.py:509
494 row_indices …Run Code Online (Sandbox Code Playgroud) 得到这个内存错误。但是我正在关注的书/链接没有收到此错误。
部分代码:
from sklearn.linear_model import SGDClassifier
sgd_clf = SGDClassifier()
sgd_clf.fit(x_train, y_train)
Run Code Online (Sandbox Code Playgroud)
错误:
MemoryError: Unable to allocate 359. MiB for an array with shape (60000, 784) and data type float64
当我尝试使用 StandardScaler 的 fit_transfrom 缩放数据时,我也会收到此错误
但是如果我减少训练集的大小(例如:x_train[:1000],y_train[:1000]),两者都可以正常工作
本书中代码的链接在这里。我得到的错误在第 60 行和第 63 行(In [60]和In [63])
本书:Aurélien Géron - 使用 Scikit-Learn Keras 和 Tensorflow 进行机器学习实践第二版(页数:149 / 1130)
这和我的ram有关系吗?“无法分配 359”是什么意思?是内存大小吗?
以防万一我的规格:CPU - ryzen 2400g ,ram - 8gb(使用 jupyter notebook 时免费 3.1gb)
我正在尝试从该网站抓取信息,但不断收到状态代码:403,因此尝试使用 header 但收到TypeError:request() 获得意外的关键字参数“header”
代码:
import requests
head = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0'}
url = "https://www.accuweather.com/en/bd/dhaka/28143/current-weather/28143"
pageObj = requests.get(url, header = head)
print("Status code: " + str(pageObj.status_code)) # *for testing purpose*
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "F:/Python/PyCharm Community Edition 2019.2.3/Workshop/WEB_SCRAPING/test2.py", line 6, in <module>
pageObj = requests.get(url, header = head)
File "F:\Python\PyCharm Community Edition 2019.2.3\Workshop\WEB_SCRAPING\venv\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "F:\Python\PyCharm …Run Code Online (Sandbox Code Playgroud)