-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate_Plots.py
More file actions
57 lines (41 loc) · 2.19 KB
/
Copy pathCreate_Plots.py
File metadata and controls
57 lines (41 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
def create_plots(results: list[list], data_drifts: list[list], concept_drifts: list[list]):
"""
Creates the plots of the metric we choose for our model
Args:
results: List with the metrics (the mean metric[1][i] and the windowing metric[0][i] of every model wee tested)
data_drifts: Data drift points for each model
concept_drifts: Concept drifts points for each model
returns: Nothing
"""
fig = make_subplots(rows=len(results[0]), cols=1,
subplot_titles=[f"Plot for pipeline {i+1}" for i in range(len(results[0]))])
for i in range(len(results[0])):
# plot
fig.add_trace(go.Scatter(x=np.arange(1, len(results[0][i]) + 1), y=results[0][i], mode='lines',
name=f'Metric for pipeline{i+1}'), row=i + 1, col=1)
fig.add_trace(go.Scatter(x=np.arange(1, len(results[1][i]) + 1), y=results[1][i], mode='lines',
name=f'Average Metric for pipeline{i + 1}'), row=i + 1, col=1)
# add data drifts in plot
for drift_index in data_drifts[i]:
fig.add_vline(x=drift_index, line=dict(color='green', dash='dash'),
name='Data Drift Detected', row=i + 1, col=1)
# add concept drifts in plot
for drift_index in concept_drifts[i]:
fig.add_vline(x=drift_index, line=dict(color='red', dash='dash'),
name='Concept Drift Detected', row=i + 1, col=1)
fig.update_xaxes(title_text="Sample number", row=i + 1, col=1)
fig.update_yaxes(title_text="Metric", range=[0, 1], row=i + 1, col=1)
fig.add_trace(go.Scatter(x=[None], y=[None], mode='lines', line=dict(color='green', dash='dash'),
name='Data Drift'))
fig.add_trace(go.Scatter(x=[None], y=[None], mode='lines', line=dict(color='red', dash='dash'),
name='Concept Drift'))
fig.update_layout(
height=340 * len(results[0]),
title='Metric plot',
legend_title='Legend',
hovermode='x'
)
fig.show()