@takane takane / graph.py
Created at Thu Oct 27 17:37:31 JST 2022
CreateML コマンドライン版の出力からAccuracyの表をグラフ化
graph.py
Raw
import numpy as np
import matplotlib.pyplot as plt
import sys

args = sys.argv
 
# data01_axis1, data01_value1 = np.loadtxt(args[1], delimiter="|", usecols=range(1,3), unpack=True)
data01_axis1, data01_value1 = np.loadtxt(args[1], delimiter="|", usecols=[1,3], unpack=True) 
data01_axis1, data02_value1 = np.loadtxt(args[1], delimiter="|", usecols=[1,4], unpack=True)

fig = plt.figure(figsize=(10, 6))

ax = fig.add_subplot(111)
ax.plot(data01_axis1, data01_value1, "-", color="k", label="Training")
ax.plot(data01_axis1, data02_value1, "-", color="r", label="Validation")
# ax.set_xlim(1000, 3000)

ax.set_xlabel("Iterations")
ax.set_ylabel("Accuracy")
ax.legend(loc="upper left")
plt.show()
@takane takane commented on 27 Oct 2022

pythonのモジュール matplotlib, numpyをインストールしておく

pip install matplotlib
pip install bumpy

使い方:

python graph.py sample.log

sample.logの中身

| 0         | 7.308949     | 0.243850          | 0.204301            |
| 1         | 17.260784    | 0.287873          | 0.548387            |
| 2         | 21.507165    | 0.278281          | 0.580645            |
| 3         | 31.503501    | 0.341721          | 0.774194            |
| 4         | 35.703591    | 0.331074          | 0.623656            |
| 6         | 44.050177    | 0.354467          | 0.838710            |
| 7         | 54.176807    | 0.360164          | 0.838710            |
| 8         | 65.836107    | 0.373952          | 0.838710            |
| 9         | 70.066764    | 0.334646          | 0.720430            |
| 10        | 75.802982    | 0.379841          | 0.838710            |
| 11        | 80.065383    | 0.389496          | 0.849462            |
| 12        | 84.302850    | 0.399356          | 0.870968            |
| 13        | 88.558791    | 0.407952          | 0.892473            |
| 14        | 94.589386    | 0.419323          | 0.924731            |
| 15        | 98.807388    | 0.416379          | 0.946237            |
| 16        | 106.050008   | 0.423349          | 0.956989            |
| 17        | 111.748439   | 0.425128          | 0.946237            |
| 18        | 116.012590   | 0.426682          | 0.946237            |
| 19        | 120.243238   | 0.424609          | 0.935484            |
| 20        | 124.485083   | 0.425827          | 0.924731            |