lux.executor package

Submodules

lux.executor.Executor module

class lux.executor.Executor.Executor[source]

Bases: object

Abstract class for the execution engine that fetches data for a given vis on a LuxDataFrame

compute_data_model(data_type)[source]
compute_data_model_lookup(data_type)[source]
static compute_data_type(self)[source]
static compute_dataset_metadata(self, ldf)[source]
static compute_stats(self)[source]
static execute(vislist: lux.vis.VisList.VisList, ldf: lux.core.frame.LuxDataFrame, approx: bool = False)[source]

Given a VisList, fetch the data required to render the vis.

static execute_2D_binning(vis: lux.vis.Vis.Vis)[source]

Apply 2D binning (heatmap) to vis.data

static execute_aggregate(vis: lux.vis.Vis.Vis, ldf: lux.core.frame.LuxDataFrame)[source]

Aggregate data points on an axis for bar or line charts

static execute_binning(ldf: lux.core.frame.LuxDataFrame, vis: lux.vis.Vis.Vis)[source]

Binning of data points for generating histograms

static execute_filter(vis: lux.vis.Vis.Vis)[source]

Apply a Vis’s filter to vis.data

invert_data_type(data_type)[source]
mapping(rmap)[source]
reverseMapping(map)[source]

lux.executor.PandasExecutor module

class lux.executor.PandasExecutor.PandasExecutor[source]

Bases: lux.executor.Executor.Executor

Given a Vis objects with complete specifications, fetch and process data using Pandas dataframe operations.

static apply_filter(df: lux.core.frame.LuxDataFrame, attribute: str, op: str, val: object) → lux.core.frame.LuxDataFrame[source]

Helper function for applying filter to a dataframe

Parameters:
  • df (pandas.DataFrame) – Dataframe to filter on
  • attribute (str) – Filter attribute
  • op (str) – Filter operation, ‘=’, ‘<’, ‘>’, ‘<=’, ‘>=’, ‘!=’
  • val (object) – Filter value
Returns:

df – Dataframe resulting from the filter operation

Return type:

pandas.DataFrame

compute_data_type(ldf: lux.core.frame.LuxDataFrame)[source]
compute_dataset_metadata(ldf: lux.core.frame.LuxDataFrame)[source]
compute_stats(ldf: lux.core.frame.LuxDataFrame)[source]
static execute(vislist: lux.vis.VisList.VisList, ldf: lux.core.frame.LuxDataFrame, approx=False)[source]

Given a VisList, fetch the data required to render the vis. 1) Apply filters 2) Retrieve relevant attribute 3) Perform vis-related processing (aggregation, binning) 4) return a DataFrame with relevant results

Parameters:
  • vislist (list[lux.Vis]) – vis list that contains lux.Vis objects for visualization.
  • ldf (lux.core.frame) – LuxDataFrame with specified intent.
Returns:

Return type:

None

static execute_2D_binning(vis: lux.vis.Vis.Vis) → None[source]

Apply 2D binning (heatmap) to vis.data

Parameters:vis (Vis) –
static execute_aggregate(vis: lux.vis.Vis.Vis, isFiltered=True)[source]

Aggregate data points on an axis for bar or line charts

Parameters:
  • vis (lux.Vis) – lux.Vis object that represents a visualization
  • ldf (lux.core.frame) – LuxDataFrame with specified intent.
Returns:

Return type:

None

static execute_approx_sample(ldf: lux.core.frame.LuxDataFrame)[source]

Compute and cache an approximate sample of the overall dataframe for the purpose of early pruning of the visualization search space

Parameters:ldf (LuxDataFrame) –
static execute_binning(ldf: lux.core.frame.LuxDataFrame, vis: lux.vis.Vis.Vis)[source]

Binning of data points for generating histograms

Parameters:
  • vis (lux.Vis) – lux.Vis object that represents a visualization
  • ldf (lux.core.frame) – LuxDataFrame with specified intent.
Returns:

Return type:

None

static execute_filter(vis: lux.vis.Vis.Vis) → bool[source]

Apply a Vis’s filter to vis.data

Parameters:vis (Vis) –
Returns:Boolean flag indicating if any filter was applied
Return type:bool
static execute_sampling(ldf: lux.core.frame.LuxDataFrame)[source]

Compute and cache a sample for the overall dataframe

  • When # of rows exceeds lux.config.sampling_start, take 75% df as sample
  • When # of rows exceeds lux.config.sampling_cap, cap the df at {lux.config.sampling_cap} rows

lux.config.sampling_start = 100k rows lux.config.sampling_cap = 1M rows

Parameters:ldf (LuxDataFrame) –

lux.executor.SQLExecutor module

class lux.executor.SQLExecutor.SQLExecutor[source]

Bases: lux.executor.Executor.Executor

Given a Vis objects with complete specifications, fetch and process data using SQL operations.

compute_data_type(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which the equivalent Pandas data type of each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
compute_dataset_metadata(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which computes the metadata required for the Lux recommendation system. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
compute_stats(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which computes the min and max values for each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
create_where_clause(view='')[source]
static execute(view_collection: lux.vis.VisList.VisList, tbl: lux.core.sqltable.LuxSQLTable, approx: bool = False)[source]

Given a VisList, fetch the data required to render the view 1) Generate Necessary WHERE clauses 2) Query necessary data, applying appropriate aggregation for the chart type 3) populates vis’ data with a DataFrame with relevant results

static execute_2D_binning(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable)[source]

Apply 2D binning (heatmap) to vis.data

static execute_aggregate(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable, isFiltered=True)[source]

Aggregate data points on an axis for bar or line charts :param vis: lux.Vis object that represents a visualization :type vis: lux.Vis :param tbl: LuxSQLTable with specified intent. :type tbl: lux.core.frame :param isFiltered: boolean that represents whether a vis has had a filter applied to its data :type isFiltered: boolean

Returns:
Return type:None
static execute_binning(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable)[source]

Binning of data points for generating histograms :param vis: lux.Vis object that represents a visualization :type vis: lux.Vis :param tbl: LuxSQLTable with specified intent. :type tbl: lux.core.frame

Returns:
Return type:None
static execute_filter(view: lux.vis.Vis.Vis)[source]

Helper function to convert a Vis’ filter specification to a SQL where clause. Takes in a Vis object and returns an appropriate SQL WHERE clause based on the filters specified in the vis’ _inferred_intent.

Parameters:vis (lux.Vis) – lux.Vis object that represents a visualization
Returns:
  • where_clause (string) – String representation of a SQL WHERE clause
  • filter_vars (list of strings) – list of variables that have been used as filters
static execute_preview(tbl: lux.core.sqltable.LuxSQLTable, preview_size=5)[source]
static execute_sampling(tbl: lux.core.sqltable.LuxSQLTable)[source]
static execute_scatter(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable)[source]

Given a scatterplot vis and a Lux Dataframe, fetch the data required to render the vis. 1) Generate WHERE clause for the SQL query 2) Check number of datapoints to be included in the query 3) If the number of datapoints exceeds 10000, perform a random sample from the original data 4) Query datapoints needed for the scatterplot visualization 5) return a DataFrame with relevant results

Parameters:
  • vislist (list[lux.Vis]) – vis list that contains lux.Vis objects for visualization.
  • tbl (lux.core.frame) – LuxSQLTable with specified intent.
Returns:

Return type:

None

get_SQL_attributes(tbl: lux.core.sqltable.LuxSQLTable)[source]

Retrieves the names of variables within a specified Lux DataFrame’s Postgres SQL table. Uses these variables to populate the Lux DataFrame’s columns list.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose columns will be populated
Returns:
Return type:None
get_cardinality(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which computes the cardinality for each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
get_filtered_size(tbl)[source]
get_unique_values(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which collects the unique values for each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None

Module contents