# Path: automlk/metrics.py
# class Metric(object):
#     def __init__(self, name, function, problem_type, best_is_min, need_class=False, binary=False, average=False):
# def rmse(y_act, y_pred):
# def rmsle(y_act, y_pred):
# def gini(y_act, y_pred):
# def gini_normalized(y_act, y_pred):
# def evaluate_metric(y_act, y_pred, metric_name, n_classes):
# 
# Path: automlk/dataset.py
# def get_dataset_list(include_results=False):
#     """
#     get the list of all datasets
# 
#     :param include_results: flag to determine if the status are also retrieved (default = False)
#     :return: list of datasets objects or empty list if error (eg. redis or environment not set)
#     """
#     # try:
#     return [get_dataset(dataset_id, include_results) for dataset_id in get_dataset_ids()]
#     # except:
#     #    return []


from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, BooleanField, SelectField, IntegerField, FileField, SelectMultipleField
from wtforms.validators import DataRequired
from automlk.metrics import metric_list
from automlk.dataset import get_dataset_list

    filename_train = StringField()
    file_train = FileField()

    filename_test = StringField()
    file_test = FileField()

    filename_submit = StringField()
    file_submit = FileField()

    def set_choices(self, choices):
        self.folder.choices = [(f['id'], f['name']) for f in choices]


class UpdateDatasetForm(FlaskForm):
    # this is the form to update specific fields of a dataset
    name = StringField(validators=[DataRequired()])
    folder = SelectField('folder', coerce=int)
    description = TextAreaField()
    source = StringField()
    url = StringField()

    def set_choices(self, choices):
        self.folder.choices = [(f['id'], f['name']) for f in choices]


class StartDatasetForm(FlaskForm):
    # this is the form to start the search on a dataset
    problem_type = SelectField(choices=[('classification', 'classification'), ('regression', 'regression')])
    regression_metric = SelectField(choices=[])

# Path: automlk/metrics.py
# class Metric(object):
#     def __init__(self, name, function, problem_type, best_is_min, need_class=False, binary=False, average=False):
# def rmse(y_act, y_pred):
# def rmsle(y_act, y_pred):
# def gini(y_act, y_pred):
# def gini_normalized(y_act, y_pred):
# def evaluate_metric(y_act, y_pred, metric_name, n_classes):
# 
# Path: automlk/dataset.py
# def get_dataset_list(include_results=False):
#     """
#     get the list of all datasets
# 
#     :param include_results: flag to determine if the status are also retrieved (default = False)
#     :return: list of datasets objects or empty list if error (eg. redis or environment not set)
#     """
#     # try:
#     return [get_dataset(dataset_id, include_results) for dataset_id in get_dataset_ids()]
#     # except:
#     #    return []


# Path: web/app/form.py
from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, BooleanField, SelectField, IntegerField, FileField, SelectMultipleField
from wtforms.validators import DataRequired
from automlk.metrics import metric_list
from automlk.dataset import get_dataset_list


    filename_train = StringField()
    file_train = FileField()

    filename_test = StringField()
    file_test = FileField()

    filename_submit = StringField()
    file_submit = FileField()

    def set_choices(self, choices):
        self.folder.choices = [(f['id'], f['name']) for f in choices]


class UpdateDatasetForm(FlaskForm):
    # this is the form to update specific fields of a dataset
    name = StringField(validators=[DataRequired()])
    folder = SelectField('folder', coerce=int)
    description = TextAreaField()
    source = StringField()
    url = StringField()

    def set_choices(self, choices):
        self.folder.choices = [(f['id'], f['name']) for f in choices]


class StartDatasetForm(FlaskForm):
    # this is the form to start the search on a dataset
    problem_type = SelectField(choices=[('classification', 'classification'), ('regression', 'regression')])
    regression_metric = SelectField(choices=[])

    regression_other_metrics = SelectMultipleField(choices=[(m.name, m.name) for m in metric_list if m.problem_type == 'regression'])