You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wish to report runtime errors when running a script from your github page at https://github.com/hyperopt/hyperopt-sklearn under the subheading "Complete example using the Iris dataset:".
In summary:
the program works if I hand-type the script. NO PROBLEMS
the program also works if I use importlib. NO PROBLEMS
the program throws runtime errors when I run the myfile.py from the command window running python. RUNTIME ERRORS.
The program is from the github page with subheading "Complete example using the Iris dataset":
from hpsklearn import HyperoptEstimator, any_classifier, any_preprocessing
from sklearn.datasets import load_iris
from hyperopt import tpe
import numpy as np
# Download the data and split into training and test sets
iris = load_iris()
X = iris.data
y = iris.target
test_size = int(0.2 * len(y))
np.random.seed(13)
indices = np.random.permutation(len(X))
X_train = X[indices[:-test_size]]
y_train = y[indices[:-test_size]]
X_test = X[indices[-test_size:]]
y_test = y[indices[-test_size:]]
# Instantiate a HyperoptEstimator with the search space and number of evaluations
estim = HyperoptEstimator(classifier=any_classifier('my_clf'),
preprocessing=any_preprocessing('my_pre'),
algo=tpe.suggest,
max_evals=100,
trial_timeout=120)
# Search the hyperparameter space based on the data
estim.fit(X_train, y_train)
# Show the results
print(estim.score(X_test, y_test))
# 1.0
print( estim.best_model() )
If I handtype/copy-and-paste the above code OR
If I run the file myfile.py by
BUT when I run myfile.py in a command window, eg MS Win 7 dos terminal I get the following
c:\Python38>python myfile.py
WARN: OMP_NUM_THREADS=None =>
... If you are using openblas if you are using openblas set OMP_NUM_THREADS=1 or
risk subprocess calls hanging indefinitely
0%| | 0/1 [00:00
... If you are using openblas if you are using openblas set OMP_NUM_THREADS=1 or
risk subprocess calls hanging indefinitely
0%| | 0/1 [00:00", line 1, in
File "c:\python38\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "c:\python38\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "c:\python38\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "c:\python38\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from
_path
main_content = runpy.run_path(main_path,
File "c:\python38\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "c:\python38\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "c:\Python38\myfile.py", line 31, in
estim.fit(X_train, y_train)
File "c:\python38\lib\site-packages\hpsklearn\estimator.py", line 787, in fit
fit_iter.send(increment)
File "c:\python38\lib\site-packages\hpsklearn\estimator.py", line 688, in fit_
iter
hyperopt.fmin(fn_with_timeout,
File "c:\python38\lib\site-packages\hyperopt\fmin.py", line 469, in fmin
return trials.fmin(
File "c:\python38\lib\site-packages\hyperopt\base.py", line 671, in fmin
return fmin(
File "c:\python38\lib\site-packages\hyperopt\fmin.py", line 509, in fmin
rval.exhaust()
File "c:\python38\lib\site-packages\hyperopt\fmin.py", line 330, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.asynchronous)
File "c:\python38\lib\site-packages\hyperopt\fmin.py", line 286, in run
self.serial_evaluate()
File "c:\python38\lib\site-packages\hyperopt\fmin.py", line 165, in serial_eva
luate
result = self.domain.evaluate(spec, ctrl)
File "c:\python38\lib\site-packages\hyperopt\base.py", line 894, in evaluate
rval = self.fn(pyll_rval)
File "c:\python38\lib\site-packages\hpsklearn\estimator.py", line 645, in fn_w
ith_timeout
th.start()
File "c:\python38\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "c:\python38\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "c:\python38\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "c:\python38\lib\multiprocessing\popen_spawn_win32.py", line 45, in __ini
t__
prep_data = spawn.get_preparation_data(process_obj._name)
File "c:\python38\lib\multiprocessing\spawn.py", line 154, in get_preparation_
data
_check_not_importing_main()
File "c:\python38\lib\multiprocessing\spawn.py", line 134, in _check_not_impor
ting_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
In sum:
Program works as expected when either hand-writing/copy-and-paste code OR using within IDLE importlib.import_module('myfile.py').
BUT does there is runtime error when running the script as python myfile.py
Info:
python: 3.8.5
OS: MS Win 7
Thank you,
Anthony of Sydney
The text was updated successfully, but these errors were encountered:
I wish to report runtime errors when running a script from your github page at https://github.com/hyperopt/hyperopt-sklearn under the subheading "Complete example using the Iris dataset:".
In summary:
The program is from the github page with subheading "Complete example using the Iris dataset":
If I handtype/copy-and-paste the above code OR
If I run the file myfile.py by
It works as excepted- excerpt from IDLE output.
BUT when I run myfile.py in a command window, eg MS Win 7 dos terminal I get the following
In sum:
Info:
python: 3.8.5
OS: MS Win 7
Thank you,
Anthony of Sydney
The text was updated successfully, but these errors were encountered: