Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法运行SVC没有错误,但它只是卡住了,有没有办法超时?_Python_Python 3.x_Hyperopt - Fatal编程技术网

Python 无法运行SVC没有错误,但它只是卡住了,有没有办法超时?

Python 无法运行SVC没有错误,但它只是卡住了,有没有办法超时?,python,python-3.x,hyperopt,Python,Python 3.x,Hyperopt,无法在合适的SVC下运行代码不知道是什么导致了问题,正在寻找适合SVC且无挂起或超时和跳过的解决方案。 如果我做更多的评估,它挂起的可能性就越大。 我必须重新启动Jupyter笔记本内核才能再次运行代码 def objective_func_svc(args): if args['model']==SVC: C = args['param']['C'] kernel = args['param']['kernel']

无法在合适的SVC下运行代码不知道是什么导致了问题,正在寻找适合SVC且无挂起或超时和跳过的解决方案。 如果我做更多的评估,它挂起的可能性就越大。 我必须重新启动Jupyter笔记本内核才能再次运行代码

    def objective_func_svc(args):


        if args['model']==SVC:
            C = args['param']['C']
            kernel = args['param']['kernel']
            clf = SVC(C=C,kernel=kernel,gamma='auto')

        clf.fit(X_train,y_train)   

        loss =1-clf.score(X_train,y_train)  
        return loss

    space_svc = hp.choice('classifier',[

            {'model': SVC,
            'param':{'C':hp.lognormal('C',0.0,1),
            'kernel':hp.choice('kernel',['poly', 'rbf', 'sigmoid'])}}])

        print('\nKernel + C choice Score') 

        best_classifier = fmin(objective_func_svc,space_svc,algo=algoused,max_evals=max_evals)

        if best_classifier.get('kernel')==0:
            kernel='poly'
        elif best_classifier.get('kernel')==1:
            kernel='rbf'
        elif best_classifier.get('kernel')==2:
            kernel='sigmoid'

        clf = SVC(C=best_classifier.get("C"),kernel=kernel,gamma='auto')

        print('\nC=',best_classifier.get("C"))
        print('kernel=',kernel)
        print('\nBest_classifier Score ')  
        clf.fit(X_train,y_train)
        y_pred=clf.predict(X_test)
        clf.score(X_test,y_test)

        a,p,n=print_confusion_matrix(y_test, y_pred)