scikit-learn/scikit-learn — pull request #1842 by jnothman (2013-04-07 00:44:15+00:00)
Title: ENH method to index ParameterGrid points by parameter values

This extension intends to solve #1020 for regular grids: it provides an index into the grid points output by `ParameterGrid`, such that results from `GridSearchCV` (particularly when returned as an array as in #1787) can be accessed by parameter value.

For example, I could get the mean `test_score` for each `'max_depth'` value:

```python
grid_search = GridSearchCV(clf, {'max_depth': range(1, 5), 'max_features': range(1, 3)})
grid_search.fit(...)
grid = ParameterGrid(grid_search.param_grid) # should we make it easier to get the ParameterGrid?
keys, index = grid.build_index(['max_depth'], ravel=True)
indexed = grid_search.grid_results_[index]
print(indexed['test_score'].mean(axis=1))
```

This PR aims to account for most of the functionality of #1034 within the current parameter search framework. The examples from there should be adopted.