Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit f309725

Browse files
authored
[doc] Add auto-generated docs (#279)
Adds auto-generated docs to make this library self-sufficient rather than relying on links in the ray docs. --------- Signed-off-by: Justin Yu <[email protected]>
1 parent 0eb3a9f commit f309725

File tree

8 files changed

+1130
-7
lines changed

8 files changed

+1130
-7
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Here’s what tune-sklearn has to offer:
1111
* **Framework support**: tune-sklearn is used primarily for tuning Scikit-Learn models, but it also supports and provides examples for many other frameworks with Scikit-Learn wrappers such as Skorch (Pytorch) [[example](https://github.com/ray-project/tune-sklearn/blob/master/examples/torch_nn.py)], KerasClassifier (Keras) [[example](https://github.com/ray-project/tune-sklearn/blob/master/examples/keras_example.py)], and XGBoostClassifier (XGBoost) [[example](https://github.com/ray-project/tune-sklearn/blob/master/examples/xgbclassifier.py)].
1212
* **Scale up**: Tune-sklearn leverages [Ray Tune](http://tune.io/), a library for distributed hyperparameter tuning, to parallelize cross validation on multiple cores and even multiple machines without changing your code.
1313

14-
Check out our [API Documentation](https://docs.ray.io/en/master/tune/api_docs/sklearn.html) and [Walkthrough](https://docs.ray.io/en/master/tune/tutorials/tune-sklearn.html) (for `master` branch).
14+
Check out our [API Documentation](docs) and [Walkthrough](https://docs.ray.io/en/master/tune/examples/tune-sklearn.html) (for `master` branch).
1515

1616
## Installation
1717

1818
### Dependencies
1919
- numpy (>=1.16)
20-
- [ray](http://docs.ray.io/)
20+
- [ray](http://docs.ray.io/) (>=2.7.0)
2121
- scikit-learn (>=0.23)
2222

2323
### User Installation
@@ -48,10 +48,10 @@ See [the Ray documentation for an overview of available stoppers](https://docs.r
4848

4949
## Examples
5050

51-
#### TuneGridSearchCV
51+
#### [TuneGridSearchCV](docs/tune_gridsearch.md)
5252
To start out, it’s as easy as changing our import statement to get Tune’s grid search cross validation interface, and the rest is almost identical!
5353

54-
`TuneGridSearchCV` accepts dictionaries in the format `{ param_name: str : distribution: list }` or a list of such dictionaries, just like scikit-learn's `GridSearchCV`. The distribution can also be the output of Ray Tune's [`tune.grid_search`](https://docs.ray.io/en/master/tune/api_docs/search_space.html#grid-search-api).
54+
`TuneGridSearchCV` accepts dictionaries in the format `{ param_name: str : distribution: list }` or a list of such dictionaries, just like scikit-learn's `GridSearchCV`. The distribution can also be the output of Ray Tune's [`tune.grid_search`](https://docs.ray.io/en/master/tune/api/search_space.html).
5555

5656
```python
5757
# from sklearn.model_selection import GridSearchCV
@@ -110,11 +110,11 @@ accuracy = np.count_nonzero(np.array(pred) == np.array(y_test)) / len(pred)
110110
print("Sklearn Accuracy:", accuracy)
111111
```
112112

113-
#### TuneSearchCV
113+
#### [TuneSearchCV](docs/tune_search.md)
114114

115115
`TuneSearchCV` is an upgraded version of scikit-learn's `RandomizedSearchCV`.
116116

117-
It also provides a wrapper for several search optimization algorithms from Ray Tune's [`tune.suggest`](https://docs.ray.io/en/master/tune/api_docs/suggestion.html), which in turn are wrappers for other libraries. The selection of the search algorithm is controlled by the `search_optimization` parameter. In order to use other algorithms, you need to install the libraries they depend on (`pip install` column). The search algorithms are as follows:
117+
It also provides a wrapper for several search optimization algorithms from Ray Tune's [searchers](https://docs.ray.io/en/master/tune/api/suggestion.html), which in turn are wrappers for other libraries. The selection of the search algorithm is controlled by the `search_optimization` parameter. In order to use other algorithms, you need to install the libraries they depend on (`pip install` column). The search algorithms are as follows:
118118

119119
| Algorithm | `search_optimization` value | Summary | Website | `pip install` |
120120
|--------------------|-----------------------------|------------------------|---------------------------------------------------------|--------------------------|
@@ -126,7 +126,7 @@ It also provides a wrapper for several search optimization algorithms from Ray T
126126

127127
All algorithms other than RandomListSearcher accept parameter distributions in the form of dictionaries in the format `{ param_name: str : distribution: tuple or list }`.
128128

129-
Tuples represent real distributions and should be two-element or three-element, in the format `(lower_bound: float, upper_bound: float, Optional: "uniform" (default) or "log-uniform")`. Lists represent categorical distributions. [Ray Tune Search Spaces](https://docs.ray.io/en/master/tune/api_docs/search_space.html) are also supported and provide a rich set of potential distributions. Search spaces allow for users to specify complex, potentially nested search spaces and parameter distributions. Furthermore, each algorithm also accepts parameters in their own specific format. More information in [Tune documentation](https://docs.ray.io/en/master/tune/api_docs/suggestion.html).
129+
Tuples represent real distributions and should be two-element or three-element, in the format `(lower_bound: float, upper_bound: float, Optional: "uniform" (default) or "log-uniform")`. Lists represent categorical distributions. [Ray Tune Search Spaces](https://docs.ray.io/en/master/tune/api/search_space.html) are also supported and provide a rich set of potential distributions. Search spaces allow for users to specify complex, potentially nested search spaces and parameter distributions. Furthermore, each algorithm also accepts parameters in their own specific format. More information in [Tune documentation](https://docs.ray.io/en/master/tune/api/suggestion.html).
130130

131131
Random Search (default) accepts dictionaries in the format `{ param_name: str : distribution: list }` or a list of such dictionaries, just like scikit-learn's `RandomizedSearchCV`.
132132

@@ -191,5 +191,16 @@ Tune-sklearn also supports the use of other machine learning libraries such as P
191191
* [Pytorch (Skorch)](https://github.com/ray-project/tune-sklearn/blob/master/examples/torch_nn.py)
192192
* [XGBoost](https://github.com/ray-project/tune-sklearn/blob/master/examples/xgbclassifier.py)
193193

194+
## [Documentation](docs)
195+
196+
See the auto-generated docs [here](docs).
197+
198+
These are generated by `lazydocs` and should be updated on every release:
199+
200+
```bash
201+
pip install lazydocs
202+
lazydocs /path/to/tune-sklearn/tune-sklearn --src-base-url="https://github.com/ray-project/tune-sklearn/blob/master" --overview-file="README.md"
203+
```
204+
194205
## More information
195206
[Ray Tune](https://docs.ray.io/en/latest/tune/index.html)

docs/.pages

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
title: API Reference
2+
nav:
3+
- Overview: README.md
4+
- ...

docs/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- markdownlint-disable -->
2+
3+
# API Overview
4+
5+
## Modules
6+
7+
- [`list_searcher`](./list_searcher.md#module-list_searcher): Helper class to support passing a
8+
- [`tune_basesearch`](./tune_basesearch.md#module-tune_basesearch): Parent class for a cross-validation interface
9+
- [`tune_gridsearch`](./tune_gridsearch.md#module-tune_gridsearch): Class for doing grid search over lists of hyperparameters
10+
- [`tune_search`](./tune_search.md#module-tune_search): Class for cross-validation over distributions of hyperparameters
11+
- [`utils`](./utils.md#module-utils)
12+
13+
## Classes
14+
15+
- [`list_searcher.ListSearcher`](./list_searcher.md#class-listsearcher): Custom search algorithm to support passing in a list of
16+
- [`list_searcher.RandomListSearcher`](./list_searcher.md#class-randomlistsearcher): Custom search algorithm to support passing in a list of
17+
- [`tune_basesearch.TuneBaseSearchCV`](./tune_basesearch.md#class-tunebasesearchcv): Abstract base class for TuneGridSearchCV and TuneSearchCV
18+
- [`tune_gridsearch.TuneGridSearchCV`](./tune_gridsearch.md#class-tunegridsearchcv): Exhaustive search over specified parameter values for an estimator.
19+
- [`tune_search.TuneSearchCV`](./tune_search.md#class-tunesearchcv): Generic, non-grid search on hyper parameters.
20+
- [`utils.EarlyStopping`](./utils.md#class-earlystopping): An enumeration.
21+
22+
## Functions
23+
24+
- [`tune_basesearch.resolve_early_stopping`](./tune_basesearch.md#function-resolve_early_stopping)
25+
- [`utils.check_error_warm_start`](./utils.md#function-check_error_warm_start)
26+
- [`utils.check_is_pipeline`](./utils.md#function-check_is_pipeline)
27+
- [`utils.check_partial_fit`](./utils.md#function-check_partial_fit)
28+
- [`utils.check_warm_start_ensemble`](./utils.md#function-check_warm_start_ensemble)
29+
- [`utils.check_warm_start_iter`](./utils.md#function-check_warm_start_iter)
30+
- [`utils.get_early_stop_type`](./utils.md#function-get_early_stop_type)
31+
- [`utils.is_tune_grid_search`](./utils.md#function-is_tune_grid_search): Checks if obj is a dictionary returned by tune.grid_search.
32+
- [`utils.resolve_logger_callbacks`](./utils.md#function-resolve_logger_callbacks)
33+
34+
35+
---
36+
37+
_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._

docs/list_searcher.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!-- markdownlint-disable -->
2+
3+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
4+
5+
# <kbd>module</kbd> `list_searcher`
6+
Helper class to support passing a list of dictionaries for hyperparameters
7+
-- Anthony Yu and Michael Chau
8+
9+
10+
11+
---
12+
13+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L11"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
14+
15+
## <kbd>class</kbd> `ListSearcher`
16+
Custom search algorithm to support passing in a list of dictionaries to TuneGridSearchCV
17+
18+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L17"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
19+
20+
### <kbd>method</kbd> `__init__`
21+
22+
```python
23+
__init__(param_grid)
24+
```
25+
26+
27+
28+
29+
30+
31+
---
32+
33+
#### <kbd>property</kbd> metric
34+
35+
The training result objective value attribute.
36+
37+
---
38+
39+
#### <kbd>property</kbd> mode
40+
41+
Specifies if minimizing or maximizing the metric.
42+
43+
44+
45+
---
46+
47+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L25"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
48+
49+
### <kbd>method</kbd> `on_trial_complete`
50+
51+
```python
52+
on_trial_complete(**kwargs)
53+
```
54+
55+
56+
57+
58+
59+
---
60+
61+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L21"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
62+
63+
### <kbd>method</kbd> `suggest`
64+
65+
```python
66+
suggest(trial_id)
67+
```
68+
69+
70+
71+
72+
73+
74+
---
75+
76+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L29"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
77+
78+
## <kbd>class</kbd> `RandomListSearcher`
79+
Custom search algorithm to support passing in a list of dictionaries to TuneSearchCV for randomized search
80+
81+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L35"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
82+
83+
### <kbd>method</kbd> `__init__`
84+
85+
```python
86+
__init__(param_grid)
87+
```
88+
89+
90+
91+
92+
93+
94+
---
95+
96+
#### <kbd>property</kbd> metric
97+
98+
The training result objective value attribute.
99+
100+
---
101+
102+
#### <kbd>property</kbd> mode
103+
104+
Specifies if minimizing or maximizing the metric.
105+
106+
107+
108+
---
109+
110+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L55"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
111+
112+
### <kbd>method</kbd> `on_trial_complete`
113+
114+
```python
115+
on_trial_complete(**kwargs)
116+
```
117+
118+
119+
120+
121+
122+
---
123+
124+
<a href="https://github.com/ray-project/tune-sklearn/blob/master/tune_sklearn/list_searcher.py#L39"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
125+
126+
### <kbd>method</kbd> `suggest`
127+
128+
```python
129+
suggest(trial_id)
130+
```
131+
132+
133+
134+
135+
136+
137+
138+
139+
---
140+
141+
_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._

0 commit comments

Comments
 (0)