nre version of the optimization_demo with the restart function
@@ -11,7 +11,7 @@ from skopt.space.space import Real
from evaluation_metrics.coherence_metrics import Coherence
#%% Load dataset
dataset = Dataset()
-dataset.load("preprocessed_datasets/M10/M10_lemmatized_0")
+dataset.load("preprocessed_datasets/m10/M10_lemmatized_0")
#%% Load model
model = LDA_Model()
@@ -33,7 +33,6 @@ search_space = {
"alpha": Real(low=0.001, high=5.0),
"eta": Real(low=0.001, high=5.0)
}
-
#%% Initialize optimizer
optimizer = Optimizer(
model,
@@ -45,11 +44,11 @@ optimizer = Optimizer(
save_path="results/simple_GP/",
save_name="resultsBO",
save_models=False,
- number_of_call=6,
+ number_of_call=10,
n_random_starts=3,
optimization_type='Maximize',
- model_runs=5,
- initial_point_generator="random", #work only for version skopt 8.0
+ model_runs=3,
+ initial_point_generator="lhs", #work only for version skopt 8.0
surrogate_model="GP")
#%% Optimize the function npmi using Bayesian Optimization
@@ -61,21 +60,8 @@ BestObject.save_to_csv("results.csv")
#%%To restart an optimization you must load the previous results
PreviousResult=BestObject.load("results/simple_GP/resultsBO.json")
-#%% Initialize again the optimizer
-optimizer = Optimizer(
- model,
- dataset,
- npmi,
- search_space,
- plot_model=True,
- plot_best_seen=True,
- save_path="results/simple_GP/",
- save_name="resultsBO2",
- save_models=False,
- number_of_call=6,
- optimization_type='Maximize',
- model_runs=2,
- surrogate_model="GP")
-
-#%%..and launch again the optimization
-BestObject2 = optimizer.restart_optimize(PreviousResult)
+#%% launch again the optimization
+number_of_call=4
+BestObject2 = optimizer.restart_optimize(PreviousResult,
+ number_of_call,
+ model)
