A Python API for Intelligent Visual Discovery
Lux is a Python library that makes data science easier by automating certain aspects of the data exploration process. Lux is designed to facilitate faster experimentation with data, even when the user does not have a clear idea of what they are looking for. Lux is integrated with an interactive Jupyter widget that allows users to quickly browse through large collections of data directly within their Jupyter notebooks.
Here are some slides from a recent talk on Lux.
Install the Python Lux API through PyPI:
pip install lux-api
Install the Lux Jupyter widget through npm:
npm i lux-widget
Lux is built on the principle that users should always be able to visualize anything they specify, without having to think about how the visualization should look like. Lux automatically determines the mark and channel mappings based on a set of best practices from Tableau. The visualizations are rendered via Altair into Vega-Lite specifications.
import lux # Load a dataset into Lux dataset = lux.Dataset("data/car.csv") dobj = lux.DataObj(dataset,[lux.Column("Acceleration"), lux.Column("Horsepower")])
Search Space Enumeration:
Lux implements a set of enumeration logic that generates a visualization collection based on a partially specified query. Users can provide a list or a wildcard to iterate over combinations of filter or attribute values and quickly browse through large numbers of visualizations. The partial specification is inspired by existing work on query languages for visualization languages, including ZQL and CompassQL.
Here, we want to look at how the attributes
Displacement depend on all other dimension variables.
dobj = lux.DataObj(dataset,[lux.Column(["Weight","Displacement"]),lux.Column("?",dataModel="dimension")])
Lux comes with a set of analytics capabilities. We can compose multiple DataObjects or DataObjectCollections to perform a specified task.
For example, we can ask which car brands have a time series of Displacement similar to that of Pontiac cars.
query = lux.DataObj(dataset,[lux.Column("Year",channel="x"), lux.Column("Displacement",channel="y"), lux.Row("Brand","pontiac")]) dobj = lux.DataObj(dataset,[lux.Column("Year",channel="x"), lux.Column("Displacement",channel="y"), lux.Row("Brand","?")]) result = dobj.similarPattern(query,topK=5)
Lux has an extensible logic that determines the appropriate analytics modules to call based on the user’s current state (i.e., the attributes and values they’re interested in). By calling the
showMore command, Lux guides users to potential next-steps in their exploration.
In this example, the user is interested in
Horsepower, Lux generates three sets of recommendations, organized as separate tabs on the widget.
dobj = lux.DataObj(dataset,[lux.Column("Acceleration",dataModel="measure"), lux.Column("Horsepower",dataModel="measure")]) result = dobj.showMore()
The left-hand side of the widget shows the Current View, which corresponds to the attributes that have been selected. On the right, Lux recommends:
- Enhance: Adds an additional attribute to the current selection
- Filter: Adds a filter to the current selection, while keeping X and Y fixed
- Generalize: Removes an attribute to display a more general trend
Manual Installation (dev)
There are two components of Lux: 1) Python Lux API (this repo)and 2) the Jupyter widget frontend (inside lux-widget).
To install the Python Lux API:
pip install --user -r requirements.txt cd lux/ python setup.py install
To install the widget, we need to install webpack:
npm install --save-dev webpack webpack-cli
Then, we can install the Lux Jupyter widget using the custom installation script:
git clone email@example.com:lux-org/lux-widget.git cd lux-widget/ npm install bash install.sh
For more detailed examples of how to use Lux, check out this demo notebook.
Lux is undergoing active development. Please report any bugs, issues, or requests through Github Issues.