A Python API for Intelligent Data Discovery
A Python API for Intelligent Visual Discovery
Lux is a Python library that facilitate fast and easy data exploration by automating the visualization and data analysis process. By simply printing out a dataframe in a Jupyter notebook, Lux recommends a set of visualizations highlighting interesting trends and patterns in the dataset. Visualizations are displayed via an interactive widget that enables users to quickly browse through large collections of visualizations and make sense of their data.
To start using Lux, simply add an extra import statement along with your Pandas import.
import lux import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/college.csv") df
When the dataframe is printed out, Lux automatically recommends a set of visualizations highlighting interesting trends and patterns in the dataset.
Voila! Here's a set of visualizations that you can now use to explore your dataset further!
Next-step recommendations based on user intent:
In addition to dataframe visualizations at every step in the exploration, you can specify to Lux the attributes and values you're interested in. Based on this intent, Lux guides users towards potential next-steps in their exploration.
For example, we might be interested in the attributes
df.intent = ["AverageCost","SATAverage"] df
The left-hand side of the widget shows the current visualization, i.e., the current visualization generated based on what the user is interested in. On the right, Lux generates three sets of recommendations, organized as separate tabs on the widget:
Enhanceadds an additional attribute to the current selection, essentially highlighting how additional variables affect the relationship of
SATAverage. We see that if we breakdown the relationship by
FundingModel, there is a clear separation between public colleges (shown in red) and private colleges (in blue), with public colleges being cheaper to attend and with SAT average of lower than 1400.
Filteradds a filter to the current selection, while keeping attributes (on the X and Y axes) fixed. These visualizations show how the relationship of
SATAveragechanges for different subsets of data. For instance, we see that colleges that offer Bachelor's degree as its highest degree show a roughly linear trend between the two variables.
Generalizeremoves an attribute to display a more general trend, showing the distributions of
SATAverageon its own. From the
AverageCosthistogram, we see that many colleges with average cost of around $20000 per year, corresponding to the bulge we see in the scatterplot view.
See this page for more information on additional ways for specifying the intent.
Easy programmatic access and export of visualizations:
Now that we have found some interesting visualizations through Lux, we might be interested in digging into these visualizations a bit more or sharing it with others. We can save the visualizations generated in Lux as a static, shareable HTML or programmatically access these visualizations further in Jupyter. Selected
Vis objects can be translated into Altair, Matplotlib, or Vega-Lite code, so that they can be further edited.
Learn more about how to save and export visualizations here.
Quick, on-demand visualizations with the help of automatic encoding:
We've seen how
Viss are automatically generated as part of the recommendations. Users can also create their own Vis via the same syntax as specifying the intent. Lux is built on the philosophy that users should always be able to visualize anything they want, 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. The visualizations are rendered via Altair into Vega-Lite specifications.
from lux.vis.Vis import Vis Vis(["Region=New England","MedianEarnings"],df)
Powerful language for working with collections of visualizations:
Lux provides a powerful abstraction for working with collections of visualizations based on a partially specified queries. 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 visualization query languages, including ZQL and CompassQL.
For example, we are interested in how the
AverageCost distribution differs across different
from lux.vis.VisList import VisList VisList(["Region=?","AverageCost"],df)
To find out more about other features in Lux, see the complete documentation on ReadTheDocs.
Installation & Setup
pip install lux-api
If you use conda, you can install
conda install -c conda-forge lux-api
Both the PyPI and conda installation include includes the Lux Jupyter widget frontend, lux-widget.
Setup in Jupyter Notebook, VSCode, JupyterHub
jupyter nbextension install --py luxwidget jupyter nbextension enable --py luxwidget
If the installation happens correctly, you should see two
- Validating: OK after executing the two lines above.
Note that you may have to restart the Jupyter Notebook server to ensure that the widget is displaying correctly.
Setup in Jupyter Lab
Lux is compatible with both Jupyter Lab version 2 and 3. To use Lux in Jupyter Lab, activate the lab extension:
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install luxwidget
Note that JupyterLab and VSCode is supported only for lux-widget version >=0.1.2, if you have an earlier version, please upgrade to the latest version of lux-widget. Lux has only been tested with the Chrome browser.
Support and Resources
Lux is undergoing active development. If you are interested in using Lux, we would love to hear from you. Any feedback, suggestions, and contributions for improving Lux are welcome.
Other additional resources:
- Follow us on Twitter or sign up to our mailing list to stay tuned for upcoming releases and updates.
- Visit ReadTheDoc for more detailed documentation.
- Try out these hands-on exercises or tutorials on Binder. Or clone and run lux-binder locally.
- Join our community Slack to discuss and ask questions.
- Report any bugs, issues, or requests through Github Issues.
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size lux-api-0.3.0.tar.gz (111.4 kB)||File type Source||Python version None||Upload date||Hashes View|