# 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/worker.py
# def get_search_rounds(dataset_id):
#     """
#     get all the results of the search with preprocessing and models
# 
#     :param dataset_id: id of the dataset
#     :return: results of the search as a dataframe
#     """
#     results = list_key_store('dataset:%s:rounds' % dataset_id)
#     return pd.DataFrame(results)
# 
# Path: automlk/models.py
# MAX_ROUNDS = 5000
# PATIENCE = 50
# class Model(object):
# class ModelCatboost(Model):
# class ModelNN(Model):
# class EnsemblePool(object):
# class ModelEnsembleSelection(Model):
#     def __init__(self, **params):
#     def fit(self, X_train, y_train):
#     def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
#     def predict(self, X):
#     def predict_proba(self, X):
# def binary_proba(y):
#     def __init__(self, **params):
#     def set_model(self):
#     def fit(self, X_train, y_train):
#     def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
#     def __init__(self, **params):
#     def fit(self, X_train, y_train):
#     def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
#     def __create_model(self, dim):
#     def predict_proba(self, X):
#     def prepare_y(self, y):
#     def __init__(self, pool_model_round_ids, pool_model_names, pool_eval_preds, pool_test_preds, pool_submit_preds):
#     def __init__(self, dataset, context, params):
#     def cv_pool(self, pool, y, y_test, cv_folds, threshold, depth):


import pickle
from automlk.dataset import get_dataset_list, create_graph_data
from automlk.graphs import *
from automlk.worker import get_search_rounds
from automlk.models import get_pred_eval_test

"""
module specifically designed to update feature round graphs after new version
"""

for dataset in get_dataset_list():
    print('-'*60)
    print(dataset.name)
    ds = pickle.load(open(get_dataset_folder(dataset.dataset_id) + '/data/eval_set.pkl', 'rb'))


# 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/worker.py
# def get_search_rounds(dataset_id):
#     """
#     get all the results of the search with preprocessing and models
# 
#     :param dataset_id: id of the dataset
#     :return: results of the search as a dataframe
#     """
#     results = list_key_store('dataset:%s:rounds' % dataset_id)
#     return pd.DataFrame(results)
# 
# Path: automlk/models.py
# MAX_ROUNDS = 5000
# PATIENCE = 50
# class Model(object):
# class ModelCatboost(Model):
# class ModelNN(Model):
# class EnsemblePool(object):
# class ModelEnsembleSelection(Model):
#     def __init__(self, **params):
#     def fit(self, X_train, y_train):
#     def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
#     def predict(self, X):
#     def predict_proba(self, X):
# def binary_proba(y):
#     def __init__(self, **params):
#     def set_model(self):
#     def fit(self, X_train, y_train):
#     def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
#     def __init__(self, **params):
#     def fit(self, X_train, y_train):
#     def fit_early_stopping(self, X_train, y_train, X_eval, y_eval):
#     def __create_model(self, dim):
#     def predict_proba(self, X):
#     def prepare_y(self, y):
#     def __init__(self, pool_model_round_ids, pool_model_names, pool_eval_preds, pool_test_preds, pool_submit_preds):
#     def __init__(self, dataset, context, params):
#     def cv_pool(self, pool, y, y_test, cv_folds, threshold, depth):


# Path: scripts/update_graphs_rounds.py
import pickle
from automlk.dataset import get_dataset_list, create_graph_data
from automlk.graphs import *
from automlk.worker import get_search_rounds
from automlk.models import get_pred_eval_test


"""
module specifically designed to update feature round graphs after new version
"""

for dataset in get_dataset_list():
    print('-'*60)
    print(dataset.name)
    ds = pickle.load(open(get_dataset_folder(dataset.dataset_id) + '/data/eval_set.pkl', 'rb'))


    for msg_search in get_search_rounds(dataset.dataset_id).to_dict(orient='records'):