# tfma.run_model_analysis

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/model-analysis/blob/v0.46.0/tensorflow_model_analysis/api/model_eval_lib.py#L1223-L1365) |

Runs TensorFlow model analysis.

    tfma.run_model_analysis(
        eval_shared_model: Optional[https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/types/EvalSharedModel] = None,
        eval_config: Optional[https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/EvalConfig] = None,
        data_location: str = '',
        file_format: str = 'tfrecords',
        output_path: Optional[str] = None,
        extractors: Optional[List[extractor.Extractor]] = None,
        evaluators: Optional[List[evaluator.Evaluator]] = None,
        writers: Optional[List[writer.Writer]] = None,
        pipeline_options: Optional[Any] = None,
        slice_spec: Optional[List[slicer.SingleSliceSpec]] = None,
        write_config: Optional[bool] = True,
        compute_confidence_intervals: Optional[bool] = False,
        min_slice_size: int = 1,
        random_seed_for_testing: Optional[int] = None,
        schema: Optional[schema_pb2.Schema] = None
    ) -> Union[https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/EvalResult, view_types.EvalResults]

### Used in the notebooks

| Used in the guide | Used in the tutorials |
|---|---|
| - [Using Counterfactual Logit Pairing with Keras](https://www.tensorflow.org/responsible_ai/model_remediation/counterfactual/guide/counterfactual_keras) | - [TensorFlow Model Analysis](https://www.tensorflow.org/tfx/tutorials/model_analysis/tfma_basic) |

It runs a Beam pipeline to compute the slicing metrics exported in TensorFlow
Eval SavedModel and returns the results.

This is a simplified API for users who want to quickly get something running
locally. Users who wish to create their own Beam pipelines can use the
Evaluate PTransform instead.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `eval_shared_model` | Optional shared model (single-model evaluation) or list of shared models (multi-model evaluation). Only required if needed by default extractors, evaluators, or writers. |
| `eval_config` | Eval config. |
| `data_location` | The location of the data files. |
| `file_format` | The file format of the data, can be either 'text' or 'tfrecords' for now. By default, 'tfrecords' will be used. |
| `output_path` | The directory to output metrics and results to. If None, we use a temporary directory. |
| `extractors` | Optional list of Extractors to apply to Extracts. Typically these will be added by calling the default_extractors function. If no extractors are provided, default_extractors (non-materialized) will be used. |
| `evaluators` | Optional list of Evaluators for evaluating Extracts. Typically these will be added by calling the default_evaluators function. If no evaluators are provided, default_evaluators will be used. |
| `writers` | Optional list of Writers for writing Evaluation output. Typically these will be added by calling the default_writers function. If no writers are provided, default_writers will be used. |
| `pipeline_options` | Optional arguments to run the Pipeline, for instance whether to run directly. |
| `slice_spec` | Deprecated (use EvalConfig). |
| `write_config` | Deprecated (use EvalConfig). |
| `compute_confidence_intervals` | Deprecated (use EvalConfig). |
| `min_slice_size` | Deprecated (use EvalConfig). |
| `random_seed_for_testing` | Provide for deterministic tests only. |
| `schema` | Optional tf.Metadata schema of the input data. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| An EvalResult that can be used with the TFMA visualization functions. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If the file_format is unknown to us. |

<br />