<Figure size 1000x1000 with 0 Axes> --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[36], line 5 3 colnm = data_train1.columns.tolist() # 列表头 4 mcorr = data_train1[colnm].corr(method="spearman") # 相关系数矩阵,即给出了任意两个变量之间的相关系数 ----> 5 mask = np.zeros_like(mcorr, dtype=np.bool) # 构造与mcorr同维数矩阵 为bool型 6 mask[np.triu_indices_from(mask)] = True # 角分线右侧为True 7 cmap = sns.diverging_palette(220, 10, as_cmap=True) # 返回matplotlib colormap对象 File c:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\numpy\__init__.py:305, in __getattr__(attr) 300 warnings.warn( 301 f"In the future `np.{attr}` will be defined as the " 302 "corresponding NumPy scalar.", FutureWarning, stacklevel=2) 304 if attr in __former_attrs__: --> 305 raise AttributeError(__former_attrs__[attr]) 307 # Importing Tester requires importing all of UnitTest which is not a 308 # cheap import Since it is mainly used in test suits, we lazy import it 309 # here to save on the order of 10 ms of import time for most users 310 # 311 # The previous way Tester was imported also had a side effect of adding 312 # the full `numpy.testing` namespace 313 if attr == 'testing': AttributeError: module 'numpy' has no attribute 'bool'. `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations出现的问题
时间: 2023-06-25 07:05:25 浏览: 115
这个错误出现在使用 `np.bool` 构造一个与相关系数矩阵同维数的布尔型矩阵时。在新版本的 NumPy 中,`np.bool` 已经被弃用,需要使用 `bool` 关键字代替。因此,你需要将代码中的 `np.bool` 替换为 `bool`。如果你需要使用 NumPy 的布尔型数据类型,应该使用 `np.bool_`。
相关问题
vncserver -geometry 1900x1000
vncserver -geometry 1900x1000是用于设置VNC服务器的分辨率大小的命令。在执行这个命令之前,有两种方式可以进行VNC桌面的启动配置。一种是通过在/etc/sysconfig/vncservers文件中配置启动,这种方式可以在服务器启动的时候就自动启动VNC桌面,并可以直接远程连接。另一种方式是在机器运行的时候使用vncserver :桌面号命令来手动启动VNC桌面,但这种方式在机器重启后会失效。对于使用文件进行配置的方式,需要在root用户下执行以下操作:
1. 打开/etc/sysconfig/vncservers文件。
2. 找到VNCSERVERS这一行,将需要启动的用户和对应的桌面号添加到该行中。例如,如果要启动root用户的桌面号为1,jason用户的桌面号为2,则可以将VNCSERVERS修改为:VNCSERVERS="1:root 2:jason"。
3. 在文件中继续向下查找,找到VNCSERVERARGS[数字]这一行,将对应桌面号的分辨率和其他参数添加到该行中。例如,要将桌面号1设置为分辨率为1600x1000,桌面号2也设置为分辨率为1600x1000,则可以将VNCSERVERARGS修改为:VNCSERVERARGS="-geometry 1600x1000 -nolisten tcp -localhost" VNCSERVERARGS="-geometry 1600x1000 -nolisten tcp -localhost"。
4. 保存文件并退出。
在执行vncserver -geometry 1900x1000命令之前,请确保已经按照上述步骤进行了相关配置,并且你的用户有执行vncserver命令的权限。
jpeg-ls 图像压缩C++
JPEG-LS 是一种无损的图像压缩算法,使用 C++ 实现它可以使用一些开源库,如 OpenCV 或 libjpeg。以下是一个使用 OpenCV 库来进行 JPEG-LS 图像压缩的示例代码:
```cpp
#include <opencv2/opencv.hpp>
int main() {
// 读取原始图像
cv::Mat image = cv::imread("input.jpg", cv::IMREAD_COLOR);
if (image.empty()) {
std::cout << "Failed to read image!" << std::endl;
return -1;
}
// 定义 JPEG-LS 压缩参数
std::vector<int> compression_params;
compression_params.push_back(cv::IMWRITE_JPEG2000_COMPRESSION_X1000); // 压缩质量参数,范围为 [0, 1000],值越小压缩比越高
// 执行 JPEG-LS 压缩
cv::imwrite("output.jls", image, compression_params);
return 0;
}
```
上述代码使用了 OpenCV 库中的 `imwrite` 函数来进行 JPEG-LS 压缩。你可以通过调整 `IMWRITE_JPEG2000_COMPRESSION_X1000` 参数的值来控制压缩质量,值越小压缩比越高。压缩后的图像将保存为名为 "output.jls" 的文件。
请注意,为了编译和运行此代码,你需要先安装并配置好 OpenCV 库。