<jupyter_start><jupyter_text>Load Overall Database<jupyter_code>engine = create_engine("sqlite:///../../recommender.db", echo=True)
demo_engine = create_engine("sqlite:///../../recommender_demo.db", echo=True)<jupyter_output><empty_output><jupyter_text>Load `Pet_Supplies` Data<jupyter_code>query = f"SELECT * FROM Pet_Supplies;"
pet_supplies = pd.read_sql(query, engine)
# check number of rows
pet_supplies.shape
# check results
pet_supplies.head()
# random sample 100 users
ps_sampled_users = pet_supplies["reviewerID"].sample(100).tolist()
# sub-select only sampled users for demo
pet_supplies_demo = pet_supplies[pet_supplies.reviewerID.isin(ps_sampled_users)]
# check dataframe
pet_supplies_demo
# save to demo db
pet_supplies_demo.to_sql("Pet_Supplies", con=demo_engine, if_exists="append")<jupyter_output>2021-10-22 20:44:00,118 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("Pet_Supplies")
2021-10-22 20:44:00,119 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-10-22 20:44:00,120 INFO sqlalchemy.engine.Engine PRAGMA temp.table_info("Pet_Supplies")
2021-10-22 20:44:00,121 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-10-22 20:44:00,125 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2021-10-22 20:44:00,126 INFO sqlalchemy.engine.Engine 
CREATE TABLE "Pet_Supplies" (
	level_0 BIGINT, 
	"index" BIGINT, 
	"reviewerID" TEXT, 
	item_rank BIGINT, 
	asin TEXT, 
	algorithm TEXT, 
	title TEXT
)


2021-10-22 20:44:00,128 INFO sqlalchemy.engine.Engine [no key 0.00165s] ()
2021-10-22 20:44:00,132 INFO sqlalchemy.engine.Engine CREATE INDEX "ix_Pet_Supplies_level_0" ON "Pet_Supplies" (level_0)
2021-10-22 20:44:00,133 INFO sqlalchemy.engine.Engine [no key 0.00168s] ()
2021-10-22 20:44:00,136 INFO sqlalchemy.engine.Engine COMMIT
2021-10-22 20:44:00,145 INFO sqlalchemy.engine.Engine BEGIN (implici[...]<jupyter_text>Load `Grocery_and_Gourmet_Food` Data<jupyter_code>query = f"SELECT * FROM Grocery_and_Gourmet_Food;"
grocery_gourmet_food = pd.read_sql(query, engine)
# check number of rows
grocery_gourmet_food.shape
# check results
grocery_gourmet_food.head()
# random sample 100 users
# keeping the users we used in our report analysis as well
ggf_sampled_users = grocery_gourmet_food["reviewerID"].sample(99).tolist() + ['A2DSXA1E02C86D']
# sub-select only sampled users for demo
grocery_gourmet_food_demo = grocery_gourmet_food[grocery_gourmet_food.reviewerID.isin(ggf_sampled_users)]
# check dataframe
grocery_gourmet_food_demo
# save to demo db
grocery_gourmet_food_demo.to_sql("Grocery_and_Gourmet_Food", con=demo_engine, if_exists="append")<jupyter_output>2021-10-22 20:44:07,175 INFO sqlalchemy.engine.Engine PRAGMA main.table_info("Grocery_and_Gourmet_Food")
2021-10-22 20:44:07,175 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-10-22 20:44:07,176 INFO sqlalchemy.engine.Engine PRAGMA temp.table_info("Grocery_and_Gourmet_Food")
2021-10-22 20:44:07,177 INFO sqlalchemy.engine.Engine [raw sql] ()
2021-10-22 20:44:07,179 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2021-10-22 20:44:07,180 INFO sqlalchemy.engine.Engine 
CREATE TABLE "Grocery_and_Gourmet_Food" (
	level_0 BIGINT, 
	"index" BIGINT, 
	"reviewerID" TEXT, 
	item_rank BIGINT, 
	asin TEXT, 
	algorithm TEXT, 
	title TEXT
)


2021-10-22 20:44:07,181 INFO sqlalchemy.engine.Engine [no key 0.00067s] ()
2021-10-22 20:44:07,184 INFO sqlalchemy.engine.Engine CREATE INDEX "ix_Grocery_and_Gourmet_Food_level_0" ON "Grocery_and_Gourmet_Food" (level_0)
2021-10-22 20:44:07,185 INFO sqlalchemy.engine.Engine [no key 0.00100s] ()
2021-10-22 20:44:07,187 INFO sqlalchemy.engine.Engine COMMIT
2021-10-[...]
{'fraction_non_alphanumeric': 0.11941964285714286, 'fraction_numerical': 0.11439732142857142, 'mean_word_length': 6.579281183932347, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '82618', 'license': 'MIT', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1386, 'n_words': 265, 'path': 'notebooks/exploratory/10-lwt-generate-streamlit-demo-db.ipynb', 'repo_name': 'wtlow003/recommendation-systems', 'size': '3584'}