Facets Overview
Facets Overview is a Python library that generates interactive visualizations for analyzing machine learning datasets. It processes data into protobufs, which are then rendered by front-end web components (Polymer). The library is currently at version 1.1.1, with the last release in 2017, indicating it is no longer actively maintained.
Common errors
-
ModuleNotFoundError: No module named 'facets_overview'
cause The `facets-overview` package is not installed in your current Python environment.fixRun `pip install facets-overview` to install the library. -
google.protobuf.message.DecodeError: Error parsing message
cause This error often indicates a version mismatch between the `protobuf` library installed in your environment and the `protobuf` version used to compile the `.proto` definitions within `facets-overview`.fixTry installing an older version of the `protobuf` library: `pip install protobuf<3.20` (or `protobuf==3.19.0` for a specific version known to work with older Google libraries). -
Javascript errors in browser console related to '<link rel="import">' or Polymer
cause Facets Overview relies on deprecated Web Components v0 APIs (Polymer 1/2 and HTML Imports). Modern browsers have removed support for these features.fixThis is a fundamental limitation of an abandoned library. There is no simple fix for modern browsers. You might need to use an older browser version or a specific environment where these legacy web components are still supported. -
AttributeError: 'HTML' object has no attribute '_repr_html_' (or similar non-rendering behavior in JupyterLab)
cause The visualization relies on Jupyter Notebook nbextensions for rendering and does not have native support or an easy integration path for JupyterLab or other environments.fixEnsure you are running in a classic Jupyter Notebook and that the `facets_overview` nbextension is enabled (`jupyter nbextension enable --py facets_overview`). For JupyterLab, consider using alternative libraries.
Warnings
- breaking The v1.0.0 release updated the underlying web component technology from Polymer 1 to Polymer 2. This can break existing display mechanisms or require browser environment updates.
- deprecated Facets Overview is an abandoned library, with the last release in 2017. It relies on deprecated front-end technologies (Polymer 1/2) and older Python practices, making it largely incompatible with modern web browsers, JupyterLab, and newer Python versions (3.8+).
- gotcha The display mechanism is tightly coupled to Jupyter Notebooks via nbextensions. It does not natively support JupyterLab or other Python environments without significant workarounds.
- gotcha Facets Overview uses Google Protobuf for data serialization. There are known compatibility issues with newer `protobuf` library versions, leading to `DecodeError` or `TypeError` exceptions.
Install
-
pip install facets-overview
Imports
- GenericFeatureStatisticsGenerator
from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator
- FeatureStatisticsList
from facets_overview.feature_statistics_pb2 import FeatureStatisticsList
Quickstart
import pandas as pd
from facets_overview.generic_feature_statistics_generator import GenericFeatureStatisticsGenerator
from IPython.display import display, HTML
# Example data
data = [
{'feature1': 1, 'feature2': 'cat'},
{'feature1': 2, 'feature2': 'dog'},
{'feature1': 3, 'feature2': 'cat'}
]
df = pd.DataFrame(data)
# Create the FeatureStatisticsList proto for Facets Overview.
gfsg = GenericFeatureStatisticsGenerator()
overview_proto = gfsg.CreateFeatureStatisticsListFromDataFrame(df)
protostr = overview_proto.SerializeToString().decode('utf-8')
# Display the Facets Overview UI (requires Jupyter Notebook and nbextension enabled)
HTML_TEMPLATE = """<link rel="import" href="/nbextensions/facets_overview/facets-overview.html">
<facets-overview id="facets-overview"></facets-overview>
<script>
document.querySelector("#facets-overview").protoInput = "{protostr}";
</script>"""
html_output = HTML_TEMPLATE.format(protostr=protostr)
display(HTML(html_output))