用jupyter notebook画2x2表格
时间: 2023-09-20 18:09:25 浏览: 61
可以使用Python中的pandas库和jupyter notebook来画2x2表格。以下是示例代码:
先在jupyter notebook中运行以下代码安装pandas库:
```
!pip install pandas
```
然后在新的代码单元格中,输入以下代码:
```python
import pandas as pd
# 创建数据
data = {'Actual Positive': [50, 10], 'Actual Negative': [5, 100]}
index = ['Predicted Positive', 'Predicted Negative']
# 创建DataFrame
df = pd.DataFrame(data=data, index=index)
# 显示2x2表格
df
```
代码的执行结果将是:
```
Actual Positive Actual Negative
Predicted Positive 50 5
Predicted Negative 10 100
```
这是一个2x2表格,其中:
- Actual Positive表示实际为正、预测为正的数量
- Actual Negative表示实际为负、预测为负的数量
- Predicted Positive表示预测为正的总数量
- Predicted Negative表示预测为负的总数量
你可以根据实际需要修改数据来创建不同的2x2表格。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)