-
Notifications
You must be signed in to change notification settings - Fork 48
if column.model not provided in visual app then set default model name #235
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,6 +29,7 @@ | |||||
MIN_WIDTH_LIMIT = 10 | ||||||
REQUEST_NAMES_COL = "request_name" | ||||||
REQUEST_IDS_COL = "request_id" | ||||||
DEFAULT_MODEL_NAME = "model1" | ||||||
blondered marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
VisualAppT = tp.TypeVar("VisualAppT", bound="VisualAppBase") | ||||||
|
||||||
|
@@ -71,7 +72,8 @@ def from_raw( | |||||
---------- | ||||||
reco : tp.Union[pd.DataFrame, TablesDict] | ||||||
Recommendations from different models in a form of a pd.DataFrame or a dict. | ||||||
In DataFrame form model names must be specified in `Columns.Model` column. In dict form | ||||||
In DataFrame form model names must be specified in `Columns.Model` column. | ||||||
If not, `Columns.Model` column will be created with default value ``model1``. In dict form | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
model names are supposed to be dict keys. | ||||||
item_data : pd.DataFrame | ||||||
Data for items that is used for visualisation in both interactions and recommendations | ||||||
|
@@ -100,7 +102,7 @@ def from_raw( | |||||
|
||||||
if isinstance(reco, pd.DataFrame): | ||||||
if Columns.Model not in reco.columns: | ||||||
raise KeyError("Missing `{Columns.Model}` column in `reco` DataFrame") | ||||||
reco[Columns.Model] = DEFAULT_MODEL_NAME | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, please add a warning here
|
||||||
reco = cls._df_to_tables_dict(reco, Columns.Model) | ||||||
cls._check_columns_present_in_reco(reco=reco, id_col=id_col) | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ | |
INTERACTIONS = pd.DataFrame({Columns.User: [1, 1, 2], Columns.Item: [3, 7, 8]}) | ||
SELECTED_REQUESTS_U2I: tp.Dict[tp.Hashable, tp.Hashable] = {"user_one": 1, "user_three": 3} | ||
SELECTED_REQUESTS_I2I: tp.Dict[tp.Hashable, tp.Hashable] = {"item_three": 3} | ||
|
||
DEFAULT_MODEL_NAME = "model1" | ||
blondered marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def check_data_storages_equal(one: AppDataStorage, two: AppDataStorage) -> None: | ||
assert one.id_col == two.id_col | ||
|
@@ -229,17 +229,17 @@ def test_missing_columns_validation(self) -> None: | |
) | ||
|
||
# Missing `Columns.Model` in reco pd.DataFrame | ||
with pytest.raises(KeyError): | ||
incorrect_reco = pd.DataFrame( | ||
{Columns.User: [1, 2, 3, 4], Columns.Item: [3, 4, 3, 4], Columns.Score: [0.99, 0.9, 0.5, 0.5]} | ||
) | ||
AppDataStorage.from_raw( | ||
reco=incorrect_reco, | ||
item_data=ITEM_DATA, | ||
interactions=INTERACTIONS, | ||
is_u2i=True, | ||
selected_requests=SELECTED_REQUESTS_U2I, | ||
) | ||
incorrect_reco = pd.DataFrame( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this to a separate test with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, there is my suggestion, how to name this test - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! Could you please name it I also added a few more comments. And we will be ready to merge. |
||
{Columns.User: [1, 2, 3, 4], Columns.Item: [3, 4, 3, 4], Columns.Score: [0.99, 0.9, 0.5, 0.5]} | ||
) | ||
ads = AppDataStorage.from_raw( | ||
reco=incorrect_reco, | ||
item_data=ITEM_DATA, | ||
interactions=INTERACTIONS, | ||
is_u2i=True, | ||
selected_requests=SELECTED_REQUESTS_U2I, | ||
) | ||
assert "model1" in ads.model_names | ||
|
||
def test_incorrect_interactions_for_reco_case(self) -> None: | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.