-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComparison_experiment_5.py
89 lines (70 loc) · 3.02 KB
/
Comparison_experiment_5.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import pandas as pd
from river import metrics
from Functions.Create_Plots import create_plots
from Functions.Data_plot import data_plot
from Functions.Prepare_data import prepare_data
from Functions.Evaluation import evaluation
from AML4S.AML4S_Usage import use_AML4S
from Functions.Comparison_with_OAML_basic_plot import compare_with_oaml
import time
from Functions.Result_extractor import result_extractor
"""
An example of how to use all the functions of the project
"""
if __name__ == "__main__":
seed = 30
# Load dataset
data = prepare_data('../More_datasets/Vehicle.csv')
# set the target name
target = list(data[0].keys())[0]
# create the lists to save the results
y_real = []
y_predicted = []
data_drifts = []
concept_drifts = []
print("-----------------------------------------------------------------------------------------------------------")
# pipeline 1
start_time = time.time()
y_real_temp, y_predicted_temp, data_drifts_temp, concept_drifts_temp = (
use_AML4S(data, target, False, True, seed = seed))
finish_time = time.time()
total_time = finish_time - start_time
print("Time of pipeline 1: ", total_time)
# add the results from the pipeline in the lists
y_real.append(y_real_temp)
y_predicted.append(y_predicted_temp)
data_drifts.append(data_drifts_temp)
concept_drifts.append(concept_drifts_temp)
result_extractor(5, 1, y_real_temp, y_predicted_temp, data_drifts_temp, concept_drifts_temp)
print("-----------------------------------------------------------------------------------------------------------")
# pipeline 2
start_time = time.time()
y_real_temp, y_predicted_temp, data_drifts_temp, concept_drifts_temp = (
use_AML4S(data, target, True, True, seed = seed))
finish_time = time.time()
total_time = finish_time - start_time
print("Time of pipeline 2: ", total_time)
# add the results from the pipeline in the lists
y_real.append(y_real_temp)
y_predicted.append(y_predicted_temp)
data_drifts.append(data_drifts_temp)
concept_drifts.append(concept_drifts_temp)
result_extractor(5, 2, y_real_temp, y_predicted_temp, data_drifts_temp, concept_drifts_temp)
# Delete the temporal variables
del y_real_temp, y_predicted_temp, data_drifts_temp, concept_drifts_temp
# evaluation of pipelines
evaluates = evaluation(y_real, y_predicted, metrics.Accuracy())
# plots for metrics and drifts of the pipelines
create_plots(evaluates, data_drifts, concept_drifts)
# Read the CSV file into a pandas DataFrame
df = pd.read_csv('../More_datasets/OAML-basic vehicle.csv', delimiter=';')
result_to_compare = []
# add the mean evaluation of pipelines in a list
for mean_evaluation in evaluates[1]:
result_to_compare.append(mean_evaluation)
# add the mean evaluation of oaml
result_to_compare.append(df.iloc[:, 0].tolist())
# compare the pipelines with oaml
compare_with_oaml(result_to_compare)
# plots for data
data_plot(data, 500)