English 中文(简体)
在Jupyter Notebook的模范建筑
原标题:Stuck in model building on Jupyter Notebook

我正试图安装一个任意的森林树模型,但我却继续把一种错误推为一种错误,即我CV的探测器被叫作空,而情况并非如此。

下面是密码和错误。

%%time
rf_val.fit(X_train, y_train)

Fitting 0 folds for each of 32 candidates, totalling 0 fits
[Parallel(n_jobs=-1)]: Using backend LokyBackend with 2 concurrent workers.
[Parallel(n_jobs=-1)]: Done   0 out of   0 | elapsed:    0.0s finished
ValueError                                Traceback (most recent call last)
<timed eval> in <module>

/opt/conda/lib/python3.7/site-packages/sklearn/model_selection/_search.py in fit(self, X, y, groups, **fit_params)
    708                 return results
    709 
--> 710             self._run_search(evaluate_candidates)
    711 
    712         # For multi-metric evaluation, store the best_index_, best_params_ and

/opt/conda/lib/python3.7/site-packages/sklearn/model_selection/_search.py in _run_search(self, evaluate_candidates)
   1149     def _run_search(self, evaluate_candidates):
   1150         """Search all candidates in param_grid"""
-> 1151         evaluate_candidates(ParameterGrid(self.param_grid))
   1152 
   1153 

/opt/conda/lib/python3.7/site-packages/sklearn/model_selection/_search.py in evaluate_candidates(candidate_params)
    690 
    691                 if len(out) < 1:
--> 692                     raise ValueError( No fits were performed.  
    693                                       Was the CV iterator empty?  
    694                                       Were there no candidates? )

ValueError: No fits were performed. Was the CV iterator empty? Were there no candidates?

我正试图调整和适应随机的森林模式,并期望它能够及时完成,但我遇到了这一错误,我可以 which。

问题回答

在原有的舱面代码中,fit功能:

def evaluate_candidates(candidate_params):
    candidate_params = list(candidate_params)
    n_candidates = len(candidate_params)

    if self.verbose > 0:
        print("Fitting {0} folds for each of {1} candidates,"
              " totalling {2} fits".format(
                  n_splits, n_candidates, n_candidates * n_splits))

    out = parallel(delayed(_fit_and_score)(clone(base_estimator),
                                           X, y,
                                           train=train, test=test,
                                           parameters=parameters,
                                           **fit_and_score_kwargs)
                   for parameters, (train, test)
                   in product(candidate_params,
                              cv.split(X, y, groups)))

    if len(out) < 1:
        raise ValueError( No fits were performed.  
                          Was the CV iterator empty?  
                          Were there no candidates? )

在你的错误信息中:

Fitting 0 folds for each of 32 candidates, totalling 0 fits

这意味着n_split = 0

<代码>n_split

 n_splits = cv.get_n_splits(X, y, groups)

您的<代码>group为None,因此该错误可能产生于您的投入数据X





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签