# tfx.v1.components.SchemaGen

<br />

A TFX SchemaGen component to generate a schema from the training data.

Inherits From: [`BaseComponent`](https://www.tensorflow.org/tfx/api_docs/python/tfx/v1/types/BaseComponent), [`BaseNode`](https://www.tensorflow.org/tfx/api_docs/python/tfx/v1/types/BaseNode)

    tfx.v1.components.SchemaGen(
        statistics: https://www.tensorflow.org/tfx/api_docs/python/tfx/v1/types/BaseChannel,
        infer_feature_shape: Optional[Union[bool, https://www.tensorflow.org/tfx/api_docs/python/tfx/v1/dsl/experimental/RuntimeParameter]] = True,
        exclude_splits: Optional[List[str]] = None
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Licensed under the Apache License, Version 2.0 (the "License");](https://www.tensorflow.org/tfx/tutorials/tfx/gpt2_finetuning_and_conversion) - [Recommending Movies: Recommender Models in TFX](https://www.tensorflow.org/tfx/tutorials/tfx/recommenders) - [TFX Estimator Component Tutorial](https://www.tensorflow.org/tfx/tutorials/tfx/components) - [TFX Keras Component Tutorial](https://www.tensorflow.org/tfx/tutorials/tfx/components_keras) - [Data validation using TFX Pipeline and TensorFlow Data Validation](https://www.tensorflow.org/tfx/tutorials/tfx/penguin_tfdv) |

The SchemaGen component uses [TensorFlow Data
Validation](https://www.tensorflow.org/tfx/data_validation/api_docs/python/tfdv)
to generate a schema from input statistics. The following TFX libraries use
the schema:

- TensorFlow Data Validation
- TensorFlow Transform
- TensorFlow Model Analysis

In a typical TFX pipeline, the SchemaGen component generates a schema which
is consumed by the other pipeline components.

## Example

      # Generates schema based on statistics files.
      infer_schema = SchemaGen(statistics=statistics_gen.outputs['statistics'])

Component `outputs` contains:

- `schema`: Channel of type [`standard_artifacts.Schema`](https://www.tensorflow.org/tfx/api_docs/python/tfx/v1/types/standard_artifacts/Schema) for schema result.

See [the SchemaGen guide](https://www.tensorflow.org/tfx/guide/schemagen)
for more details.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `statistics` | A BaseChannel of `ExampleStatistics` type (required if spec is not passed). This should contain at least a `train` split. Other splits are currently ignored. *required* |
| `infer_feature_shape` | Boolean (or RuntimeParameter) value indicating whether or not to infer the shape of features. If the feature shape is not inferred, downstream Tensorflow Transform component using the schema will parse input as tf.SparseTensor. Default to True if not set. |
| `exclude_splits` | Names of splits that will not be taken into consideration when auto-generating a schema. Default behavior (when exclude_splits is set to None) is excluding no splits. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `outputs` | Component's output channel dict. |

<br />

## Methods

### `with_node_execution_options`

    with_node_execution_options(
        node_execution_options: utils.NodeExecutionOptions
    ) -> typing_extensions.Self

<br />

<br />

<br />

| ## Class Variables ||
|---|---|
| POST_EXECUTABLE_SPEC | `None` |
| PRE_EXECUTABLE_SPEC | `None` |

<br />