def test__config_loader__correct_response():
    config_test_path = 'tests/resources/config.yaml'
    config = ConfigLoader()
    config.load(config_test_path)
    assert config['string_key'] == 'value'
    assert config['int_key'] == 1
    assert config['float_key'] == 1.5
    assert config['list_key'] == [1, 'value2', 3]
    assert list(config['model_parameters'].keys()) == ['C', 'penalty']
    assert config['model_parameters']['C']['uniform'] == [0.2, 1]
    assert config['model_parameters']['penalty']['choice'] == ['l1', 'l2']
    assert config.get('non_existent_key') is None
Example #2
0
from sklearn.impute import SimpleImputer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report
import mlflow
import mlflow.sklearn
from mlflow.exceptions import MlflowException

from src.logging_config import setup_logging
from src.config_loader import ConfigLoader
from src.transformers import SelectDtypeColumns, CountThresholder, CategoricalEncoder
from src.bayes_hyperopt import BayesOpt
from src.utils import persist_local_artifact

setup_logging()
CONFIG = ConfigLoader()
CONFIG.load('config/config.yaml')


class Trainer:
    """Train machine learning models and save artifacts using MLflow"""

    # TODO: Log MLflow metrics
    def __init__(self, config, seed=0):
        self._config = config
        self._seed = seed
        np.random.seed(self._seed)
        self.data = None
        self.categorical_columns = None
        self.numerical_columns = None
        self.df_train = None
        self.df_test = None
Example #3
0
def config():
    config_test_path = 'tests/resources/config.yaml'
    config = ConfigLoader()
    config.load(config_test_path)
    return config