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

Before Change


        // type: (Dict, Dict) -> Estimator
        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



        // 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]

        idx = cv_results["model_id"] == best_model_id
        assert idx.sum() == 1
        best_idx = np.argmax(idx)
        return best_idx, best_est
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 9

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: flow-project/flow
Commit Name: 9f60f957cd7be8f9c17c99b4c90d764e5898e989
Time: 2019-01-15
Author: eugenevinitsky@users.noreply.github.com
File Name: flow/multiagent_envs/multiagent_env.py
Class Name: MultiEnv
Method Name: step


Project Name: QUANTAXIS/QUANTAXIS
Commit Name: 89b43bbd55550d5c103a8b06281d9bc62e533680
Time: 2019-08-05
Author: yutiansut@qq.com
File Name: QUANTAXIS/QAData/data_resample.py
Class Name:
Method Name: QA_data_min_resample


Project Name: tensorflow/transform
Commit Name: 50aed730f4225f32e3a59407a4cb2552cbd08150
Time: 2021-02-16
Author: varshaan@google.com
File Name: tensorflow_transform/saved/saved_transform_io_v2.py
Class Name: SavedModelLoader
Method Name: _apply_v2_transform_model