Eric Hierholzer commited on
Commit
acbf545
·
1 Parent(s): 47952e3
Files changed (2) hide show
  1. recommend_app.py +1 -1
  2. recommendation_engine.py +1 -1
recommend_app.py CHANGED
@@ -25,7 +25,7 @@ app = Flask(__name__, static_folder='static')
25
  # Load data and model at startup
26
  try:
27
  df = load_and_preprocess_data("netflix_titles.csv")
28
- _, cosine_sim_matrix, title_to_index = build_or_load_model(df, "cosine_sim_cache.pkl")
29
  logger.info("Application started successfully with data and model loaded.")
30
  except Exception as e:
31
  logger.error(f"Startup failed: {str(e)}")
 
25
  # Load data and model at startup
26
  try:
27
  df = load_and_preprocess_data("netflix_titles.csv")
28
+ _, cosine_sim_matrix, title_to_index = build_or_load_model(df, "/tmp/cosine_sim_cache.pkl")
29
  logger.info("Application started successfully with data and model loaded.")
30
  except Exception as e:
31
  logger.error(f"Startup failed: {str(e)}")
recommendation_engine.py CHANGED
@@ -50,7 +50,7 @@ def load_and_preprocess_data(csv_file="netflix_titles.csv"):
50
  logger.error(f"Error loading data from {csv_file}: {str(e)}")
51
  raise Exception(f"Error loading data: {str(e)}")
52
 
53
- def build_or_load_model(df, cache_file="cosine_sim_cache.pkl"):
54
  """Builds or loads TF-IDF matrix and cosine similarity, with caching."""
55
  if os.path.exists(cache_file):
56
  try:
 
50
  logger.error(f"Error loading data from {csv_file}: {str(e)}")
51
  raise Exception(f"Error loading data: {str(e)}")
52
 
53
+ def build_or_load_model(df, cache_file="/tmp/cosine_sim_cache.pkl"):
54
  """Builds or loads TF-IDF matrix and cosine similarity, with caching."""
55
  if os.path.exists(cache_file):
56
  try: