class_docstr: Integration with polar based popularity recommender.
code: def predict(self, df=None, args: Optional[dict] = None):
      args = self.model_storage.json_get("args")
      popularity = self.model_storage.json_get("popularity")
      interaction = dill.loads(
          self.model_storage.file_get("interaction")
      )
  
      global_popularity = [*popularity.values()][1]
  
      if df is not None:
          # get recommendations for specific users if specified
          user_ids = df[args["user_id"]].unique().tolist()
  
          interaction_data = pl.from_pandas(interaction).filter(
              pl.col(args["user_id"]).is_in(user_ids)
          )
  
      else:
          # get recommendations for all users
          interaction_data = pl.from_pandas(interaction)
  
      # aggregate over user
      interacted_items = (
          interaction_data.groupby(args["user_id"])
          .agg(pl.col(args["item_id"]).alias("items"))
          .with_columns(
              pl.lit([global_popularity]).alias("popular_items"),
          )
      ).lazy()
  
      df = (
          (
              interacted_items.join(
                  (
                      interacted_items.explode("popular_items")
                      .filter(
                          pl.col("popular_items")
                          .is_in("items")
                          .is_not()
                      )
                      .groupby(args["user_id"])
                      .agg(recommended="popular_items")
                  ),
                  on=args["user_id"],
              ).select(
                  [
                      pl.col(args["user_id"]),
                      pl.col("recommended").list.head(
                          args["n_recommendations"]
                      ),
                  ]
              )
          )
          .explode("recommended")
          .collect()
          .to_pandas()
      )
  
      return df
  
file_path: mindsdb/mindsdb/integrations/handlers/popularity_recommender_handler/popularity_recommender_handler.py
imports: from typing import Dict, Optional
  import dill
  import pandas
  import polars
  from mindsdb.integrations.libs.base import BaseMLEngine
label_desc: Use image node_id 2 for calling the PopularityRecommenderHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: df