Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occured when calling estim.fit() in demo #72

Open
wang123150629 opened this issue Mar 26, 2017 · 1 comment
Open

Error occured when calling estim.fit() in demo #72

wang123150629 opened this issue Mar 26, 2017 · 1 comment

Comments

@wang123150629
Copy link

Hello,

I got the error below when running the second example copied from http://hyperopt.github.io/hyperopt-sklearn/.

D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "", line 1, in
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\forking.py", line 380, in main
prepare(preparation_data)
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\forking.py", line 509, in prepare
'parents_main', file, path_name, etc
File "E:\Hyperopt-sklearn\hysklearn_examples\sparse_classifier.py", line 20, in
estim.fit( X_train, y_train )
File "d:\programdata\hyperopt-hyperopt-sklearn-4cbcc64\hpsklearn\estimator.py", line 708, in fit
fit_iter.send(increment)
File "d:\programdata\hyperopt-hyperopt-sklearn-4cbcc64\hpsklearn\estimator.py", line 619, in fit_iter
return_argmin=False, # -- in case no success so far
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 307, in fmin
return_argmin=return_argmin,
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\base.py", line 635, in fmin
return_argmin=return_argmin)
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 320, in fmin
rval.exhaust()
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 199, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.async)
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 173, in run
self.serial_evaluate()
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 92, in serial_evaluate
result = self.domain.evaluate(spec, ctrl)
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\base.py", line 840, in evaluate
rval = self.fn(pyll_rval)
File "d:\programdata\hyperopt-hyperopt-sklearn-4cbcc64\hpsklearn\estimator.py", line 567, in fn_with_timeout
th.start()
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\process.py", line 130, in start
self._popen = Popen(self)
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\forking.py", line 258, in init
cmd = get_command_line() + [rhandle]
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\forking.py", line 358, in get_command_line
is not going to be frozen to produce a Windows executable.''')
RuntimeError:
Attempt to start a new process before the current process
has finished its bootstrapping phase.

        This probably means that you are on Windows 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 a Windows executable.

D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
Traceback (most recent call last):
File "E:\Hyperopt-sklearn\hysklearn_examples\sparse_classifier.py", line 20, in
estim.fit( X_train, y_train )
File "d:\programdata\hyperopt-hyperopt-sklearn-4cbcc64\hpsklearn\estimator.py", line 708, in fit
fit_iter.send(increment)
File "d:\programdata\hyperopt-hyperopt-sklearn-4cbcc64\hpsklearn\estimator.py", line 619, in fit_iter
return_argmin=False, # -- in case no success so far
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 307, in fmin
return_argmin=return_argmin,
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\base.py", line 635, in fmin
return_argmin=return_argmin)
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 320, in fmin
rval.exhaust()
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 199, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.async)
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 173, in run
self.serial_evaluate()
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\fmin.py", line 92, in serial_evaluate
result = self.domain.evaluate(spec, ctrl)
File "D:\ProgramData\Anaconda3\envs\py27\lib\site-packages\hyperopt\base.py", line 840, in evaluate
rval = self.fn(pyll_rval)
File "d:\programdata\hyperopt-hyperopt-sklearn-4cbcc64\hpsklearn\estimator.py", line 567, in fn_with_timeout
th.start()
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\process.py", line 130, in start
self._popen = Popen(self)
File "D:\ProgramData\Anaconda3\envs\py27\lib\multiprocessing\forking.py", line 280, in init
to_child.close()
IOError: [Errno 22] Invalid argument

I have tried other demos such as iris and MNIST, and encourtered the same error too. What's the problem?

@bjkomer
Copy link
Member

bjkomer commented Mar 27, 2017

This seems to be an issue with Windows and multiprocessing. I've found a solution on stack overflow that looks promising. Try wrapping your code in a if __name__ == '__main__': block. So something like this:

if __name__ == '__main__':
    estim = HyperoptEstimator()
    estim.fit(X,y)
    #...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants