Skip to content

Add documentation with MkDocs #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
57dd140
Rename docs directory
smokestacklightnin May 8, 2025
4ba0a7d
Add mkdocs dependencies
smokestacklightnin May 9, 2025
21c38a9
Get mkdocs up and running
smokestacklightnin May 9, 2025
5e464cc
Add navigation for guide pages
smokestacklightnin May 9, 2025
265ee3a
Move deprecated API docs to `deprecated` directory
smokestacklightnin May 9, 2025
11afded
Add dependencies for API docs
smokestacklightnin May 10, 2025
e5829fc
Add items to `__all__` so they are included in the docs
smokestacklightnin May 10, 2025
34de7c4
Add api docs for `tfma.constants`
smokestacklightnin May 10, 2025
01cef4a
Batch add remaining submodule api docs
smokestacklightnin May 10, 2025
3de5438
Add items to `__all__` for `evaluators` submodule
smokestacklightnin May 10, 2025
6983d83
Add emoji to experimental submodule
smokestacklightnin May 10, 2025
dbcf3fa
Add items to `__all__` for `extractors` submodule
smokestacklightnin May 10, 2025
fbd1d9a
Add items to `__all__` for `metrics` submodule
smokestacklightnin May 10, 2025
85b9182
Add file extensions
smokestacklightnin May 10, 2025
ae1e394
Add items to `__all__` for submodule `post_export_metrics`
smokestacklightnin May 10, 2025
b49304b
Add items to `__all__` for `sdk` submodule
smokestacklightnin May 10, 2025
c02478a
Add items to `__all__` for `types` submodule
smokestacklightnin May 10, 2025
adf88a9
Add items to `__all__` in `utils` submodule
smokestacklightnin May 10, 2025
3374af4
Add items to `__all__` for `validators` submodule
smokestacklightnin May 10, 2025
a7d1587
Add items to `__all__` for `view` submodule
smokestacklightnin May 10, 2025
03f1f5a
Add items to `__all__` for `writers` submodule
smokestacklightnin May 10, 2025
8aca955
Fix capitalization
smokestacklightnin May 10, 2025
5099efa
Add documentation workflow
smokestacklightnin May 12, 2025
d787dcf
Merge remote-tracking branch 'upstream/master' into ci/docs/add-mkdocs
smokestacklightnin May 12, 2025
ac2d1c5
Fix broken links
smokestacklightnin May 12, 2025
7ea84ae
Fix links to old docs
smokestacklightnin May 15, 2025
c4b483f
Fix external links that should be internal
smokestacklightnin May 15, 2025
9d42207
Fix links to external documentation
smokestacklightnin May 16, 2025
0bfebab
Fix links to api docs
smokestacklightnin May 16, 2025
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
52 changes: 52 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy docs
on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
if: (github.event_name != 'pull_request')

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
setup.py
requirements-docs.txt

- name: Save time for cache for mkdocs
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- name: Caching
uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-

- name: Install Dependencies
run: pip install -r requirements-docs.txt

- name: Deploy to GitHub Pages
run: mkdocs gh-deploy --force
if: (github.event_name != 'pull_request')

- name: Build docs to check for errors
run: mkdocs build
if: (github.event_name == 'pull_request')
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions docs/api_docs/python/tfma-constants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TFMA Constants

::: tensorflow_model_analysis.constants
3 changes: 3 additions & 0 deletions docs/api_docs/python/tfma-contrib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TFMA Constants

::: tensorflow_model_analysis.contrib
5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-evaluators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Evaluators

::: tensorflow_model_analysis.evaluators

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-experimental.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Experimental

::: tensorflow_model_analysis.experimental

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-extractors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Extractors

::: tensorflow_model_analysis.extractors

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Metrics

::: tensorflow_model_analysis.metrics

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-post_export_metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Post_Export_Metrics

::: tensorflow_model_analysis.post_export_metrics

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA SDK

::: tensorflow_model_analysis.sdk

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Types

::: tensorflow_model_analysis.types

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Utils

::: tensorflow_model_analysis.utils

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-validators.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Validators

::: tensorflow_model_analysis.validators

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Version

::: tensorflow_model_analysis.version

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA View

::: tensorflow_model_analysis.view

5 changes: 5 additions & 0 deletions docs/api_docs/python/tfma-writers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# TFMA Writers

::: tensorflow_model_analysis.writers

3 changes: 3 additions & 0 deletions docs/api_docs/python/tfma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TFMA

::: tensorflow_model_analysis
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions g3doc/faq.md → docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TFMA supports keras models, models based on generic TF2 signature APIs, as well
TF estimator based models (although depending on the use case the estimator
based models may require an `EvalSavedModel` to be used).

See [get_started](get_started.md) guide for the full list of model types
See [get started](get_started.md) guide for the full list of model types
supported and any restrictions.

### How do I setup TFMA to work with a native keras based model?
Expand All @@ -61,7 +61,7 @@ assumptions:
(this can be changed using `model_specs[0].signature_name`).
* Built in metrics from `model.compile(...)` should be evaluated (this can be
disabled via `options.include_default_metric` within the
[tfma.EvalConfig](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/EvalConfig)).
[tfma.EvalConfig](../api_docs/python/tfma#tensorflow_model_analysis.EvalConfig)).

```python
from google.protobuf import text_format
Expand Down Expand Up @@ -425,7 +425,7 @@ single label per example, not for multi-label.
This is most likely caused because the metrics are configured for a binary
classification problem, but the model is outputing probabilities for both of the
classes instead of just one. This is common when
[tensorflow's classification API](https://www.tensorflow.org/tfx/serving/signature_defs#classification_signaturedef)
[tensorflow's classification API](https://tensorflow.github.io/serving/guide/signature_defs/#classification-signaturedef)
is used. The solution is to choose the class that you would like the predictions
to be based on and then binarize on that class. For example:

Expand Down
14 changes: 7 additions & 7 deletions g3doc/get_started.md → docs/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you just want to jump in and get started, check out our
notebook.

This page can also be viewed from
[tensorflow.org](https://www.tensorflow.org/tfx/model_analysis/get_started).
[tensorflow.org](https://tensorflow.github.io/model-analysis/get_started).

## Model Types Supported

Expand Down Expand Up @@ -75,19 +75,19 @@ different model types.
## Setup

Before running an evaluation, a small amount of setup is required. First, a
[`tfma.EvalConfig`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/EvalConfig)
[`tfma.EvalConfig`](../api_docs/python/tfma#tensorflow_model_analysis.EvalConfig)
object must be defined that provides specifications for the model, metrics, and
slices that are to be evaluated. Second a
[`tfma.EvalSharedModel`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/default_eval_shared_model)
[`tfma.EvalSharedModel`](../api_docs/python/tfma#tensorflow_model_analysis.default_eval_shared_model)
needs to be created that points to the actual model (or models) to be used
during the evaluation. Once these have been defined, evaluation is performed by
calling
[`tfma.run_model_analysis`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/run_model_analysis)
[`tfma.run_model_analysis`](../api_docs/python/tfma#tensorflow_model_analysis.run_model_analysis)
with an appropriate dataset. For more details, see the [setup](setup.md) guide.

If running within a TFX pipeline, see the TFX
[guide](https://www.tensorflow.org/tfx/guide) for how to configure TFMA to run
as a TFX [Evaluator](https://www.tensorflow.org/tfx/guide/evaluator) component.
[guide](https://tensorflow.github.io/tfx/guide) for how to configure TFMA to run
as a TFX [Evaluator](https://tensorflow.github.io/tfx/guide/evaluator) component.

## Examples

Expand Down Expand Up @@ -296,4 +296,4 @@ frontend components included in TFMA. For example:
* [Visualizations](visualizations.md)
* [Architecture](architecture.md)
* [FAQ](faq.md)
* [API Reference](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma)
* [API Reference](../api_docs/python/tfma)
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions docs/images/tf_full_color_primary_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
39 changes: 39 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Improving Model Quality With TensorFlow Model Analysis

## Introduction

As you tweak your model during development, you need to check whether your
changes are improving your model. Just checking accuracy may not be enough. For
example, if you have a classifier for a problem in which 95% of your instances
are positive, you may be able to improve accuracy by simply always predicting
positive, but you won't have a very robust classifier.

## Overview

The goal of TensorFlow Model Analysis is to provide a mechanism for model
evaluation in TFX. TensorFlow Model Analysis allows you to perform model
evaluations in the TFX pipeline, and view resultant metrics and plots in a
Jupyter notebook. Specifically, it can provide:

* [Metrics](https://tensorflow.github.io/model-analysis/metrics) computed on entire training and holdout
dataset, as well as next-day evaluations
* Tracking metrics over time
* Model quality performance on different feature slices
* [Model validation](https://tensorflow.github.io/model-analysis/model_validations) for ensuring that
model's maintain consistent performance

## Next Steps

Try our [TFMA tutorial](https://tensorflow.github.io/tfx/tutorials/model_analysis/tfma_basic).

Check out our [github](https://github.com/tensorflow/model-analysis) page for
details on the supported
[metrics and plots](https://tensorflow.github.io/model-analysis/metrics) and associated notebook
[visualizations](https://tensorflow.github.io/model-analysis/visualizations).

See the [installation](https://tensorflow.github.io/model-analysis/install) and
[getting started](https://tensorflow.github.io/model-analysis/get_started) guides for information and
examples on how to get [set up](https://tensorflow.github.io/model-analysis/setup) in a standalone
pipeline. Recall that TFMA is also used within the [Evaluator](evaluator.md)
component in TFX, so these resources will be useful for getting started in TFX
as well.
File renamed without changes.
19 changes: 19 additions & 0 deletions docs/javascripts/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.startup.output.clearCache()
MathJax.typesetClear()
MathJax.texReset()
MathJax.typesetPromise()
})
14 changes: 7 additions & 7 deletions g3doc/metrics.md → docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ TFMA supports the following metrics and plots:
are computed outside of the graph in beam using the metrics classes
directly.
* Standard TFMA metrics and plots
([`tfma.metrics.*`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/metrics))
([`tfma.metrics.*`](../api_docs/python/tfma-metrics))

* Custom keras metrics (metrics derived from
[`tf.keras.metrics.Metric`](https://www.tensorflow.org/api_docs/python/tf/keras/metrics/Metric))

* Custom TFMA metrics (metrics derived from
[`tfma.metrics.Metric`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/metrics/Metric))
[`tfma.metrics.Metric`](../api_docs/python/tfma-metrics#tensorflow_model_analysis.metrics.Metric))
using custom beam combiners or metrics derived from other metrics).

NOTE: In TFMA, plots and metrics are both defined under the metrics library. By
Expand All @@ -38,10 +38,10 @@ classification, ranking, etc.
## Configuration

There are two ways to configure metrics in TFMA: (1) using the
[`tfma.MetricsSpec`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/api/MetricsSpec)
[`tfma.MetricsSpec`](../api_docs/python/tfma#tensorflow_model_analysis.metricsSpec)
or (2) by creating instances of `tf.keras.metrics.*` and/or `tfma.metrics.*`
classes in python and using
[`tfma.metrics.specs_from_metrics`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/api/metrics/specs_from_metrics)
[`tfma.metrics.specs_from_metrics`](../api_docs/python/tfma-metrics#tensorflow_model_analysis.metrics.specs_from_metrics)
to convert them to a list of `tfma.MetricsSpec`.

The following sections describe example configurations for different types of
Expand Down Expand Up @@ -598,7 +598,7 @@ All the supported plots are stored in a single proto called
### EvalResult

The return from an evaluation run is an
[`tfma.EvalResult`](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/EvalResult).
[`tfma.EvalResult`](../api_docs/python/tfma#tensorflow_model_analysis.EvalResult).
This record contains `slicing_metrics` that encode the metric key as a
multi-level dict where the levels correspond to output name, class ID, metric
name, and metric value respectively. This is intended to be used for UI display
Expand Down Expand Up @@ -702,7 +702,7 @@ will be used by the combiner (see [architecture](architecture.md) for more info
on what are extracts). All preprocessors will be executed sequentially in the
order of the list. If the `preprocessors` is empty, then the combiner will be
passed
[StandardMetricInputs](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/metrics/StandardMetricInputs)
[StandardMetricInputs](../api_docs/python/tfma-metrics#tensorflow_model_analysis.metrics.StandardMetricInputs)
(standard metric inputs contains labels, predictions, and example_weights). The
`combiner` is a `beam.CombineFn` that takes a tuple of (slice key, preprocessor
output) as its input and outputs a tuple of (slice_key, metric results dict) as
Expand All @@ -713,7 +713,7 @@ Note that slicing happens between the `preprocessors` and `combiner`.
Note that if a metric computation wants to make use of both the standard metric
inputs, but augment it with a few of the features from the `features` extracts,
then the special
[FeaturePreprocessor](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/metrics/FeaturePreprocessor)
[FeaturePreprocessor](../api_docs/python/tfma-metrics#tensorflow_model_analysis.metrics.FeaturePreprocessor)
can be used which will merge the requested features from multiple combiners into
a single shared StandardMetricsInputs value that is passed to all the combiners
(the combiners are responsible for reading the features they are interested in
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:root {
--md-primary-fg-color: #FFA800;
--md-primary-fg-color--light: #CCCCCC;
--md-primary-fg-color--dark: #425066;
}

.video-wrapper {
max-width: 240px;
display: flex;
flex-direction: row;
}
.video-wrapper > iframe {
width: 100%;
aspect-ratio: 16 / 9;
}

.buttons-wrapper {
flex-wrap: wrap;
gap: 1em;
display: flex;
/* flex-grow: 1; */
/* justify-content: center; */
/* align-content: center; */
}

.buttons-wrapper > a {
justify-content: center;
align-content: center;
flex-wrap: nowrap;
/* gap: 1em; */
align-items: center;
text-align: center;
flex: 1 1 30%;
display: flex;
}

.md-button > .buttons-content {
align-items: center;
justify-content: center;
display: flex;
gap: 1em;
}
Loading