To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

combine_results.py 1.64 KB
Newer Older
felikskiszkurno's avatar
felikskiszkurno committed
1
2
3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
4
Created on 19.01.2021
felikskiszkurno's avatar
felikskiszkurno committed
5

6
@author: Feliks Kiszkurno
felikskiszkurno's avatar
felikskiszkurno committed
7
"""
8

9
import matplotlib.pyplot as plt
10
from pathlib import Path
11
12


13
14
def combine_results(ml_results):

15
16
    # TODO avoid reusing the same code twice
    # Predictions
17
    fig = plt.figure()
18
19
    ax = fig.subplots(1)
    fig.suptitle('Accuracy of different ML methods: predictions')
20

21
22
23
    for method_name in sorted(ml_results.keys()):
        plt.plot(ml_results[method_name]['labels'], ml_results[method_name]['score'], marker='x',
                 label=method_name)
24

25
26
27
28
    plt.xlabel('Test name')
    plt.setp(ax.get_xticklabels(), rotation=45)
    plt.ylabel('Correct points [%]')
    plt.legend(loc='lower right')
29

30
    # fig.savefig(Path('results/figures/ML_summary_prediction.eps'))
31
    fig.savefig(Path('results/figures/ML_summary_prediction.png'))
32
    # fig.savefig(Path('results/figures/ML_summary_prediction.pdf'))
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

    # Training
    fig = plt.figure()
    ax = fig.subplots(1)
    fig.suptitle('Accuracy of different ML methods - training')

    for method_name in sorted(ml_results.keys()):
        plt.plot(ml_results[method_name]['labels_training'], ml_results[method_name]['score_training'], marker='x',
                 label=method_name)

    plt.xlabel('Test name')
    plt.setp(ax.get_xticklabels(), rotation=90)
    plt.ylabel('Correct points [%]')
    plt.legend(loc='lower right')

    fig.tight_layout()
49
    # fig.savefig(Path('results/figures/ML_summary_training.eps'), bbox_inches="tight")
50
    fig.savefig(Path('results/figures/ML_summary_training.png'), bbox_inches="tight")
51
    # fig.savefig(Path('results/figures/ML_summary_training.pdf'), bbox_inches="tight")