code: import lancedb
  
  import numpy as np
  import pandas as pd
  
  global data
  data = []
  global table
  table = None
  
  
  def get_recommendations(title):
      pd_data = pd.DataFrame(data)
      # Table Search
      result = (
          table.search(pd_data[pd_data["title"] == title]["vector"].values[0])
          .limit(5)
          .to_pandas()
      )
  
      # Get IMDB links
      links = pd.read_csv(
          "./ml-latest-small/links.csv",
          header=0,
          names=["movie id", "imdb id", "tmdb id"],
          converters={"imdb id": str},
      )
  
      ret = result["title"].values.tolist()
      # Loop to add links
      for i in range(len(ret)):
          link = links[links["movie id"] == result["id"].values[i]]["imdb id"].values[0]
          link = "https://www.imdb.com/title/tt" + link
          ret[i] = [ret[i], link]
      return ret
  
  
  if __name__ == "__main__":
      # Load and prepare data
      ratings = pd.read_csv(
          "./ml-latest-small/ratings.csv",
          header=None,
          names=["user id", "movie id", "rating", "timestamp"],
      )
      ratings = ratings.drop(columns=["timestamp"])
      ratings = ratings.drop(0)
      ratings["rating"] = ratings["rating"].values.astype(np.float32)
      ratings["user id"] = ratings["user id"].values.astype(np.int32)
      ratings["movie id"] = ratings["movie id"].values.astype(np.int32)
  
      reviewmatrix = ratings.pivot(
          index="user id", columns="movie id", values="rating"
      ).fillna(0)
  
      # SVD
      matrix = reviewmatrix.values
      u, s, vh = np.linalg.svd(matrix, full_matrices=False)
  
      vectors = np.rot90(np.fliplr(vh))
  
      # Metadata
      movies = pd.read_csv(
          "./ml-latest-small/movies.csv", header=0, names=["movie id", "title", "genres"]
      )
      movies = movies[movies["movie id"].isin(reviewmatrix.columns)]
  
      data = []
      for i in range(len(movies)):
          data.append(
              {
                  "id": movies.iloc[i]["movie id"],
                  "title": movies.iloc[i]["title"],
                  "vector": vectors[i],
                  "genre": movies.iloc[i]["genres"],
              }
          )
  
      # Connect to LanceDB
      db_url = "your-project-name"
      api_key = "sk_..."
      region = "us-east-1"
  
      db = lancedb.connect(db_url, api_key=api_key, region=region)
      try:
          table = db.create_table("movie_set", data=data)
      except:
          table = db.open_table("movie_set")
  
      print(get_recommendations("Moana (2016)"))
      print(get_recommendations("Rogue One: A Star Wars Story (2016)"))
  
apis: lancedb.connect
extract_api: [((152, 170), 'pandas.DataFrame', 'pd.DataFrame', (['data'], {}), '(data)\n', (164, 170), True, 'import pandas as pd\n'), ((361, 488), 'pandas.read_csv', 'pd.read_csv', (['"""./ml-latest-small/links.csv"""'], {'header': '(0)', 'names': "['movie id', 'imdb id', 'tmdb id']", 'converters': "{'imdb id': str}"}), "('./ml-latest-small/links.csv', header=0, names=['movie id',\n    'imdb id', 'tmdb id'], converters={'imdb id': str})\n", (372, 488), True, 'import pandas as pd\n'), ((880, 995), 'pandas.read_csv', 'pd.read_csv', (['"""./ml-latest-small/ratings.csv"""'], {'header': 'None', 'names': "['user id', 'movie id', 'rating', 'timestamp']"}), "('./ml-latest-small/ratings.csv', header=None, names=['user id',\n    'movie id', 'rating', 'timestamp'])\n", (891, 995), True, 'import pandas as pd\n'), ((1480, 1522), 'numpy.linalg.svd', 'np.linalg.svd', (['matrix'], {'full_matrices': '(False)'}), '(matrix, full_matrices=False)\n', (1493, 1522), True, 'import numpy as np\n'), ((1591, 1687), 'pandas.read_csv', 'pd.read_csv', (['"""./ml-latest-small/movies.csv"""'], {'header': '(0)', 'names': "['movie id', 'title', 'genres']"}), "('./ml-latest-small/movies.csv', header=0, names=['movie id',\n    'title', 'genres'])\n", (1602, 1687), True, 'import pandas as pd\n'), ((2178, 2233), 'lancedb.connect', 'lancedb.connect', (['db_url'], {'api_key': 'api_key', 'region': 'region'}), '(db_url, api_key=api_key, region=region)\n', (2193, 2233), False, 'import lancedb\n'), ((1547, 1560), 'numpy.fliplr', 'np.fliplr', (['vh'], {}), '(vh)\n', (1556, 1560), True, 'import numpy as np\n')]