Skip to content

KupaMakunura/movie-recommender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Certainly! Here's an example of how you can write a README markdown file for your movie recommendation system:

Movie Recommendation System

This is a movie recommendation system based on content similarity using the TfidfVectorizer and linear_kernel from the scikit-learn library. The system uses movie overviews to calculate the similarity between movies and provides recommendations based on that similarity.

Prerequisites

Make sure you have the following dependencies installed:

  • pandas
  • scikit-learn

Getting Started

  1. Clone the repository and navigate to the project directory.

  2. Download the dataset files tmdb_5000_movies.csv and tmdb_5000_credits.csv.

  3. Install the required dependencies using the following command:

    pip install pandas scikit-learn
    
  4. Open the Python script and import the necessary libraries:

    import pandas as pd
    from sklearn.feature_extraction.text import TfidfVectorizer
    from sklearn.metrics.pairwise import linear_kernel
  5. Load the movie dataset and credit dataset into pandas DataFrames:

    df_movies = pd.read_csv('tmdb_5000_movies.csv')
    df_credits = pd.read_csv('tmdb_5000_credits.csv')
  6. Preprocess the data by filling any missing values in the "overview" column:

    df_movies['overview'] = df_movies['overview'].fillna('')
  7. Create a TF-IDF matrix using the movie overviews:

    tfidf = TfidfVectorizer(stop_words='english')
    tfidf_matrix = tfidf.fit_transform(df_movies['overview'])
  8. Compute the cosine similarity matrix:

    cosine_sim = linear_kernel(tfidf_matrix)
  9. Build a mapping of movie titles to their corresponding indices in the DataFrame:

    indices = pd.Series(df_movies.index, index=df_movies['original_title']).drop_duplicates()
  10. Define a function to get movie recommendations based on a given movie title:

    def get_recommendations(movie_title, input_cosine_sim=cosine_sim):
        ind = indices[movie_title]
        sim_score = enumerate(cosine_sim[ind])
        sim_score = sorted(sim_score, key=lambda x: x[1], reverse=True)
        sim_score = sim_score[1:11]
        sim_index = [i[0] for i in sim_score]
        print(df_movies["original_title"].iloc[sim_index])
  11. Finally, call the get_recommendations function with a movie title to get recommendations:

    get_recommendations(movie_title='Batman v Superman: Dawn of Justice')

Conclusion

This movie recommendation system uses content similarity to provide recommendations based on movie overviews. By calculating the cosine similarity between movies, the system identifies similar movies and suggests a list of recommendations. Feel free to explore and modify the code to suit your needs!

For more information on the functions and classes used in this system, refer to the documentation of the respective libraries:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published