Package: lux
A Python API for Intelligent Visual DiscoveryLux 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 viaan interactive widgetthat enables users to quickly browse through large collections of visualizations and make sense of their data.Here is a1-min videointroducing Lux, andslidesfrom a more extended talk.Check out ournotebook gallerywith examples of how Lux can be used with different datasets and analyses.Or try out Lux on your own in alive Jupyter Notebook!Getting StartedTo start using Lux, simply add an extra import statement along with your Pandas import.importluximportpandasaspdLux can be used without modifying any existing Pandas code. Here, we use Pandas'sread_csvcommand to load in adataset of collegesand their properties.df=pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/college.csv")dfWhen 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 attributesAverageCostandSATAverage.df.intent=["AverageCost","SATAverage"]dfThe 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 ofAverageCostandSATAverage. We see that if we breakdown the relationship byFundingModel, 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 ofAverageCostandSATAveragechanges 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 ofAverageCostandSATAverageon its own. From theAverageCosthistogram, we see that many colleges with average cost of around $20000 per year, corresponding to the bulge we see in the scatterplot view.Seethis pagefor 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 astatic, shareable HTMLor programmatically access these visualizations further in Jupyter. SelectedVisobjects can be translated intoAltair,Matplotlib, orVega-Litecode, so that they can be further edited.Learn more about how to save and export visualizationshere.Quick, on-demand visualizations with the help of automatic encoding:We've seen howViss 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 abouthowthe visualization should look like. Lux automatically determines the mark and channel mappings based on a set ofbest practices. The visualizations are rendered viaAltairintoVega-Litespecifications.fromlux.vis.VisimportVisVis(["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, includingZQLandCompassQL.For example, we are interested in how theAverageCostdistribution differs across differentRegions.fromlux.vis.VisListimportVisListVisList(["Region=?","AverageCost"],df)To find out more about other features in Lux, see the complete documentation onReadTheDocs.Installation & SetupNote: After installing the package, remember to run the setup instructions for your notebook IDE, e.g.,jupyter notebookandjupyter lab.To get started, please follow both the installation and setup instructions in your command line.luxcan be installed throughPyPIorconda-forge.pipinstallluxIf you useconda, you can installluxvia:condainstall-cconda-forgeluxBoth the PyPI and conda installation include includes the Lux Jupyter widget frontend,lux-widget.Setup in Jupyter Notebook, VSCode, JupyterHubTo use Lux with any Jupyter notebook-based frontends (e.g.,Jupyter notebook,JupyterHub, orVSCode), activate the notebook extension:jupyternbextensioninstall--pyluxwidget
jupyternbextensionenable--pyluxwidgetIf the installation happens correctly, you should see two- Validating: OKafter 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 LabLux is compatible with both Jupyter Lab version 2 and 3. To use Lux inJupyter Lab, activate the lab extension:jupyterlabextensioninstall@jupyter-widgets/jupyterlab-manager
jupyterlabextensioninstallluxwidgetNote 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 oflux-widget. Lux has only been tested with the Chrome browser.If you encounter issues with the installation, please refer tothis pageto troubleshoot the installation. Followthese instructionsto set up Lux for development purposes.Support and ResourcesLux is undergoing active development. If you are using Lux, we would love to hear from you!Drop us a notehereto share your experiences — any feedback, suggestions, and contributions are welcome!Links to additional resources:Follow us onTwitteror sign up to ourmailing listto stay tuned for upcoming releases and updates.VisitReadTheDocfor more detailed documentation.Try out these hands-onexercisesortutorialsonBinder. Or clone and runlux-binderlocally.Join our communitySlackto discuss and ask questions.Check outour paperfor more details on how Lux works under the hoods.Report any bugs, issues, or requests throughGithub Issues.