blob: aee4557276e41ae8a6665886de86e0f1b0cc3ff8 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>apache_beam.ml.transforms.tft module &mdash; Apache Beam 2.52.0 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="apache_beam.ml.transforms.utils module" href="apache_beam.ml.transforms.utils.html" />
<link rel="prev" title="apache_beam.ml.transforms.handlers module" href="apache_beam.ml.transforms.handlers.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Apache Beam
</a>
<div class="version">
2.52.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="apache_beam.coders.html">apache_beam.coders package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.dataframe.html">apache_beam.dataframe package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.io.html">apache_beam.io package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.metrics.html">apache_beam.metrics package</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="apache_beam.ml.html">apache_beam.ml package</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="apache_beam.ml.html#subpackages">Subpackages</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="apache_beam.ml.gcp.html">apache_beam.ml.gcp package</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.ml.inference.html">apache_beam.ml.inference package</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="apache_beam.ml.transforms.html">apache_beam.ml.transforms package</a><ul class="current">
<li class="toctree-l4 current"><a class="reference internal" href="apache_beam.ml.transforms.html#submodules">Submodules</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.options.html">apache_beam.options package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.portability.html">apache_beam.portability package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.runners.html">apache_beam.runners package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.testing.html">apache_beam.testing package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.transforms.html">apache_beam.transforms package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.typehints.html">apache_beam.typehints package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.utils.html">apache_beam.utils package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.yaml.html">apache_beam.yaml package</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.error.html">apache_beam.error module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pipeline.html">apache_beam.pipeline module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pvalue.html">apache_beam.pvalue module</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Apache Beam</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li><a href="apache_beam.ml.html">apache_beam.ml package</a> &raquo;</li>
<li><a href="apache_beam.ml.transforms.html">apache_beam.ml.transforms package</a> &raquo;</li>
<li>apache_beam.ml.transforms.tft module</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/apache_beam.ml.transforms.tft.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-apache_beam.ml.transforms.tft">
<span id="apache-beam-ml-transforms-tft-module"></span><h1>apache_beam.ml.transforms.tft module<a class="headerlink" href="#module-apache_beam.ml.transforms.tft" title="Permalink to this headline"></a></h1>
<p>This module defines a set of data processing transforms that can be used
to perform common data transformations on a dataset. These transforms are
implemented using the TensorFlow Transform (TFT) library. The transforms
in this module are intended to be used in conjunction with the
MLTransform class, which provides a convenient interface for
applying a sequence of data processing transforms to a dataset.</p>
<p>See the documentation for MLTransform for more details.</p>
<p>Note: The data processing transforms defined in this module don’t
perform the transformation immediately. Instead, it returns a
configured operation object, which encapsulates the details of the
transformation. The actual computation takes place later in the Apache Beam
pipeline, after all transformations are set up and the pipeline is run.</p>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.TFTOperation">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">TFTOperation</code><span class="sig-paren">(</span><em>columns: List[str]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#TFTOperation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.TFTOperation" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.ml.transforms.base.html#apache_beam.ml.transforms.base.BaseOperation" title="apache_beam.ml.transforms.base.BaseOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.base.BaseOperation</span></code></a></p>
<p>Base Operation class for TFT data processing transformations.
Processing logic for the transformation is defined in the
apply_transform() method. If you have a custom transformation that is not
supported by the existing transforms, you can extend this class
and implement the apply_transform() method.
:param columns: List of column names to apply the transformation.</p>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.ComputeAndApplyVocabulary">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">ComputeAndApplyVocabulary</code><span class="sig-paren">(</span><em>columns: List[str], split_string_by_delimiter: Optional[str] = None, *, default_value: Any = -1, top_k: Optional[int] = None, frequency_threshold: Optional[int] = None, num_oov_buckets: int = 0, vocab_filename: Optional[str] = None, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ComputeAndApplyVocabulary"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ComputeAndApplyVocabulary" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This function computes the vocabulary for the given columns of incoming
data. The transformation converts the input values to indices of the
vocabulary.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – List of column names to apply the transformation.</li>
<li><strong>split_string_by_delimiter</strong> – (Optional) A string that specifies the
delimiter to split strings.</li>
<li><strong>default_value</strong> – (Optional) The value to use for out-of-vocabulary values.</li>
<li><strong>top_k</strong> – (Optional) The number of most frequent tokens to keep.</li>
<li><strong>frequency_threshold</strong> – (Optional) Limit the generated vocabulary only to
elements whose absolute frequency is &gt;= to the supplied threshold.
If set to None, the full vocabulary is generated.</li>
<li><strong>num_oov_buckets</strong> – Any lookup of an out-of-vocabulary token will return a
bucket ID based on its hash if <cite>num_oov_buckets</cite> is greater than zero.
Otherwise it is assigned the <cite>default_value</cite>.</li>
<li><strong>vocab_filename</strong> – The file name for the vocabulary file. If not provided,
the default name would be <cite>compute_and_apply_vocab’
NOTE in order to make your pipelines resilient to implementation
details please set `vocab_filename</cite> when you are using
the vocab_filename on a downstream component.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.ComputeAndApplyVocabulary.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; Dict[str, &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;]<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ComputeAndApplyVocabulary.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ComputeAndApplyVocabulary.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.ScaleToZScore">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">ScaleToZScore</code><span class="sig-paren">(</span><em>columns: List[str], *, elementwise: bool = False, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ScaleToZScore"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ScaleToZScore" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This function performs a scaling transformation on the specified columns of
the incoming data. It processes the input data such that it’s normalized
to have a mean of 0 and a variance of 1. The transformation achieves this
by subtracting the mean from the input data and then dividing it by the
square root of the variance.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – A list of column names to apply the transformation on.</li>
<li><strong>elementwise</strong> – If True, the transformation is applied elementwise.
Otherwise, the transformation is applied on the entire column.</li>
<li><strong>name</strong> – A name for the operation (optional).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>scale_to_z_score also outputs additional artifacts. The artifacts are
mean, which is the mean value in the column, and var, which is the
variance in the column. The artifacts are stored in the column
named with the suffix &lt;original_col_name&gt;_mean and &lt;original_col_name&gt;_var
respectively.</p>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.ScaleToZScore.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; Dict[str, &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;]<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ScaleToZScore.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ScaleToZScore.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.ScaleTo01">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">ScaleTo01</code><span class="sig-paren">(</span><em>columns: List[str], elementwise: bool = False, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ScaleTo01"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ScaleTo01" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This function applies a scaling transformation on the given columns
of incoming data. The transformation scales the input values to the
range [0, 1] by dividing each value by the maximum value in the
column.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – A list of column names to apply the transformation on.</li>
<li><strong>elementwise</strong> – If True, the transformation is applied elementwise.
Otherwise, the transformation is applied on the entire column.</li>
<li><strong>name</strong> – A name for the operation (optional).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>ScaleTo01 also outputs additional artifacts. The artifacts are
max, which is the maximum value in the column, and min, which is the
minimum value in the column. The artifacts are stored in the column
named with the suffix &lt;original_col_name&gt;_min and &lt;original_col_name&gt;_max
respectively.</p>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.ScaleTo01.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; Dict[str, &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;]<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ScaleTo01.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ScaleTo01.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.ApplyBuckets">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">ApplyBuckets</code><span class="sig-paren">(</span><em>columns: List[str], bucket_boundaries: Iterable[Union[int, float]], name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ApplyBuckets"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ApplyBuckets" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This functions is used to map the element to a positive index i for
which bucket_boundaries[i-1] &lt;= element &lt; bucket_boundaries[i],
if it exists. If input &lt; bucket_boundaries[0], then element is
mapped to 0. If element &gt;= bucket_boundaries[-1], then element is
mapped to len(bucket_boundaries). NaNs are mapped to
len(bucket_boundaries).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – A list of column names to apply the transformation on.</li>
<li><strong>bucket_boundaries</strong> – A rank 2 Tensor or list representing the bucket
boundaries sorted in ascending order.</li>
<li><strong>name</strong> – (Optional) A string that specifies the name of the operation.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.ApplyBuckets.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; Dict[str, &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;]<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ApplyBuckets.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ApplyBuckets.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.Bucketize">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">Bucketize</code><span class="sig-paren">(</span><em>columns: List[str], num_buckets: int, *, epsilon: Optional[float] = None, elementwise: bool = False, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#Bucketize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.Bucketize" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This function applies a bucketizing transformation on the given columns
of incoming data. The transformation splits the input data range into
a set of consecutive bins/buckets, and converts the input values to
bucket IDs (integers) where each ID corresponds to a particular bin.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – List of column names to apply the transformation.</li>
<li><strong>num_buckets</strong> – Number of buckets to be created.</li>
<li><strong>epsilon</strong> – (Optional) A float number that specifies the error tolerance
when computing quantiles, so that we guarantee that any value x will
have a quantile q such that x is in the interval
[q - epsilon, q + epsilon] (or the symmetric interval for even
num_buckets). Must be greater than 0.0.</li>
<li><strong>elementwise</strong> – (Optional) A boolean that specifies whether the quantiles
should be computed on an element-wise basis. If False, the quantiles
are computed globally.</li>
<li><strong>name</strong> – (Optional) A string that specifies the name of the operation.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.Bucketize.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; Dict[str, &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;]<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#Bucketize.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.Bucketize.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.TFIDF">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">TFIDF</code><span class="sig-paren">(</span><em>columns: List[str], vocab_size: Optional[int] = None, smooth: bool = True, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#TFIDF"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.TFIDF" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This function applies a tf-idf transformation on the given columns
of incoming data.</p>
<p>TFIDF outputs two artifacts for each column: the vocabu index and
the tfidf weight. The vocabu index is a mapping from the original
vocabulary to the new vocabulary. The tfidf weight is a mapping
from the original vocabulary to the tfidf score.</p>
<p>Input passed to the TFIDF is not modified and used to calculate the
required artifacts.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – List of column names to apply the transformation.</li>
<li><strong>vocab_size</strong><p>(Optional) An integer that specifies the size of the
vocabulary. Defaults to None.</p>
<p>If vocab_size is None, then the size of the vocabulary is
determined by <cite>tft.get_num_buckets_for_transformed_feature</cite>.</p>
</li>
<li><strong>smooth</strong> – (Optional) A boolean that specifies whether to apply
smoothing to the tf-idf score. Defaults to True.</li>
<li><strong>name</strong> – (Optional) A string that specifies the name of the operation.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.TFIDF.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#TFIDF.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.TFIDF.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.ScaleByMinMax">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">ScaleByMinMax</code><span class="sig-paren">(</span><em>columns: List[str], min_value: float = 0.0, max_value: float = 1.0, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ScaleByMinMax"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ScaleByMinMax" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>This function applies a scaling transformation on the given columns
of incoming data. The transformation scales the input values to the
range [min_value, max_value].</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – A list of column names to apply the transformation on.</li>
<li><strong>min_value</strong> – The minimum value of the output range.</li>
<li><strong>max_value</strong> – The maximum value of the output range.</li>
<li><strong>name</strong> – A name for the operation (optional).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.ScaleByMinMax.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#ScaleByMinMax.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.ScaleByMinMax.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.NGrams">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">NGrams</code><span class="sig-paren">(</span><em>columns: List[str], split_string_by_delimiter: Optional[str] = None, *, ngram_range: Tuple[int, int] = (1, 1), ngrams_separator: Optional[str] = None, name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#NGrams"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.NGrams" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>An n-gram is a contiguous sequence of n items from a given sample of text
or speech. This operation applies an n-gram transformation to
specified columns of incoming data, splitting the input data into a
set of consecutive n-grams.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – A list of column names to apply the transformation on.</li>
<li><strong>split_string_by_delimiter</strong> – (Optional) A string that specifies the
delimiter to split the input strings before computing ngrams.</li>
<li><strong>ngram_range</strong> – A tuple of integers(inclusive) specifying the range of
n-gram sizes.</li>
<li><strong>ngrams_separator</strong> – A string that will be inserted between each ngram.</li>
<li><strong>name</strong> – A name for the operation (optional).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.NGrams.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;</em>, <em>output_column_name: str</em><span class="sig-paren">)</span> &#x2192; Dict[str, &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbed400&gt;]<a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#NGrams.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.NGrams.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.ml.transforms.tft.BagOfWords">
<em class="property">class </em><code class="descclassname">apache_beam.ml.transforms.tft.</code><code class="descname">BagOfWords</code><span class="sig-paren">(</span><em>columns: List[str], split_string_by_delimiter: Optional[str] = None, *, ngram_range: Tuple[int, int] = (1, 1), ngrams_separator: Optional[str] = None, compute_word_count: bool = False, key_vocab_filename: str = 'key_vocab_mapping', name: Optional[str] = None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#BagOfWords"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.BagOfWords" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="#apache_beam.ml.transforms.tft.TFTOperation" title="apache_beam.ml.transforms.tft.TFTOperation"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.ml.transforms.tft.TFTOperation</span></code></a></p>
<p>Bag of words contains the unique words present in the input text.
This operation applies a bag of words transformation to specified
columns of incoming data. Also, the transformation accepts a Tuple of
integers specifying the range of n-gram sizes. The transformation
splits the input data into a set of consecutive n-grams if ngram_range
is specified. The n-grams are then converted to a bag of words.
Also, you can specify a seperator string that will be inserted between
each ngram.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>columns</strong> – A list of column names to apply the transformation on.</li>
<li><strong>split_string_by_delimiter</strong> – (Optional) A string that specifies the
delimiter to split the input strings before computing ngrams.</li>
<li><strong>ngram_range</strong> – A tuple of integers(inclusive) specifying the range of
n-gram sizes.</li>
<li><strong>seperator</strong> – A string that will be inserted between each ngram.</li>
<li><strong>compute_word_count</strong> – A boolean that specifies whether to compute
the unique word count over the entire dataset. Defaults to False.</li>
<li><strong>key_vocab_filename</strong> – The file name for the key vocabulary file when
compute_word_count is True.</li>
<li><strong>name</strong> – A name for the operation (optional).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Note that original order of the input may not be preserved.</p>
<dl class="method">
<dt id="apache_beam.ml.transforms.tft.BagOfWords.apply_transform">
<code class="descname">apply_transform</code><span class="sig-paren">(</span><em>data: &lt;sphinx.ext.autodoc.importer._MockObject object at 0x7f50cfbfe280&gt;</em>, <em>output_col_name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/ml/transforms/tft.html#BagOfWords.apply_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.ml.transforms.tft.BagOfWords.apply_transform" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="apache_beam.ml.transforms.utils.html" class="btn btn-neutral float-right" title="apache_beam.ml.transforms.utils module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="apache_beam.ml.transforms.handlers.html" class="btn btn-neutral float-left" title="apache_beam.ml.transforms.handlers module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>