def __init__(self, scoring_function=r2_score, joiner=NumpyConcatenateOuterBatch()): MetaStepMixin.__init__(self) BaseStep.__init__(self) self.scoring_function = scoring_function self.joiner = joiner
def __init__(self, wrapped: BaseStep, copy_op=copy.deepcopy): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) self.set_step(wrapped) self.steps: List[BaseStep] = [] self.copy_op = copy_op
def __init__(self, wrapped, epochs, fit_only=False, repeat_in_test_mode=False, cache_folder_when_no_handle=None): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder=cache_folder_when_no_handle) self.repeat_in_test_mode = repeat_in_test_mode self.fit_only = fit_only self.epochs = epochs
def __init__(self, wrapped, from_data_inputs=False, cache_folder_when_no_handle=None): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) self.from_data_inputs = from_data_inputs
def __init__(self, wrapped: BaseStep, copy_op=copy.deepcopy): # TODO: set params on wrapped. # TODO: use MetaStep*s*Mixin (plural) and review. BaseStep.__init__(self) MetaStepMixin.__init__(self) self.set_step(wrapped) self.steps: List[BaseStep] = [] self.copy_op = copy_op
def __init__(self, hyperparameter_optimizer: BaseHyperparameterOptimizer, higher_score_is_better=True, cache_folder_when_no_handle=None): BaseStep.__init__(self) MetaStepMixin.__init__(self, None) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) self.higher_score_is_better = higher_score_is_better self.hyperparameter_optimizer = hyperparameter_optimizer
def __init__( self, pipeline: Union[BaseStep, NamedTupleList], validation_size: int = None, batch_size: int = None, batch_metrics: Dict[str, Callable] = None, shuffle_in_each_epoch_at_train: bool = True, seed: int = None, n_epochs: int = 1, epochs_metrics: Dict[str, Callable] = None, scoring_function: Callable = None, cache_folder: str = None, print_epoch_metrics=False, print_batch_metrics=False ): """ :param pipeline: pipeline to wrap with an epoch repeater, a validation split wrapper, and a mini batch sequential pipeline :param validation_size: ratio for validation size between 0 and 1 :param batch_size: batch size for the mini batch sequential pipeline :param batch_metrics: metrics to calculate for each processed mini batch :param shuffle_in_each_epoch_at_train: :param seed: random seed for the data shuffling that can be done at each epoch when the param shuffle_in_each_epoch_at_train is True :param n_epochs: number of epochs :param epochs_metrics: metrics to calculate for each epoch :param scoring_function: scoring function with two arguments (y_true, y_pred) :param cache_folder: cache folder to be used inside the pipeline :param print_epoch_metrics: whether or not to print epoch metrics :param print_batch_metrics: whether or not to print batch metrics """ if epochs_metrics is None: epochs_metrics = {} if batch_metrics is None: batch_metrics = {} self.final_scoring_metric = scoring_function self.epochs_metrics = epochs_metrics self.n_epochs = n_epochs self.shuffle_in_each_epoch_at_train = shuffle_in_each_epoch_at_train self.batch_size = batch_size self.batch_metrics = batch_metrics self.validation_size = validation_size self.print_batch_metrics = print_batch_metrics self.print_epoch_metrics = print_epoch_metrics wrapped = pipeline wrapped = self._create_mini_batch_pipeline(wrapped) if shuffle_in_each_epoch_at_train: wrapped = TrainShuffled(wrapped=wrapped, seed=seed) wrapped = self._create_validation_split(wrapped) wrapped = self._create_epoch_repeater(wrapped) BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) EvaluableStepMixin.__init__(self) ForceHandleMixin.__init__(self, cache_folder)
def __init__(self, columns_selection, n_dimension=3): BaseStep.__init__(self) col_selector = ColumnSelector2D(columns_selection=columns_selection) for _ in range(min(0, n_dimension - 2)): col_selector = ForEachDataInput(col_selector) MetaStepMixin.__init__(self, col_selector) self.n_dimension = n_dimension
def __init__(self, wrapped): """ Wrap a scikit-learn MetaEstimatorMixin for usage in Neuraxle. This class is similar to the SKLearnWrapper class of Neuraxle that can wrap a scikit-learn BaseEstimator. :param wrapped: a scikit-learn object of type "MetaEstimatorMixin". """ MetaStepMixin.__init__(self) BaseStep.__init__(self) self.wrapped_sklearn_metaestimator = wrapped # TODO: use self.set_step of the MetaStepMixin instead?
def __init__(self, wrapped: BaseStep, then_unflatten: bool = True): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ResumableStepMixin.__init__(self) ForceHandleMixin.__init__(self) self.then_unflatten = then_unflatten self.len_di = [] self.len_eo = []
def __init__(self, wrapped, epochs, fit_only=False, repeat_in_test_mode=False): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) self.repeat_in_test_mode = repeat_in_test_mode self.fit_only = fit_only self.epochs = epochs
def __init__(self, wrapped: BaseStep, is_train_only=True, cache_folder_when_no_handle=None): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder=cache_folder_when_no_handle) self.is_train_only = is_train_only
def __init__(self, wrapped=None, scoring_function: Callable = r2_score): """ Base class For validation wrappers. It has a scoring function to calculate the score for the validation split. :param scoring_function: scoring function with two arguments (y_true, y_pred) :type scoring_function: Callable """ BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) self.scoring_function = scoring_function
def __init__(self, wrapped: BaseStep, copy_op=copy.deepcopy, cache_folder_when_no_handle=None): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) self.set_step(wrapped) self.steps: List[BaseStep] = [] self.copy_op = copy_op
def __init__(self, wrapped: BaseStep, copy_op=copy.deepcopy, cache_folder_when_no_handle=None): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) self.savers.append(TruncableJoblibStepSaver()) self.set_step(wrapped) self.steps_as_tuple: List[NamedTupleList] = [] self.copy_op = copy_op
def __init__(self, hyperparameter_optimizer: BaseHyperparameterOptimizer, validation_technique: BaseCrossValidationWrapper = None, higher_score_is_better=True): BaseStep.__init__(self) MetaStepMixin.__init__(self, None) if validation_technique is None: validation_technique = KFoldCrossValidationWrapper() self.validation_technique = validation_technique self.higher_score_is_better = higher_score_is_better self.hyperparameter_optimizer = hyperparameter_optimizer
def __init__(self, wrapped, transform_callback_function, fit_callback_function, inverse_transform_callback_function=None, more_arguments: List = tuple(), hyperparams=None): MetaStepMixin.__init__(self, wrapped) BaseStep.__init__(self, hyperparams) self.inverse_transform_callback_function = inverse_transform_callback_function self.more_arguments = more_arguments self.fit_callback_function = fit_callback_function self.transform_callback_function = transform_callback_function
def __init__(self, wrapped: BaseStep, enabled: bool = True, nullified_return_value=None): BaseStep.__init__( self, hyperparams=HyperparameterSamples({ OPTIONAL_ENABLED_HYPERPARAM: enabled }) ) MetaStepMixin.__init__(self, wrapped) ForceMustHandleMixin.__init__(self) if nullified_return_value is None: nullified_return_value = [] self.nullified_return_value = nullified_return_value
def __init__(self, wrapped: BaseStep, enabled: bool = True, nullified_return_value=None, cache_folder_when_no_handle=None): BaseStep.__init__(self, hyperparams=HyperparameterSamples( {OPTIONAL_ENABLED_HYPERPARAM: enabled})) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) if nullified_return_value is None: nullified_return_value = [] self.nullified_return_value = nullified_return_value
def __init__( self, wrapped: BaseStep, cache_folder: str = DEFAULT_CACHE_FOLDER, value_hasher: 'BaseValueHasher' = None, ): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) self.value_hasher = value_hasher if self.value_hasher is None: self.value_hasher = Md5Hasher() self.value_caching_folder = cache_folder
def __init__( self, wrapped=None, n_iter: int = 10, higher_score_is_better: bool = True, validation_technique: BaseCrossValidation = KFoldCrossValidation(), refit=True, ): if wrapped is not None: MetaStepMixin.__init__(self, wrapped) BaseStep.__init__(self) self.n_iter = n_iter self.higher_score_is_better = higher_score_is_better self.validation_technique: BaseCrossValidation = validation_technique self.refit = refit
def __init__(self, wrapped: BaseStep, metrics: Dict, name: str = None, print_metrics=False, print_fun=print): BaseStep.__init__(self, name=name) MetaStepMixin.__init__(self, wrapped) self.metrics: Dict = metrics self._initialize_metrics(metrics) self.print_metrics = print_metrics self.print_fun = print_fun self.enabled = True
def __init__(self, wrapped: BaseStep, test_size: float, scoring_function=r2_score, run_validation_split_in_test_mode=True): """ :param wrapped: wrapped step :param test_size: ratio for test size between 0 and 1 :param scoring_function: scoring function with two arguments (y_true, y_pred) """ MetaStepMixin.__init__(self, wrapped) BaseStep.__init__(self) self.run_validation_split_in_test_mode = run_validation_split_in_test_mode self.test_size = test_size self.scoring_function = scoring_function
def __init__(self, wrapped: BaseStep, auto_ml_algorithm: AutoMLAlgorithm, hyperparams_repository: HyperparamsRepository = None, n_iters: int = 100, refit=True): BaseStep.__init__(self) self.refit = refit auto_ml_algorithm = auto_ml_algorithm.set_step(wrapped) MetaStepMixin.__init__(self, auto_ml_algorithm) NonTransformableMixin.__init__(self) if hyperparams_repository is None: hyperparams_repository = InMemoryHyperparamsRepository() self.hyperparams_repository = hyperparams_repository self.n_iters = n_iters
def __init__(self, wrapped: BaseStep, enabled: bool = True, nullified_return_value=None, cache_folder_when_no_handle=None, use_hyperparameter_space=True, nullify_hyperparams=True): hyperparameter_space = HyperparameterSpace({ OPTIONAL_ENABLED_HYPERPARAM: Boolean() }) if use_hyperparameter_space else {} BaseStep.__init__( self, hyperparams=HyperparameterSamples({ OPTIONAL_ENABLED_HYPERPARAM: enabled }), hyperparams_space=hyperparameter_space ) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) if nullified_return_value is None: nullified_return_value = [] self.nullified_return_value = nullified_return_value self.nullify_hyperparams = nullify_hyperparams
def __init__(self, wrapped: BaseStep, auto_ml_algorithm: AutoMLAlgorithm, hyperparams_repository: HyperparamsRepository = None, n_iters: int = 100, refit=True, cache_folder_when_no_handle=None): if not isinstance(wrapped, EvaluableStepMixin): raise ValueError( 'AutoML algorithm needs evaluable steps that implement the function get_score. Please use a validation technique, or implement EvaluableStepMixin.' ) BaseStep.__init__(self) MetaStepMixin.__init__(self, auto_ml_algorithm.set_step(wrapped)) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) if hyperparams_repository is None: hyperparams_repository = InMemoryHyperparamsRepository() self.hyperparams_repository = hyperparams_repository self.n_iters = n_iters self.refit = refit
def __init__( self, wrapped: BaseStep, max_queue_size: int, n_workers: int, use_threading: bool, additional_worker_arguments=None, use_savers=False ): if not additional_worker_arguments: additional_worker_arguments = [[] for _ in range(n_workers)] BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ObservableQueueMixin.__init__(self, Queue(maxsize=max_queue_size)) self.use_threading: bool = use_threading self.workers: List[Process] = [] self.n_workers: int = n_workers self.observers: List[Queue] = [] self.additional_worker_arguments = additional_worker_arguments self.use_savers = use_savers
def __init__(self, wrapped: BaseStep = None, test_size: float = 0.2, scoring_function=r2_score, run_validation_split_in_test_mode=True, metrics_already_enabled=True, cache_folder_when_no_handle=None): """ :param wrapped: wrapped step :param test_size: ratio for test size between 0 and 1 :param scoring_function: scoring function with two arguments (y_true, y_pred) """ BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) ForceHandleOnlyMixin.__init__(self, cache_folder_when_no_handle) EvaluableStepMixin.__init__(self) self.run_validation_split_in_test_mode = run_validation_split_in_test_mode self.test_size = test_size self.scoring_function = scoring_function self.metrics_enabled = metrics_already_enabled
def __init__(self, wrapped: BaseStep): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped)
def __init__(self, wrapped: BaseStep, is_train_only=True): BaseStep.__init__(self) MetaStepMixin.__init__(self, wrapped) self.is_train_only = is_train_only