【发布时间】:2021-08-18 02:02:03
【问题描述】:
我在 Jupyter notebook 中尝试了以下凝聚聚类。
我的数据集的形状是(406829, 8)。
我尝试了以下代码:
import pandas as pd
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
import os
from sklearn.preprocessing import StandardScaler, LabelEncoder
import scipy.cluster.hierarchy as shc
from sklearn.cluster import AgglomerativeClustering
# Apply the agglomerative clustering with ward linkage
aggloclust = AgglomerativeClustering(affinity='euclidean',linkage='ward', memory=None, n_clusters=5).fit(data)
print(aggloclust)
# Agglomerative clustering labels
labels = aggloclust.labels_
# Show the clusters on the graph
plt.scatter(x[:,0], x[:,1], c=labels)
plt.show()
然后我遇到了一个错误 - MemoryError: Unable to allocate 617. GiB for an array with shape (82754714206,) and data type float64
我正在使用 16GB RAM 的 Windows 机器。 Python 版本 - 3.8.5 谁能告诉我如何解决这个问题。
我试图用谷歌搜索这个错误并得到了解决方案 - 创建 jupyter 配置文件 然后更新该文件中的 max_buffer_size 我在这里找到了 - How to increase Jupyter notebook Memory limit?
我尝试了上面链接中提供的解决方案,但没有奏效。 请帮帮我。
【问题讨论】:
-
如果您只有 16 GB 的物理 RAM,您无法通过增加配置文件中的数字来神奇地获得 617 GB 的内存。
-
82754714206这个数字是从哪里来的?
标签: python python-3.x machine-learning artificial-intelligence