Skip to content
Snippets Groups Projects
Commit 91aa3307 authored by Caron Olivier's avatar Caron Olivier
Browse files

small updates

parent 2ffe60fe
No related branches found
No related tags found
No related merge requests found
......@@ -209,13 +209,13 @@ def get_cli_args():
type=str
)
parser.add_argument(
'--dataset-mapper-file',
action='store',
dest='dataset_mapper_file',
default=None,
type=str
)
# parser.add_argument(
# '--dataset-mapper-file',
# action='store',
# dest='dataset_mapper_file',
# default=None,
# type=str
# )
parser.add_argument(
'--search-space',
......
......@@ -32,7 +32,7 @@ class EASpace(Sequence): # pylint: disable=too-many-public-methods
try:
self.check_ea_space()
except InvalidEASpace as e:
logging.error("EA space is not well formated: %s", e)
logging.error("EA space is not well formatted: %s", e)
raise e
def set_parameters(self, parameters):
......@@ -225,7 +225,8 @@ class EASpace(Sequence): # pylint: disable=too-many-public-methods
raise Exception(f"Unknown probability_operator_name {operator_type}")
strategy = self._operator_strategy(operator_type)
probabilities = self.parameters[probability_operator_name] if probability_operator_name in self.parameters else None
probabilities = self.parameters[probability_operator_name] if (probability_operator_name
in self.parameters) else None
len_operators = len(self._operators(operator_type))
if strategy == OPERATOR_DISTRIBUTION_STRATEGY.STATIC_DISTRIBUTION:
......
......@@ -103,7 +103,8 @@ class MaryMorstan():
ea_space.set_parameters(ea_parameters)
if (OPERATOR_DISTRIBUTION_STRATEGY.TIME_BASED_DISTRIBUTION in (ea_space.mutation_strategy,
ea_space.crossover_strategy) and wall_time_optimization_seconds is None):
ea_space.crossover_strategy)
and wall_time_optimization_seconds is None):
raise Exception('Please specify wall_time_optimization_seconds parameters '
'if you plan to base your variation strategy on the time')
......
......@@ -15,6 +15,5 @@ then
exit ${exit_code}
fi
echo ${results} | grep 0.11792351206144569 >/dev/null || exit 41
echo ${results} | grep 0.7401839889682496 >/dev/null || exit 42
......@@ -2,6 +2,7 @@
from sklearn.model_selection import train_test_split
from sklearn.model_selection._validation import _score
import numpy as np
import importlib
import logging
......@@ -11,27 +12,31 @@ from marymorstan.marymorstan import MaryMorstan
log_level = getattr(logging, 'ERROR')
logging.basicConfig(format='%(asctime)s [%(filename)s:%(lineno)d] %(levelname)s %(message)s', level=log_level)
dataset_preprocessing_module = importlib.import_module("datasets.iris_dataset_preprocessing")
dataset_preprocessing_module = importlib.import_module("datasets.iris_dataset_preprocessing") # <1>
dataset = dataset_preprocessing_module.MyDataSetPreprocessing("iris")
X_train, X_test, y_train, y_test = train_test_split(dataset.get_X(), dataset.get_y(), test_size=.25, random_state=42)
mm = MaryMorstan(generations=4, population_size=5, random_state=42)
pipelines = mm.optimize(X_train=X_train, y_train=y_train, random_state=42)
mm = MaryMorstan(generations=4, population_size=5, random_state=np.random.RandomState(42)) # <2>
pipelines = mm.optimize(X_train=X_train, y_train=y_train,
random_state=np.random.RandomState(42)) # <3>
best_pipeline = MaryMorstan.best(pipelines)
best_pipeline = MaryMorstan.best(pipelines) # <4>
# then you can save it as a string and easily reimport later
best_pipeline_str = str(best_pipeline)
print("best pipeline found:", str(best_pipeline))
print("Objectives:", str(mm.objectives))
print("resulting scores") # <5>
print(f'current validation_scores: {str(list(best_pipeline.fitness.weighted_values))}')
best_pipeline_compiled = best_pipeline.compile()
best_pipeline_compiled.fit(X_train, y_train)
score = best_pipeline_compiled.score(X_train, y_train)
print("train score 1: ", score)
train_scores = _score(best_pipeline_compiled, X_train, y_train, mm.objectives.scorers).values()
test_scores = _score(best_pipeline_compiled, X_test, y_test, mm.objectives.scorers).values()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment