简体   繁体   English

OSError: [Errno 9] 使用 GridSearchCV 的文件描述符错误

[英]OSError: [Errno 9] Bad file descriptor using GridSearchCV

I'm having little hard times figure out what's the problem with my code.我很难弄清楚我的代码有什么问题。 I'm a newbie in the fabulous world of python, so forgive me for any kind of syntax problem.我是 python 神话般的世界的新手,所以请原谅我的任何语法问题。 Thanks to anyone who's gonna spend his time to help me.感谢任何愿意花时间帮助我的人。 Here's my code:这是我的代码:

X_train=np.random.randn(4000,400)

y_train=np.random.randn(4000)

parameters={
    "solver":("auto", "svd", "cholesky", "lsqr", "sparse_cg", "sag", "saga"),

    "tol":[1e-3,1e-5,1e-8],

    "alpha":[1,1.2,1.4,1.5],

    "random_state":[42]

}

reg= Ridge()

clf = GridSearchCV(reg, parameters,scoring="r2", n_jobs=-1,cv=5)

clf.fit(X_train,y_train) **here's where troubles happen**

print(clf.best_score_)

print(clf.best_params_)

And here is the error:这是错误:

File"/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 290, in _on_run

r = self.sock.recv(1024)

OSError: [Errno 9] Bad file descriptor

The problem is because of the argument n_jobs=-1 .问题是因为参数n_jobs=-1 It means, the computer can use all cores available, and certains algorithms in several scenarios it raises an error.这意味着,计算机可以使用所有可用的内核,并且在几种情况下某些算法会引发错误。

Check this sentence:检查这句话:

clf = GridSearchCV(reg, parameters, scoring="r2", cv=5)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM