# Path: automlk/config.py
# METRIC_NULL = 1e7
# 
# Path: automlk/dataset.py
# def get_dataset_ids():
# def get_dataset_list(include_results=False):
# def get_dataset_status(dataset_id):
# def get_dataset(dataset_id, include_results=False):
# def make_dataset(d):
# def create_dataset_json(dataset_id):
# def create_dataset(name, folder_id, description, source, mode, filename_train, filename_test='', filename_cols='',
#                    filename_submit='', url=''):
# def update_dataset(dataset_id, name, folder_id, description, source, url):
# def update_feature_dataset(dataset_id, name, description, to_keep, col_type, text_ref):
# def update_problem_dataset(dataset_id, problem_type, y_col, metric, other_metrics, val_col, cv_folds, val_col_shuffle,
#                            scan, holdout_ratio, col_submit):
# def reset_dataset(dataset_id):
# def delete_dataset(dataset_id):
# def get_dataset_sample(dataset_id):
#     def __init__(self, dataset_id, name, folder_id, description, source, mode, filename_train,
#                  filename_test, filename_cols, filename_submit, url, creation_date):
#     def initialize_data(self):
#     def update_stats(self, df_train, df_test, df_submit):
#     def update_calc(self):
#     def update_problem(self, problem_type, y_col, metric, other_metrics, val_col, cv_folds, val_col_shuffle, scan,
#                        holdout_ratio, col_submit, best_is_min=True):
#     def update_y_data(self):
#     def save(self, dataset_id):
#     def load(self, load_data, features):
#     def load_calc(self, calc_data):
#     def finalize_creation(self, df_train, df_test, df_submit):
#     def get_data(self, part='train'):
#     def create_folders(self):
#     def __folder(self):
#     def __check_data(self, filename, part='train'):
#     def __read_data(self, filename):
#     def __initialize_features(self, df, df_cols):
#     def update_features(self, df):
#     def __import_data(self, filename, part):
#     def __init__(self, name, raw_type, n_missing, n_unique_values, first_unique_values, description, to_keep,
#                  col_type, text_ref='', n_unique_ratio=0.):
# def get_y_eval(dataset_id):
# class DataSet(object):
# class Feature(object):


from abc import ABCMeta, abstractmethod
from .spaces.model import *
from .config import METRIC_NULL
from .dataset import get_dataset_folder
    from catboost import Pool, CatBoostClassifier, CatBoostRegressor
    from .utils.keras_wrapper import keras_create_model, keras_compile_model, import_keras, to_categorical
import pickle
import logging
import numpy as np
import pandas as pd
        self.num_rounds = self.model.tree_count_

        self.params['iterations'] = self.num_rounds
        self.params.pop('od_type')
        self.params.pop('od_wait')



class ModelNN(Model):
    # class for model Neural Networks

    def __init__(self, **params):
        super().__init__(**params)
        self.early_stopping = True
        self.model_created = False

    def fit(self, X_train, y_train):
        # train with num_rounds
        if not self.model_created:
            self.__create_model(len(X_train.columns))
        keras_compile_model(self.model, self.params, self.problem_type)
        self.model.fit(X_train.as_matrix(), self.prepare_y(y_train), epochs=self.num_rounds, batch_size=self.params['batch_size'],
                       validation_split=0.,
                       verbose=0)

    def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
        # find best round
        if not self.model_created:
            self.__create_model(len(X_train.columns))
        keras_compile_model(self.model, self.params, self.problem_type)

# Path: automlk/config.py
# METRIC_NULL = 1e7
# 
# Path: automlk/dataset.py
# def get_dataset_ids():
# def get_dataset_list(include_results=False):
# def get_dataset_status(dataset_id):
# def get_dataset(dataset_id, include_results=False):
# def make_dataset(d):
# def create_dataset_json(dataset_id):
# def create_dataset(name, folder_id, description, source, mode, filename_train, filename_test='', filename_cols='',
#                    filename_submit='', url=''):
# def update_dataset(dataset_id, name, folder_id, description, source, url):
# def update_feature_dataset(dataset_id, name, description, to_keep, col_type, text_ref):
# def update_problem_dataset(dataset_id, problem_type, y_col, metric, other_metrics, val_col, cv_folds, val_col_shuffle,
#                            scan, holdout_ratio, col_submit):
# def reset_dataset(dataset_id):
# def delete_dataset(dataset_id):
# def get_dataset_sample(dataset_id):
#     def __init__(self, dataset_id, name, folder_id, description, source, mode, filename_train,
#                  filename_test, filename_cols, filename_submit, url, creation_date):
#     def initialize_data(self):
#     def update_stats(self, df_train, df_test, df_submit):
#     def update_calc(self):
#     def update_problem(self, problem_type, y_col, metric, other_metrics, val_col, cv_folds, val_col_shuffle, scan,
#                        holdout_ratio, col_submit, best_is_min=True):
#     def update_y_data(self):
#     def save(self, dataset_id):
#     def load(self, load_data, features):
#     def load_calc(self, calc_data):
#     def finalize_creation(self, df_train, df_test, df_submit):
#     def get_data(self, part='train'):
#     def create_folders(self):
#     def __folder(self):
#     def __check_data(self, filename, part='train'):
#     def __read_data(self, filename):
#     def __initialize_features(self, df, df_cols):
#     def update_features(self, df):
#     def __import_data(self, filename, part):
#     def __init__(self, name, raw_type, n_missing, n_unique_values, first_unique_values, description, to_keep,
#                  col_type, text_ref='', n_unique_ratio=0.):
# def get_y_eval(dataset_id):
# class DataSet(object):
# class Feature(object):


# Path: automlk/models.py
from abc import ABCMeta, abstractmethod
from .spaces.model import *
from .config import METRIC_NULL
from .dataset import get_dataset_folder
    from catboost import Pool, CatBoostClassifier, CatBoostRegressor
    from .utils.keras_wrapper import keras_create_model, keras_compile_model, import_keras, to_categorical
import pickle
import logging
import numpy as np
import pandas as pd

        self.num_rounds = self.model.tree_count_

        self.params['iterations'] = self.num_rounds
        self.params.pop('od_type')
        self.params.pop('od_wait')



class ModelNN(Model):
    # class for model Neural Networks

    def __init__(self, **params):
        super().__init__(**params)
        self.early_stopping = True
        self.model_created = False

    def fit(self, X_train, y_train):
        # train with num_rounds
        if not self.model_created:
            self.__create_model(len(X_train.columns))
        keras_compile_model(self.model, self.params, self.problem_type)
        self.model.fit(X_train.as_matrix(), self.prepare_y(y_train), epochs=self.num_rounds, batch_size=self.params['batch_size'],
                       validation_split=0.,
                       verbose=0)

    def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
        # find best round
        if not self.model_created:
            self.__create_model(len(X_train.columns))
        keras_compile_model(self.model, self.params, self.problem_type)

        best_score = METRIC_NULL