Skip to content

Commit

Permalink
Adding Long Descriptions (#244)
Browse files Browse the repository at this point in the history
* Responding to issue #67, Added color for bar charts.

* Minor: Updated spacing

* Updated BarChar.py to disable legends for basic bar plots

* changing colors for bar charts

* fixing merge error

* started adding in long descriptions

* fixed style

* Changed naming to conform w/ PEP8

* rename

* rename

* Update correlation.py

* Update univariate.py

* made required fields dynamic

* added links

* added to description length
  • Loading branch information
jerrysong1324 committed Feb 17, 2021
1 parent 7a4f769 commit a7b04ba
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lux/action/column_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def column_group(ldf):
recommendation = {
"action": "Column Groups",
"description": "Shows charts of possible visualizations with respect to the column-wise index.",
"long_description": 'A column index can be thought of as an extra column that indicates the values that the user is interested in. \
Lux focuses on visualizing named dataframe indices, i.e., indices with a non-null name property, as a proxy of the attribute \
that the user is interested in or have operated on (e.g., group-by attribute). In particular, dataframes with named indices \
are often pre-aggregated, so Lux visualizes exactly the values that the dataframe portrays. \
<a href="https://lux-api.readthedocs.io/en/latest/source/advanced/indexgroup.html" target="_blank">More details</a>',
}
collection = []
ldf_flat = ldf
Expand Down
8 changes: 8 additions & 0 deletions lux/action/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ def correlation(ldf: LuxDataFrame, ignore_transpose: bool = True):
]
intent.extend(filter_specs)
vlist = VisList(intent, ldf)
examples = ""
if len(vlist) > 1:
measures = vlist[0].get_attr_by_data_model("measure")
if len(measures) >= 2:
examples = f" (e.g., {measures[0].attribute}, {measures[1].attribute})"
recommendation = {
"action": "Correlation",
"description": "Show relationships between two <p class='highlight-descriptor'>quantitative</p> attributes.",
"long_description": f"Correlation searches through all pairwise relationship between two quantitative attributes\
{examples}. The visualizations are ranked from most to least linearly correlated based on \
their Pearson鈥檚 correlation score.",
}
ignore_rec_flag = False
# Doesn't make sense to compute correlation if less than 4 data values
Expand Down
1 change: 1 addition & 0 deletions lux/action/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def custom(ldf):
recommendation = {
"action": "Current Vis",
"description": "Shows the list of visualizations generated based on user specified intent",
"long_description": "Shows the list of visualizations generated based on user specified intent",
}

recommendation["collection"] = ldf.current_vis
Expand Down
2 changes: 2 additions & 0 deletions lux/action/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ def enhance(ldf):
recommendation = {
"action": "Enhance",
"description": f"Augmenting current {intended_attrs} intent with additional attribute.",
"long_description": f"Enhance adds an additional attribute displaying how {intended_attrs} changes with respect to other attributes. Visualizations are ranked based on interestingness. The top 15 visualizations are displayed.",
}
elif len(attr_specs) == 2:
recommendation = {
"action": "Enhance",
"description": f"Further breaking down current {intended_attrs} intent by additional attribute.",
"long_description": f"Enhance adds an additional attribute as the color to break down the {intended_attrs} distribution",
}
# if there are too many column attributes, return don't generate Enhance recommendations
elif len(attr_specs) > 2:
Expand Down
4 changes: 4 additions & 0 deletions lux/action/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def add_filter(ldf):
recommendation = {
"action": "Filter",
"description": f"Changing the <p class='highlight-intent'>{fltr.attribute}</p> filter to an alternative value.",
"long_description": f"Swap out the filter value for {fltr.attribute} to other possible values, while keeping all else the same. Visualizations are ranked based on interestingness",
}
unique_values = ldf.unique_values[fltr.attribute]
filter_values.append(fltr.value)
Expand All @@ -64,6 +65,7 @@ def add_filter(ldf):
recommendation = {
"action": "Filter",
"description": f"Changing the <p class='highlight-intent'>{fltr.attribute}</p> filter to an alternative inequality operation.",
"long_description": f"Changing the <p class='highlight-intent'>{fltr.attribute}</p> filter to an alternative inequality operation.",
}

def get_complementary_ops(fltr_op):
Expand Down Expand Up @@ -99,6 +101,7 @@ def get_complementary_ops(fltr_op):
recommendation = {
"action": "Filter",
"description": f"Applying filters to the <p class='highlight-intent'>{intended_attrs}</p> intent.",
"long_description": f"Adding any filter while keeping the attributes on the x and y axes fixed. Visualizations are ranked based on interestingness",
}
categorical_vars = []
for col in list(ldf.columns):
Expand All @@ -122,6 +125,7 @@ def get_complementary_ops(fltr_op):
recommendation = {
"action": "Similarity",
"description": "Show other charts that are visually similar to the Current vis.",
"long_description": "Show other charts that are visually similar to the Current vis.",
}
last = get_filter_specs(ldf.intent)[-1]
output = ldf.intent.copy()[0:-1]
Expand Down
1 change: 1 addition & 0 deletions lux/action/generalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def generalize(ldf):
recommendation = {
"action": "Generalize",
"description": f"Remove an attribute or filter from {intended_attrs}.",
"long_description": f"Remove one aspect of the Current Vis. We can either remove an attribute or filter from {intended_attrs}.",
}
# to observe a more general trend
# if we do no have enough column attributes or too many, return no vis.
Expand Down
5 changes: 5 additions & 0 deletions lux/action/row_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def row_group(ldf):
recommendation = {
"action": "Row Groups",
"description": "Shows charts of possible visualizations with respect to the row-wise index.",
"long_description": 'A row index can be thought of as an extra row that indicates the values that the user is interested in. \
Lux focuses on visualizing named dataframe indices, i.e., indices with a non-null name property, as a proxy of the attribute \
that the user is interested in or have operated on (e.g., group-by attribute). In particular, dataframes with named indices \
are often pre-aggregated, so Lux visualizes exactly the values that the dataframe portrays. \
<a href="https://lux-api.readthedocs.io/en/latest/source/advanced/indexgroup.html" target="_blank">More details</a>',
}
collection = []

Expand Down
14 changes: 14 additions & 0 deletions lux/action/univariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,40 @@ def univariate(ldf, *args):
]
intent = [lux.Clause(possible_attributes)]
intent.extend(filter_specs)
examples = ""
if len(possible_attributes) >= 1:
examples = f" (e.g., {possible_attributes[0]})"
recommendation = {
"action": "Distribution",
"description": "Show univariate histograms of <p class='highlight-descriptor'>quantitative</p> attributes.",
"long_description": f"Distribution displays univariate histogram distributions of all quantitative attributes{examples}. Visualizations are ranked from most to least skewed.",
}
# Doesn't make sense to generate a histogram if there is less than 5 datapoints (pre-aggregated)
if len(ldf) < 5:
ignore_rec_flag = True
elif data_type_constraint == "nominal":
possible_attributes = [
c
for c in ldf.columns
if ldf.data_type[c] == "nominal" and ldf.cardinality[c] > 5 and c != "Number of Records"
]
examples = ""
if len(possible_attributes) >= 1:
examples = f" (e.g., {possible_attributes[0]})"
intent = [lux.Clause("?", data_type="nominal")]
intent.extend(filter_specs)
recommendation = {
"action": "Occurrence",
"description": "Show frequency of occurrence for <p class='highlight-descriptor'>categorical</p> attributes.",
"long_description": f"Occurence displays bar charts of counts for all categorical attributes{examples}. Visualizations are ranked from most to least uneven across the bars. ",
}
elif data_type_constraint == "temporal":
intent = [lux.Clause("?", data_type="temporal")]
intent.extend(filter_specs)
recommendation = {
"action": "Temporal",
"description": "Show trends over <p class='highlight-descriptor'>time-related</p> attributes.",
"long_description": "Temporal displays line charts for all attributes related to datetimes in the dataframe.",
}
# Doesn't make sense to generate a line chart if there is less than 3 datapoints (pre-aggregated)
if len(ldf) < 3:
Expand Down

0 comments on commit a7b04ba

Please sign in to comment.