Skip to content

Commit

Permalink
Adding pipeline section to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
elemets committed Nov 20, 2024
1 parent 750f24d commit be22187
Show file tree
Hide file tree
Showing 79 changed files with 366 additions and 1,216 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
_build/
develop-eggs/
dist/
downloads/
Expand Down
4 changes: 2 additions & 2 deletions docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 06037f880793e9cafa1a90e7ed27d5de
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 4d115e8219837f5e7663068621637d0a
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file modified docs/.doctrees/about.doctree
Binary file not shown.
Binary file modified docs/.doctrees/caveats.doctree
Binary file not shown.
Binary file modified docs/.doctrees/changelog.doctree
Binary file not shown.
Binary file modified docs/.doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/.doctrees/getting_started.doctree
Binary file not shown.
Binary file modified docs/.doctrees/index.doctree
Binary file not shown.
Binary file modified docs/.doctrees/references.doctree
Binary file not shown.
Binary file modified docs/.doctrees/usage_guide.doctree
Binary file not shown.
83 changes: 83 additions & 0 deletions docs/_sources/usage_guide.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,89 @@ Input Parameters
:raises KeyError: Raised when accessing dictionary keys that are not available, such as missing scores in ``self.best_params_per_score``.
:raises RuntimeError: Raised for unexpected issues during model fitting or transformations that do not fit into the other exception categories.

Pipeline Management
============================================

The pipeline in the model tuner class is designed to automatically organize steps into three categories: **preprocessing**, **feature selection**, and **imbalanced sampling**. The steps are ordered in the following sequence:

1. **Preprocessing**:
- Imputation
- Scaling
- Other preprocessing steps
2. **Imbalanced Sampling**
3. **Feature Selection**
4. **Classifier**

The ``pipeline_assembly`` method automatically sorts the steps into this order.

Specifying Pipeline Steps
-------------------------

Pipeline steps can be specified in multiple way. For example if naming a pipeline step then specify like so::

pipeline_steps = ['imputer', SimpleImputer()]

Naming each step is optional and the steps can also be specified like so::

pipeline_steps = [SimpleImputer(), StandardScalar(), rfe()]

- If no name is assigned, the step will be renamed automatically to follow the convention ``step_0``, ``step_1``, etc.
- Column transformers can also be included in the pipeline and are automatically categorized under the **preprocessing** section.

Helper Methods for Pipeline Extraction
--------------------------------------

To support advanced use cases, the model tuner provides helper methods to extract parts of the pipeline for later use. For example, when generating SHAP plots, users might only need the preprocessing section of the pipeline.

Here are some of the available methods:

.. py:function:: get_preprocessing_and_feature_selection_pipeline(pipeline)
Extracts both the preprocessing and feature selection parts of the pipeline.

**Example**::

def get_preprocessing_and_feature_selection_pipeline(self, pipeline):
steps = [
(name, transformer)
for name, transformer in pipeline.steps
if name.startswith("preprocess_") or name.startswith("feature_selection_")
]
return self.PipelineClass(steps)

.. py:function:: get_feature_selection_pipeline(pipeline)
Extracts only the feature selection part of the pipeline.

**Example**::

def get_feature_selection_pipeline(self, pipeline):
steps = [
(name, transformer)
for name, transformer in pipeline.steps
if name.startswith("feature_selection_")
]
return steps

.. py:function:: get_preprocessing_pipeline(pipeline)
Extracts only the preprocessing part of the pipeline.

**Example**::

def get_preprocessing_pipeline(self, pipeline):
preprocessing_steps = [
(name, transformer)
for name, transformer in pipeline.steps
if name.startswith("preprocess_")
]
return self.PipelineClass(preprocessing_steps)

Summary
-------

By organizing pipeline steps automatically and providing helper methods for extraction, the model tuner class offers flexibility and ease of use for building and managing complex pipelines. Users can focus on specifying the steps, and the tuner handles naming, sorting, and category assignments seamlessly.

Binary Classification
======================

Expand Down
15 changes: 13 additions & 2 deletions docs/_static/basic.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/

/* -- main layout ----------------------------------------------------------- */
Expand Down Expand Up @@ -108,11 +115,15 @@ img {
/* -- search page ----------------------------------------------------------- */

ul.search {
margin-top: 10px;
margin: 10px 0 0 20px;
padding: 0;
}

ul.search li {
padding: 5px 0;
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}

ul.search li a {
Expand Down
7 changes: 7 additions & 0 deletions docs/_static/doctools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/*
* doctools.js
* ~~~~~~~~~~~
*
* Base JavaScript utilities for all Sphinx HTML documentation.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
"use strict";

Expand Down
7 changes: 7 additions & 0 deletions docs/_static/language_data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/*
* language_data.js
* ~~~~~~~~~~~~~~~~
*
* This script contains the language-specific data used by searchtools.js,
* namely the list of stopwords, stemmer, scorer and splitter.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/

var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"];
Expand Down
38 changes: 13 additions & 25 deletions docs/_static/searchtools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/*
* searchtools.js
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilities for the full-text search.
*
* :copyright: Copyright 2007-2024 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
"use strict";

Expand All @@ -13,7 +20,7 @@ if (typeof Scorer === "undefined") {
// and returns the new score.
/*
score: result => {
const [docname, title, anchor, descr, score, filename, kind] = result
const [docname, title, anchor, descr, score, filename] = result
return score
},
*/
Expand All @@ -40,14 +47,6 @@ if (typeof Scorer === "undefined") {
};
}

// Global search result kind enum, used by themes to style search results.
class SearchResultKind {
static get index() { return "index"; }
static get object() { return "object"; }
static get text() { return "text"; }
static get title() { return "title"; }
}

const _removeChildren = (element) => {
while (element && element.lastChild) element.removeChild(element.lastChild);
};
Expand All @@ -65,13 +64,9 @@ const _displayItem = (item, searchTerms, highlightTerms) => {
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
const contentRoot = document.documentElement.dataset.content_root;

const [docName, title, anchor, descr, score, _filename, kind] = item;
const [docName, title, anchor, descr, score, _filename] = item;

let listItem = document.createElement("li");
// Add a class representing the item's type:
// can be used by a theme's CSS selector for styling
// See SearchResultKind for the class names.
listItem.classList.add(`kind-${kind}`);
let requestUrl;
let linkUrl;
if (docBuilder === "dirhtml") {
Expand Down Expand Up @@ -120,10 +115,8 @@ const _finishSearch = (resultCount) => {
"Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories."
);
else
Search.status.innerText = Documentation.ngettext(
"Search finished, found one page matching the search query.",
"Search finished, found ${resultCount} pages matching the search query.",
resultCount,
Search.status.innerText = _(
"Search finished, found ${resultCount} page(s) matching the search query."
).replace('${resultCount}', resultCount);
};
const _displayNextItem = (
Expand All @@ -145,7 +138,7 @@ const _displayNextItem = (
else _finishSearch(resultCount);
};
// Helper function used by query() to order search results.
// Each input is an array of [docname, title, anchor, descr, score, filename, kind].
// Each input is an array of [docname, title, anchor, descr, score, filename].
// Order the results by score (in opposite order of appearance, since the
// `_displayNextItem` function uses pop() to retrieve items) and then alphabetically.
const _orderResultsByScoreThenName = (a, b) => {
Expand Down Expand Up @@ -255,7 +248,6 @@ const Search = {
searchSummary.classList.add("search-summary");
searchSummary.innerText = "";
const searchList = document.createElement("ul");
searchList.setAttribute("role", "list");
searchList.classList.add("search");

const out = document.getElementById("search-results");
Expand Down Expand Up @@ -326,7 +318,7 @@ const Search = {
const indexEntries = Search._index.indexentries;

// Collect multiple result groups to be sorted separately and then ordered.
// Each is an array of [docname, title, anchor, descr, score, filename, kind].
// Each is an array of [docname, title, anchor, descr, score, filename].
const normalResults = [];
const nonMainIndexResults = [];

Expand All @@ -345,7 +337,6 @@ const Search = {
null,
score + boost,
filenames[file],
SearchResultKind.title,
]);
}
}
Expand All @@ -363,7 +354,6 @@ const Search = {
null,
score,
filenames[file],
SearchResultKind.index,
];
if (isMain) {
normalResults.push(result);
Expand Down Expand Up @@ -485,7 +475,6 @@ const Search = {
descr,
score,
filenames[match[0]],
SearchResultKind.object,
]);
};
Object.keys(objects).forEach((prefix) =>
Expand Down Expand Up @@ -596,7 +585,6 @@ const Search = {
null,
score,
filenames[file],
SearchResultKind.text,
]);
}
return results;
Expand Down
2 changes: 1 addition & 1 deletion docs/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=e34472b7"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/caveats.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=e34472b7"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=e34472b7"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
Expand Down
39 changes: 38 additions & 1 deletion docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=e34472b7"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
Expand Down Expand Up @@ -56,6 +56,7 @@
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#key-methods-and-functionalities">Key Methods and Functionalities</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#helper-functions">Helper Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#input-parameters">Input Parameters</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#pipeline-management">Pipeline Management</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#binary-classification">Binary Classification</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#regression">Regression</a></li>
<li class="toctree-l1"><a class="reference internal" href="usage_guide.html#bootstrap-metrics">Bootstrap Metrics</a></li>
Expand Down Expand Up @@ -108,6 +109,7 @@ <h1 id="index">Index</h1>
<a href="#B"><strong>B</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#E"><strong>E</strong></a>
| <a href="#G"><strong>G</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
Expand All @@ -123,6 +125,12 @@ <h2 id="B">B</h2>
<li><a href="usage_guide.html#check_input_type">check_input_type()</a>
</li>
<li><a href="usage_guide.html#evaluate_bootstrap_metrics">evaluate_bootstrap_metrics()</a>
</li>
<li><a href="usage_guide.html#get_feature_selection_pipeline">get_feature_selection_pipeline()</a>
</li>
<li><a href="usage_guide.html#get_preprocessing_and_feature_selection_pipeline">get_preprocessing_and_feature_selection_pipeline()</a>
</li>
<li><a href="usage_guide.html#get_preprocessing_pipeline">get_preprocessing_pipeline()</a>
</li>
<li><a href="usage_guide.html#return_bootstrap_metrics">return_bootstrap_metrics()</a>
</li>
Expand Down Expand Up @@ -158,6 +166,35 @@ <h2 id="E">E</h2>
</ul></td>
</tr></table>

<h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
get_feature_selection_pipeline()

<ul>
<li><a href="usage_guide.html#get_feature_selection_pipeline">built-in function</a>
</li>
</ul></li>
<li>
get_preprocessing_and_feature_selection_pipeline()

<ul>
<li><a href="usage_guide.html#get_preprocessing_and_feature_selection_pipeline">built-in function</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li>
get_preprocessing_pipeline()

<ul>
<li><a href="usage_guide.html#get_preprocessing_pipeline">built-in function</a>
</li>
</ul></li>
</ul></td>
</tr></table>

<h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=e34472b7"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
Expand Down
Loading

0 comments on commit be22187

Please sign in to comment.