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

[doc] Add auto-generated docs #279

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Here’s what tune-sklearn has to offer:
* **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)].
* **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.

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).
Check out our [API Documentation](docs) and [Walkthrough](https://docs.ray.io/en/master/tune/examples/tune-sklearn.html) (for `master` branch).

## Installation

### Dependencies
- numpy (>=1.16)
- [ray](http://docs.ray.io/)
- [ray](http://docs.ray.io/) (>=2.7.0)
- scikit-learn (>=0.23)

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

## Examples

#### TuneGridSearchCV
#### [TuneGridSearchCV](docs/tune_gridsearch.md)
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!

`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).
`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).

```python
# from sklearn.model_selection import GridSearchCV
Expand Down Expand Up @@ -110,11 +110,11 @@ accuracy = np.count_nonzero(np.array(pred) == np.array(y_test)) / len(pred)
print("Sklearn Accuracy:", accuracy)
```

#### TuneSearchCV
#### [TuneSearchCV](docs/tune_search.md)

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

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:
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:

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

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

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).
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).

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`.

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

## [Documentation](docs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this expected to have a link to the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a working link to the docs overview page


See the auto-generated docs [here](docs).

These are generated by `lazydocs` and should be updated on every release:

```bash
pip install lazydocs
lazydocs /path/to/tune-sklearn/tune-sklearn --src-base-url="https://github.com/ray-project/tune-sklearn/blob/master" --overview-file="README.md"
```

## More information
[Ray Tune](https://docs.ray.io/en/latest/tune/index.html)
4 changes: 4 additions & 0 deletions docs/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
title: API Reference
nav:
- Overview: README.md
- ...
37 changes: 37 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- markdownlint-disable -->

# API Overview

## Modules

- [`list_searcher`](./list_searcher.md#module-list_searcher): Helper class to support passing a
- [`tune_basesearch`](./tune_basesearch.md#module-tune_basesearch): Parent class for a cross-validation interface
- [`tune_gridsearch`](./tune_gridsearch.md#module-tune_gridsearch): Class for doing grid search over lists of hyperparameters
- [`tune_search`](./tune_search.md#module-tune_search): Class for cross-validation over distributions of hyperparameters
- [`utils`](./utils.md#module-utils)

## Classes

- [`list_searcher.ListSearcher`](./list_searcher.md#class-listsearcher): Custom search algorithm to support passing in a list of
- [`list_searcher.RandomListSearcher`](./list_searcher.md#class-randomlistsearcher): Custom search algorithm to support passing in a list of
- [`tune_basesearch.TuneBaseSearchCV`](./tune_basesearch.md#class-tunebasesearchcv): Abstract base class for TuneGridSearchCV and TuneSearchCV
- [`tune_gridsearch.TuneGridSearchCV`](./tune_gridsearch.md#class-tunegridsearchcv): Exhaustive search over specified parameter values for an estimator.
- [`tune_search.TuneSearchCV`](./tune_search.md#class-tunesearchcv): Generic, non-grid search on hyper parameters.
- [`utils.EarlyStopping`](./utils.md#class-earlystopping): An enumeration.

## Functions

- [`tune_basesearch.resolve_early_stopping`](./tune_basesearch.md#function-resolve_early_stopping)
- [`utils.check_error_warm_start`](./utils.md#function-check_error_warm_start)
- [`utils.check_is_pipeline`](./utils.md#function-check_is_pipeline)
- [`utils.check_partial_fit`](./utils.md#function-check_partial_fit)
- [`utils.check_warm_start_ensemble`](./utils.md#function-check_warm_start_ensemble)
- [`utils.check_warm_start_iter`](./utils.md#function-check_warm_start_iter)
- [`utils.get_early_stop_type`](./utils.md#function-get_early_stop_type)
- [`utils.is_tune_grid_search`](./utils.md#function-is_tune_grid_search): Checks if obj is a dictionary returned by tune.grid_search.
- [`utils.resolve_logger_callbacks`](./utils.md#function-resolve_logger_callbacks)


---

_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
141 changes: 141 additions & 0 deletions docs/list_searcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<!-- markdownlint-disable -->

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

# <kbd>module</kbd> `list_searcher`
Helper class to support passing a list of dictionaries for hyperparameters
-- Anthony Yu and Michael Chau



---

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

## <kbd>class</kbd> `ListSearcher`
Custom search algorithm to support passing in a list of dictionaries to TuneGridSearchCV

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

### <kbd>method</kbd> `__init__`

```python
__init__(param_grid)
```






---

#### <kbd>property</kbd> metric

The training result objective value attribute.

---

#### <kbd>property</kbd> mode

Specifies if minimizing or maximizing the metric.



---

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

### <kbd>method</kbd> `on_trial_complete`

```python
on_trial_complete(**kwargs)
```





---

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

### <kbd>method</kbd> `suggest`

```python
suggest(trial_id)
```






---

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

## <kbd>class</kbd> `RandomListSearcher`
Custom search algorithm to support passing in a list of dictionaries to TuneSearchCV for randomized search

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

### <kbd>method</kbd> `__init__`

```python
__init__(param_grid)
```






---

#### <kbd>property</kbd> metric

The training result objective value attribute.

---

#### <kbd>property</kbd> mode

Specifies if minimizing or maximizing the metric.



---

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

### <kbd>method</kbd> `on_trial_complete`

```python
on_trial_complete(**kwargs)
```





---

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

### <kbd>method</kbd> `suggest`

```python
suggest(trial_id)
```








---

_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
Loading
Loading