keras-team / autokeras

AutoML library for deep learning

Home Page:http://autokeras.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

scikit-learn.metrics import custom metric function

leeprinxin opened this issue · comments

How do I import scikit-learn.metrics into a custom metrics function to use, for example, the following example :

from sklearn.metrics import mean_tweedie_deviance

def deviance(y_true, y_pred):
    return mean_tweedie_deviance(y_true, y_pred)

clf = ak.StructuredDataRegressor(
    overwrite=True,
    max_trials=3,
    metrics=['mae',deviance],
    objective=keras_tuner.Objective('val_mae', direction='min'),
    )

clf.fit(x_train, y_train, validation_data=(x_test,y_test), epochs=10)

The example you give should work, right?
If you wang to set the deviance as the objective, just do objective=keras_tuner.Objective('val_deviance', direction='min').