Matplotlib 如何从日志文件中绘制损失

Matplotlib 如何从日志文件中绘制损失,matplotlib,Matplotlib,下面提到的是文件“log”中生成的损失值(迭代次数实际上比我下面列出的要多)。附上日志文件内容的屏幕截图供参考。如何在“日志”文件中绘制这些内容的迭代(x轴)与损失(y轴) 0: combined_hm_loss: 0.17613089 1: combined_hm_loss: 0.20243575 2: combined_hm_loss: 0.07203530 3: combined_hm_loss: 0.03444689 4: combined_hm_loss: 0.0262346

下面提到的是文件“log”中生成的损失值(迭代次数实际上比我下面列出的要多)。附上日志文件内容的屏幕截图供参考。如何在“日志”文件中绘制这些内容的迭代(x轴)与损失(y轴)

0:  combined_hm_loss: 0.17613089
1:  combined_hm_loss: 0.20243575
2:  combined_hm_loss: 0.07203530
3:  combined_hm_loss: 0.03444689
4:  combined_hm_loss: 0.02623464
5:  combined_hm_loss: 0.02061908
6:  combined_hm_loss: 0.01562270
7:  combined_hm_loss: 0.01253260
8:  combined_hm_loss: 0.01102418
9:  combined_hm_loss: 0.00958306
10:  combined_hm_loss: 0.00824807
11:  combined_hm_loss: 0.00694697
12:  combined_hm_loss: 0.00640630
13:  combined_hm_loss: 0.00593691
14:  combined_hm_loss: 0.00521284
15:  combined_hm_loss: 0.00445185
16:  combined_hm_loss: 0.00408901
17:  combined_hm_loss: 0.00377806
18:  combined_hm_loss: 0.00314004
19:  combined_hm_loss: 0.00287649
试试这个:

import pandas as pd
import numpy as np
import io

data = '''
index combined_hm_loss
0:   0.17613089
1:   0.20243575
2:   0.07203530
3:   0.03444689
4:   0.02623464
5:   0.02061908
6:   0.01562270
7:   0.01253260
8:   0.01102418
9:   0.00958306
10:   0.00824807
11:   0.00694697
12:   0.00640630
13:   0.00593691
14:   0.00521284
15:   0.00445185
16:   0.00408901
17:   0.00377806
18:   0.00314004
19:   0.00287649
'''

df = pd.read_csv(io.StringIO(data), delim_whitespace=True)
ax = df.plot.area(y='combined_hm_loss')
ax.invert_yaxis()

到目前为止,您有什么结果?请展示你的作品。您是否尝试将示例签入此库?首先,你需要将你的每一行分成两个值。谢谢r初学者。谢谢你的回答。我也很高兴能帮助你。请接受我的回答。