0

I have used a couple of computers to run the same script and now have several result_files.pkl.

results1 = gp_minimize(func=fitness,
                            dimensions=dimensions,
                            acq_func='gp_hedge',
                            n_calls=11,
                            x0=default_parameters)

I will like to merge them all together to analyze all the results together. Is this possible. I tried to use a dictionary to append them:

all_results = {}
for i in range(8):
    to_add = 'results'+str(i+1)
    all_results.update(to_add) 

But receive the following error message:

--------------------------------------------------------------------------- 
ValueError                                
Traceback (most recent call last) <ipython-input-33-fb7bb81cb72b> in <module>
      3     to_add = 'results'+str(i+1)
      4     print('adding: ',to_add)
----> 5     all_results.update(to_add)

ValueError: dictionary update sequence element #0 has length 1; 2 is required

Any ideas on how to merge them?

Thanks

Wilfredo
  • 55
  • 6

1 Answers1

0

I was able to merge them by manually selecting the values that could be merged. To do this, I had to realize that the pkl file is basically a dictionary and you can get the keys and values for the files by loading them and then using file.keys() and file.values(). In my case, these pkl files were created by scikit-optimize and the dictionary looks like this:

results1.keys() #like a dictionry, lists all the keys results1.values() #like a dictionary, lists all the values results1.fun #best performance (mse) results1.func_vals #performance for each iteration (mse) results1.space #range of the hyperparameters results1.specs #parameters for the run results1.x #hyperparameters for best performance (mse) results1.x_iters #hyperparameters tested results1.models #model used for the gaussian search? results1.random_state #random seed?

I was able to loop though all the pkl files and append the 'func_vals' and 'x_iters' values. These fields were just numpy arrays. The other values are identifiers of the best performing model or the run itself. I was able then to plot and other functions as a single pkl file.

Wilfredo
  • 55
  • 6