上面的代码报错module 'numpy' has no attribute 'kde'
时间: 2023-12-21 21:31:05 浏览: 85
多线程爬虫出现报错AttributeError: ‘NoneType’ object has no attribute ‘xpath’
```python
import numpy as np
from sklearn.neighbors import KernelDensity
# 创建一些随机数据
data = np.random.rand(100, 1)
# 使用KernelDensity估计概率密度
kde = KernelDensity(bandwidth=1.0, kernel='gaussian')
kde.fit(data)
# 生成新的数据点
new_data = np.linspace(0, 1, 100)[:, np.newaxis]
# 计算新数据点的概率密度估计
log_dens = kde.score_samples(new_data)
```
阅读全文