Facets
        zenml.integrations.facets
  
      special
  
    Facets integration for ZenML.
        
FacetsIntegration            (Integration)
        
    Definition of Facets integration for ZenML.
Source code in zenml/integrations/facets/__init__.py
          class FacetsIntegration(Integration):
    """Definition of Facets integration for ZenML."""
    NAME = FACETS
    REQUIREMENTS = ["facets-overview>=1.0.0"]
    REQUIREMENTS_IGNORED_ON_UNINSTALL = ["pandas"]
    @classmethod
    def activate(cls) -> None:
        """Activate the Facets integration."""
        from zenml.integrations.facets import materializers  # noqa
    @classmethod
    def get_requirements(cls, target_os: Optional[str] = None) -> List[str]:
        """Method to get the requirements for the integration.
        Args:
            target_os: The target operating system to get the requirements for.
        Returns:
            A list of requirements.
        """
        from zenml.integrations.pandas import PandasIntegration
        return cls.REQUIREMENTS + \
            PandasIntegration.get_requirements(target_os=target_os)
activate()
  
      classmethod
  
    Activate the Facets integration.
Source code in zenml/integrations/facets/__init__.py
          @classmethod
def activate(cls) -> None:
    """Activate the Facets integration."""
    from zenml.integrations.facets import materializers  # noqa
get_requirements(target_os=None)
  
      classmethod
  
    Method to get the requirements for the integration.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| target_os | Optional[str] | The target operating system to get the requirements for. | None | 
Returns:
| Type | Description | 
|---|---|
| List[str] | A list of requirements. | 
Source code in zenml/integrations/facets/__init__.py
          @classmethod
def get_requirements(cls, target_os: Optional[str] = None) -> List[str]:
    """Method to get the requirements for the integration.
    Args:
        target_os: The target operating system to get the requirements for.
    Returns:
        A list of requirements.
    """
    from zenml.integrations.pandas import PandasIntegration
    return cls.REQUIREMENTS + \
        PandasIntegration.get_requirements(target_os=target_os)
        materializers
  
      special
  
    Facets Materializers.
        facets_materializer
    Implementation of the FacetsMaterializer.
        
FacetsMaterializer            (BaseMaterializer)
        
    Materializer to save Facets visualizations.
This materializer is used to visualize and compare dataset statistics using Facets. In contrast to other materializers, this materializer only saves the visualization and not the data itself.
Source code in zenml/integrations/facets/materializers/facets_materializer.py
          class FacetsMaterializer(BaseMaterializer):
    """Materializer to save Facets visualizations.
    This materializer is used to visualize and compare dataset statistics using
    Facets. In contrast to other materializers, this materializer only saves
    the visualization and not the data itself.
    """
    ASSOCIATED_TYPES = (FacetsComparison,)
    ASSOCIATED_ARTIFACT_TYPE = ArtifactType.DATA_ANALYSIS
    def save_visualizations(
        self, data: FacetsComparison
    ) -> Dict[str, VisualizationType]:
        """Save a Facets visualization of the data.
        Args:
            data: The data to visualize.
        Returns:
            A dictionary of visualization URIs and their types.
        """
        proto = GenericFeatureStatisticsGenerator().ProtoFromDataFrames(
            data.datasets
        )
        protostr = base64.b64encode(proto.SerializeToString()).decode("utf-8")
        template = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "stats.html",
        )
        html = io_utils.read_file_contents_as_string(template)
        html = html.replace("protostr", protostr)
        visualization_path = os.path.join(self.uri, VISUALIZATION_FILENAME)
        visualization_path = visualization_path.replace("\\", "/")
        with fileio.open(visualization_path, "w") as f:
            f.write(html)
        return {visualization_path: VisualizationType.HTML}
save_visualizations(self, data)
    Save a Facets visualization of the data.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | FacetsComparison | The data to visualize. | required | 
Returns:
| Type | Description | 
|---|---|
| Dict[str, zenml.enums.VisualizationType] | A dictionary of visualization URIs and their types. | 
Source code in zenml/integrations/facets/materializers/facets_materializer.py
          def save_visualizations(
    self, data: FacetsComparison
) -> Dict[str, VisualizationType]:
    """Save a Facets visualization of the data.
    Args:
        data: The data to visualize.
    Returns:
        A dictionary of visualization URIs and their types.
    """
    proto = GenericFeatureStatisticsGenerator().ProtoFromDataFrames(
        data.datasets
    )
    protostr = base64.b64encode(proto.SerializeToString()).decode("utf-8")
    template = os.path.join(
        os.path.abspath(os.path.dirname(__file__)),
        "stats.html",
    )
    html = io_utils.read_file_contents_as_string(template)
    html = html.replace("protostr", protostr)
    visualization_path = os.path.join(self.uri, VISUALIZATION_FILENAME)
    visualization_path = visualization_path.replace("\\", "/")
    with fileio.open(visualization_path, "w") as f:
        f.write(html)
    return {visualization_path: VisualizationType.HTML}
        models
    Models used by the Facets integration.
        
FacetsComparison            (BaseModel)
        
    Facets comparison model.
Returning this from any step will automatically visualize the datasets statistics using Facets.
Attributes:
| Name | Type | Description | 
|---|---|---|
| datasets | List[Dict[str, Union[str, pandas.DataFrame]]] | List of datasets to compare. Should be in the format
 | 
Source code in zenml/integrations/facets/models.py
          class FacetsComparison(BaseModel):
    """Facets comparison model.
    Returning this from any step will automatically visualize the datasets
    statistics using Facets.
    Attributes:
        datasets: List of datasets to compare. Should be in the format
            `[{"name": "dataset_name", "table": pd.DataFrame}, ...]`.
    """
    datasets: List[Dict[str, Union[str, pd.DataFrame]]]
    model_config = ConfigDict(arbitrary_types_allowed=True)
        steps
  
      special
  
    Facets Standard Steps.
        facets_visualization_steps
    Facets Standard Steps.