-
Notifications
You must be signed in to change notification settings - Fork 0
/
try2.py
36 lines (31 loc) · 1.74 KB
/
try2.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
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 22 18:38:20 2021
@author: 20210595
"""
from sklearn.datasets import load_breast_cancer, load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import log_loss, accuracy_score
from gama import GamaClassifier
from gama.search_methods.random_search import RandomSearch
from gama.search_methods.asha import AsynchronousSuccessiveHalving
# from gama.search_methods.rf9 import RandomForestTry
from gama.search_methods.pygmo_search14 import SearchPygmo
if __name__ == '__main__':
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=0)
#El tiempo que gama tiene por default son 6 minutos
####automl = GamaClassifier(max_total_time=15, store="nothing", search=SearchPygmo())
automl = GamaClassifier(max_total_time=600000, store="nothing", search=SearchPygmo()) #n_jobs=-1
#automl = GamaClassifier(max_total_time=15, store='models')
#automl = GamaClassifier(max_total_time=15, store="nothing", search=RandomSearch())
# automl = GamaClassifier(max_total_time=10, store="nothing", search=RandomForestTry()) # Hemos usado rf9
# automl = GamaClassifier(max_total_time=10, store="nothing", search=AsynchronousSuccessiveHalving())
print("Starting `fit` which will take roughly 10 seconds.")
automl.fit(X_train, y_train)
label_predictions = automl.predict(X_test)
probability_predictions = automl.predict_proba(X_test)
print('accuracy:', accuracy_score(y_test, label_predictions))
print('log loss:', log_loss(y_test, probability_predictions))
# the `score` function outputs the score on the metric optimized towards (by default, `log_loss`)
print('log_loss', automl.score(X_test, y_test))