Skip to content

Commit

Permalink
Add recommendation property to LuxSeries objects (#266)
Browse files Browse the repository at this point in the history
* rec series

* rec

* rm

* fix test

Co-authored-by: Caitlyn Chen <caitlynachen@berkeley.edu>
  • Loading branch information
caitlynachen and Caitlyn Chen committed Feb 17, 2021
1 parent a7b04ba commit dfb6ecf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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
7 changes: 7 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ def test_print_iterrow(global_var):
print(row)
break
assert len(w) == 0, "Warning displayed when printing iterrow"


def test_series_recommendation():
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, "Recommendation property empty for LuxSeries"

0 comments on commit dfb6ecf

Please sign in to comment.