Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recommendation property to LuxSeries objects #266

Merged
merged 4 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lux/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,16 @@ def on_button_clicked(b):
warnings.warn(traceback.format_exc())
display(self.to_pandas())
return ""

@property
def recommendation(self):
from lux.core.frame import LuxDataFrame

if self.name is None:
self.name = " "
ldf = LuxDataFrame(self)

if self._recommendation is not None and self._recommendation == {}:
ldf.maintain_metadata()
ldf.maintain_recs()
return ldf._recommendation
1 change: 0 additions & 1 deletion tests/test_interestingness.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def test_interestingness_0_1_0(global_var):
):
rank3 = f
assert rank1 < rank2 and rank1 < rank3 and rank2 < rank3


# check that top recommended filter graph score is not none and that ordering makes intuitive sense
assert interestingness(df.recommendation["Filter"][0], df) != None
Expand Down
14 changes: 14 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ def test_print_iterrow(global_var):
print(row)
break
assert len(w) == 0, "Warning displayed when printing iterrow"


def test_series_recommendation():
lux.config.plotting_backend = "matplotlib"
df = pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/employee.csv")
df.plot_config = None
df = df["YearsAtCompany"] / df["TotalWorkingYears"]
assert len(df.recommendation["Distribution"]) > 0

lux.config.plotting_backend = "vegalite"
df = pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/employee.csv")
df.plot_config = None
df = df["YearsAtCompany"] / df["TotalWorkingYears"]
assert len(df.recommendation["Distribution"]) > 0