-
Notifications
You must be signed in to change notification settings - Fork 13
/
test.py
77 lines (69 loc) · 2.66 KB
/
test.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
"""
This file is for testing the integration of the library classes and functions.
"""
from tab_automl.automl.datasets import Iris, Wine
from tab_automl.automl.training import Trainer
from tab_automl.automl.processing import PreProcessing
from tab_automl.automl.fet_engineering import FeatureEngineering
from tab_automl.utils.training import train_validation_split
def classification_test():
print(f"Testing through Classification AutoML ...")
# Loading the dataset
dataset = Iris()
# X feature set and target feature split
x, y = dataset.prepare_x_and_y()
# Defining processor
processor = PreProcessing(x=x, y=y)
# Executing processor
processor.run()
# Saving processed data
processor.save_data()
# Defining feature engineer
feature_engineer = FeatureEngineering(x=x, y=y)
# Executing feature engineer
feature_engineer.run()
# Saving engineered data
feature_engineer.save_data()
# Defining model trainer
trainer = Trainer(problem_type="classification")
# Preparing train and validation split
x_train, y_train, x_val, y_val = train_validation_split(x=x, y=y)
# Training AutoML and saving the best model
trainer.single_model_trainer(x_train=x_train, y_train=y_train,
x_val=x_val, y_val=y_val,
metric_list=["accuracy_score"], save_model=True)
print(f"Classification test completed successfully...\n")
def regression_test():
print(f"Testing through Regression AutoML ...")
# Loading the dataset
dataset = Wine()
# X feature set and target feature split
x, y = dataset.prepare_x_and_y()
# Defining processor
processor = PreProcessing(x=x, y=y)
# Executing processor
processor.run()
# Saving processed data
processor.save_data()
# Defining feature engineer
feature_engineer = FeatureEngineering(x=x, y=y)
# Executing feature engineer
feature_engineer.run()
# Saving engineered data
feature_engineer.save_data()
# Defining model trainer
trainer = Trainer(problem_type="regression")
# Preparing train and validation split
x_train, y_train, x_val, y_val = train_validation_split(x=x, y=y)
# Training AutoML and saving the best model
trainer.single_model_trainer(x_train=x_train, y_train=y_train,
x_val=x_val, y_val=y_val,
metric_list=["mse", "msle"], result_monitor="mse", save_model=True)
print(f"Regression test completed successfully...\n")
def test():
# Testing classification
classification_test()
# Testing Regression
regression_test()
if __name__ == "__main__":
test()