specifying appropriate arguments for catalog_data and catalog_formula have no impact on the returned value of sar()
. The issue is an assignment in the main sar.default()
. Fix inc.
data(ms_usage)
data(ms_catalog)
## create some feature variables
ms_catalog$ms <- grepl("microsoft", ms_catalog$name, ignore.case=TRUE)
ms_catalog$surf <- grepl("surface", ms_catalog$name, ignore.case=TRUE)
## create several different SAR models
mod0 <- sar(ms_usage, support_threshold=25)
mod1 <- sar(ms_usage, support_threshold=25, catalog_data=ms_catalog, catalog_formula=f, cold_item_model=NULL)
mod2 <- sar(ms_usage, support_threshold=25, catalog_data=ms_catalog, catalog_formula=f, cold_item_model=NULL,
cold_to_cold=TRUE)
mod3 <- sar(ms_usage, support_threshold=25, catalog_data=ms_catalog, catalog_formula=f, cold_item_model="lm")
mod4 <- sar(ms_usage, support_threshold=25, catalog_data=ms_catalog, catalog_formula=f, cold_item_model="lm",
cold_to_cold=TRUE)
## all the similarity matrices are the same
all(mod0$sim_mat == mod1$sim_mat)
all(mod0$sim_mat == mod2$sim_mat)
all(mod0$sim_mat == mod3$sim_mat)
all(mod0$sim_mat == mod4$sim_mat)
## do one comparison by hand:
sim_onlywarm = SAR:::make_similarity(ms_usage$user, factor(ms_usage$item), ms_usage$time, 25, by_user=TRUE, similarity='jaccard')
## augment with cold items to mirror model1
f <- reformulate(names(ms_catalog)[-(1:2)])
sim_withcold1 <- SAR:::get_cold_similarity(cold_item_model=NULL, sim_matrix=sim_onlywarm, catalog_formula=f, catalog_data=ms_catalog, cold_to_cold=FALSE,
similarity='jaccard')
## this is still TRUE
all(mod1$sim_mat == sim_onlywarm)
## it SHOULD be FALSE:
all(sim_withcold1 == sim_onlywarm)