28793deaf98b37ef5d9425c1ec975a11b397e465,dask_ml/model_selection/_incremental.py,BaseIncrementalSearchCV,_get_best,#BaseIncrementalSearchCV#Any#Any#,505

Before Change


        Select the best estimator from the set of estimators.
        best_model_id = first(results.info)
        key = operator.itemgetter("model_id")
        best_index = -1
        // history_results is sorted by (model_id, partial_fit_calls)
        // best is the model_id with the highest partial fit calls
        for k, v in itertools.groupby(history_results, key=key):
            v = list(v)
            best_index += len(v)
            if k == best_model_id:
                break

        return results.models[best_model_id], best_index

    def _process_results(self, results):
        Called with the output of `fit` immediately after it finishes.

After Change


        return cv_results

    def _get_best(self, results, cv_results):
        scores = {
            k: v[-1]["score"] for k, v in results.info.items() if k in results.models
        }

        // Could use max(scores, key=score.get), but what if score is repeated?
        // Happens in the test case a lot
        model_ids = list(scores.keys())
        scores = [scores[k] for k in model_ids]
        model_idx = np.argmax(scores)
        best_model_id = model_ids[model_idx]

        best_est = results.models[best_model_id]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: dask/dask-ml
Commit Name: 28793deaf98b37ef5d9425c1ec975a11b397e465
Time: 2018-10-13
Author: github@stsievert.com
File Name: dask_ml/model_selection/_incremental.py
Class Name: BaseIncrementalSearchCV
Method Name: _get_best


Project Name: spectralpython/spectral
Commit Name: 0817e41d3d104da9a8e4ffb84d12fd72e5687434
Time: 2017-03-26
Author: thomas.boggs@gmail.com
File Name: spectral/graphics/spypylab.py
Class Name:
Method Name: plot


Project Name: NervanaSystems/nlp-architect
Commit Name: 11187c1fd28a0c9a11836aa8b27cc21e47b6855f
Time: 2018-11-11
Author: peteriz@users.noreply.github.com
File Name: nlp_architect/api/intent_extraction_api.py
Class Name: IntentExtractionApi
Method Name: display_results


Project Name: dask/dask-ml
Commit Name: 28793deaf98b37ef5d9425c1ec975a11b397e465
Time: 2018-10-13
Author: github@stsievert.com
File Name: dask_ml/model_selection/_incremental.py
Class Name: BaseIncrementalSearchCV
Method Name: _get_best