Skip to content
Snippets Groups Projects
Commit a86dff87 authored by Charly Lamothe's avatar Charly Lamothe
Browse files

- Add missing LOG_PATH in two init files;

- Move bolsonaro imports on top of the file in compute_hyperparam file;
- Move change_binary_func_load to utils file.
parent 94d1388e
No related branches found
No related tags found
1 merge request!3clean scripts
import os
LOG_PATH = os.path.abspath(os.path.dirname(__file__) + os.sep + '..' + os.sep + '..' + os.sep + 'log')
from bolsonaro.data.dataset import Dataset
from bolsonaro.data.task import Task
from bolsonaro.utils import change_binary_func_load
from sklearn.datasets import load_boston, load_iris, load_diabetes, \
load_digits, load_linnerud, load_wine, load_breast_cancer
......@@ -9,17 +10,6 @@ from sklearn.datasets import fetch_olivetti_faces, fetch_20newsgroups, \
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
from bolsonaro.utils import binarize_class_data
def change_binary_func_load(base_load_function):
def func_load(return_X_y):
X, y = base_load_function(return_X_y=return_X_y)
possible_classes = sorted(set(y))
assert len(possible_classes) == 2, "Function change binary_func_load only work for binary classfication"
y = binarize_class_data(y, possible_classes[-1])
return X, y
return func_load
class DatasetLoader(object):
......
import os
LOG_PATH = os.path.abspath(os.path.dirname(__file__) + os.sep + '..' + os.sep + '..' + os.sep + 'log')
......@@ -63,4 +63,13 @@ def binarize_class_data(data, class_pos, inplace=True):
data[~(position_class_labels)] = -1
data[(position_class_labels)] = +1
return data
\ No newline at end of file
return data
def change_binary_func_load(base_load_function):
def func_load(return_X_y):
X, y = base_load_function(return_X_y=return_X_y)
possible_classes = sorted(set(y))
assert len(possible_classes) == 2, "Function change binary_func_load only work for binary classfication"
y = binarize_class_data(y, possible_classes[-1])
return X, y
return func_load
from bolsonaro import LOG_PATH
from bolsonaro.data.dataset_loader import DatasetLoader
from bolsonaro.data.dataset_parameters import DatasetParameters
from bolsonaro.data.task import Task
from bolsonaro.error_handling.logger_factory import LoggerFactory
from bolsonaro.hyperparameter_searcher import HyperparameterSearcher
from bolsonaro.utils import save_obj_to_json
import argparse
import os
import pathlib
import pickle
import random
from dotenv import find_dotenv, load_dotenv
"""
......@@ -13,14 +20,6 @@ the issue described here https://github.com/scikit-optimize/scikit-optimize/issu
"""
from skopt.space import Categorical, Integer, Real
from bolsonaro import LOG_PATH
from bolsonaro.data.dataset_loader import DatasetLoader
from bolsonaro.data.dataset_parameters import DatasetParameters
from bolsonaro.data.task import Task
from bolsonaro.error_handling.logger_factory import LoggerFactory
from bolsonaro.hyperparameter_searcher import HyperparameterSearcher
from bolsonaro.utils import save_obj_to_json
def clean_numpy_int_dict(dictionary):
return dict([a, int(x)] if type(x) == Integer else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment