0% found this document useful (0 votes)
26 views34 pages

The Movie Recommendation

The document outlines the development of an AI-based movie recommendation system using Django, focusing on personalized suggestions through user input and voice interaction. It discusses the challenges faced in existing systems, the proposed architecture, and the integration of machine learning for real-time predictions. The project aims to enhance user experience by providing intuitive interfaces and leveraging AI technologies like NLP and chatbots.

Uploaded by

Abi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views34 pages

The Movie Recommendation

The document outlines the development of an AI-based movie recommendation system using Django, focusing on personalized suggestions through user input and voice interaction. It discusses the challenges faced in existing systems, the proposed architecture, and the integration of machine learning for real-time predictions. The project aims to enhance user experience by providing intuitive interfaces and leveraging AI technologies like NLP and chatbots.

Uploaded by

Abi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Title: AI-Based Movie Recommendation System Using

Django
Table of content
Abstract
1. Chapter 1: Introduction
○ 1.1 Background
○ 1.2 Problem Statement
○ 1.3 Objectives
○ 1.4 Scope of the Project
2. Chapter 2: Literature Survey
○ 2.1 Challenges in Movie Recommendation
○ 2.2 AI and NLP in Recommendation Engines
○ 2.3 Existing Systems and Limitations
○ 2.4 Related Work
3. Chapter 3: System Analysis
○ 3.1 Existing System
○ 3.2 Proposed System
○ 3.3 Feasibility Study
○ 3.4 Requirements Analysis
■ 3.4.1 Functional Requirements
■ 3.4.2 Non-Functional Requirements
4. Chapter 4: System Design
○ 4.1 System Architecture
○ 4.2 Use Case Diagram
○ 4.3 Data Flow Diagram
4.4 UI Design
5. Chapter 5: Implementation
○ 5.1 Technology Stack
○ 5.2 Use Authentication
○ 5.3 Chatbot and Genre Classifier
○ 5.4 Voice Integration
○ 5.5 Result Display and Navigation
6. Chapter 6: Results and Discussion
○ 6.1 Output Screenshots
○ 6.2 Chatbot Interaction Flow
○ 6.3 Recommendation Accuracy
○ 6.4 User Feedback
7. Chapter 7: Conclusion and Future Work
○ 7.1 Conclusion
○ 7.3 Limitations
○ 7.2 Future Enhancements
8. References

Chapter 1: Introduction

1.1 Background

Movies are a powerful medium of entertainment and education, consumed by billions globally. With the
explosion of content on platforms like Netflix, Amazon Prime, and YouTube, users are often overwhelmed
by choice. Hence, personalized movie recommendation systems have become increasingly valuable in
guiding users to discover relevant content efficiently.

The convergence of Artificial Intelligence, Natural Language Processing (NLP), and web development has
enabled the creation of intelligent recommendation systems that can suggest movies based on user
preferences, search history, or genre interests. This project presents a web-based AI-powered Movie
Recommendation System, developed using Django, that allows users to input movie titles, receive auto-
suggestions, interact with a genre-specific chatbot, and even use voice-based input for convenience.

1.2 Problem Statement

With a massive and ever-growing movie database, users often face decision fatigue when choosing what to
watch. Most existing platforms provide limited recommendation logic or require sign-in history.
Additionally, non-technical users may prefer voice-based and intuitive chatbot interfaces to search for
movies.

Problem Statement: “To design and implement an AI-based movie recommendation system that provides
personalized suggestions based on user input, genre preferences, and natural voice or text interaction
through a Django-based web platform.”

1.3 Objectives

● To develop a Django-based web application for recommending movies


● To implement a dynamic search with real-time suggestions using JavaScript
● To build a simple AI chatbot for genre-based movie recommendation
● To integrate voice recognition for voice-based movie search
● To provide an intuitive and responsive UI using Tailwind CSS

1.4 Scope of the Project

In Scope:

● Static and rule-based movie recommendation chatbot


● Movie auto-suggestion system
● Voice input using Web Speech API
● Chat interface and Tailwind-based UI

Out of Scope:

● Deep collaborative filtering algorithms


● Real-time sentiment analysis or live user profiling
● Large-scale movie dataset scraping or ML training

Chapter 2: Literature Survey

2.1 Challenges in Movie Recommendation

Movie recommendation systems must overcome the following challenges:

● Cold start problem: When a user or movie has no history


● Scalability: Handling large datasets and real-time suggestions
● User diversity: Accounting for different genre preferences
● Contextual understanding: Interpreting vague or varied user inputs

These issues necessitate intelligent filtering and user-friendly interfaces.

2.2 AI and NLP in Recommendation Engines

AI-based recommendation systems leverage:

● Content-based filtering: Using movie attributes (genre, actor, director)


● Collaborative filtering: Using similar user preferences
● NLP: Understanding and interpreting user input
● Chatbots: Simulating conversation to capture user intent
● Speech Recognition: Accepting natural language voice input

Libraries like Scikit-Learn, OpenAI models, or NLP frameworks such as spaCy, Rasa, and Hugging Face
Transformers help power these systems.

2.3 Existing Systems and Limitations

Popular platforms like Netflix, IMDB, and Letterboxd offer recommendations, but:

● They often require login or profile history


● Chatbots are rarely integrated with genre-based response flows
● Voice input is not widely available in web-based movie portals
● Customization for local or niche cinema is limited

2.4 Related Work

● MovieLens Dataset: Extensively used in recommendation research


● “Chatbot Recommender Systems” by Jannach et al. explores conversational recommendation
● Voice assistants like Alexa and Google Assistant provide basic movie recommendations but are
not tailored to specific user queries or genre-based suggestions via web apps

This project fills these gaps by building a Django-powered assistant combining traditional search, voice
input, and chatbot responses tailored to movie genres.

Chapter 3: System Analysis


3.1 Existing System
The AI-powered Movie Recommendation System, is a full-stack web application designed to
provide intelligent recommendations based on real-time environmental data. It combines a modern web
framework (Django) with machine learning techniques to, Movie recommendation administrators, and
agribusiness customers with insights that can improve planning, resource utilization, and yield outcomes.

This chapter outlines the major components of the system, describing how each module contributes to the
overall functionality. The system architecture is modular, allowing for future expansion and easy
maintenance. The four primary components are: Frontend, Backend, Database, and Machine Learning
Service.
Frontend

The user interface is built using Django templates and styled with Tailwind CSS, a utility-first CSS
framework that allows for rapid design and consistent aesthetics across pages. The frontend is designed to
be clean, responsive, and accessible, ensuring usability on both desktop and mobile devices.

0The frontend interacts with the backend using standard form submissions and can be extended to include
AJAX or API-based data submission in future versions. Mobile responsiveness is achieved using
Tailwind's responsive breakpoints, ensuring optimal user experience on smaller screens.

Backend

The backend is developed in Django 4.x, a high-level Python web framework known for its scalability,
security, and built-in ORM. It handles:

● Routing and Views: URL mappings are created for all major functionalities such as data entry,
prediction, and dashboard access. Views control the logic for rendering templates or processing
prediction requests.
● Authentication and Authorization: Built-in Django auth is used for login, logout, and password
protection. Users are grouped into roles using Django's Group model, enabling role-based access
control.
● Model Integration: The machine learning model is integrated into Django as a Python module. It
is invoked during form processing to generate real-time predictions.
● Data Validation and Security: The backend ensures input validation, uses CSRF protection on
forms, and handles exceptions gracefully to prevent system crashes.

The architecture follows the Model-View-Template (MVT) design pattern, which cleanly separates data,
logic, and presentation layers.

Database

The system uses PostgreSQL as its primary relational database management system. PostgreSQL was
selected due to its robustness, ACID compliance, and support for advanced features such as JSON storage,
indexing, and role management.

Database tables and their roles include:

● User Accounts: Stores information about registered users, their roles, and credentials.
● Prediction Logs: Captures environmental input values, recommended s, timestamps, and user ID
for traceability.
● Training Dataset Management (Admin Only): A provision to upload and manage datasets for
retraining the ML model in the future.
● Feedback Records: Planned for future implementation where can submit feedback on the
recommendation quality.

The Django ORM abstracts SQL queries and handles migrations seamlessly, which simplifies database
operations and schema evolution.

Machine Learning Service

The core intelligence of the system lies in the Machine Learning service, implemented as a standalone
Python module integrated into the Django backend. The service uses a Random Forest Classifier trained
on a structured dataset containing labels and environmental features.

Key components of the ML service include:

● Model Training Script: Written in Python using pandas, scikit-learn, and NumPy. The
model is trained offline and validated using test data before deployment.
● Model Serialization: The trained model is serialized using joblib for efficient storage and fast
loading at runtime.
● Runtime Inference: When a user submits environmental data, the Django view loads the
serialized model and passes the input to generate predictions in real-time.
● Result Output: The prediction result is returned to the user interface along with optional metadata
like confidence score (planned in future).

The design ensures that the model can be updated independently of the web app. Admins can retrain the
model offline and replace the serialized .pkl file without needing to redeploy the entire system.

Integration Workflow

Here’s how the components interact in practice:

1. User Interaction: The user fills out the data to be used for prediction form via the frontend
interface.
2. Form Submission: The input is sent to a Django view through a secure POST request.
3. Model Prediction: The backend view invokes the ML service, loads the model, and performs
inference.
4. Result Storage and Display: The prediction is stored in the database and returned to the frontend
for display.
5. Admin Access (Optional): Admins can view all prediction logs and performance analytics.

This modular and loosely coupled architecture ensures that each part of the system is independently
testable, replaceable, and scalable.
3.2 Proposed System

The proposed system addresses these limitations by offering a custom, content-based


detection tool using supervised learning. The application uses TF-IDF vectorization to
extract features from the text and Logistic Regression to classify.

Key features of the proposed system:

● Accepts content (subject + body) through a web interface.


● Uses a trained machine learning model to classify the input.
● Offers a result page showing the prediction.
● Allows users to register and log in before accessing the tool.
● Designed with a clean UI and scalable backend using Django.

This system is intended as an educational prototype to demonstrate real-world AI integration


in web applications.

3.3 Feasibility Study and Requirements Analysis


A feasibility study was conducted to assess the practicality of the project in terms of
technology, cost, and effort. The results are as follows:

Technical Feasibility: The system is built using widely available open-source tools (Python,
Django, Scikit-learn). No proprietary software or specialized hardware is required. The ML
model is trained offline and loaded into memory during runtime using joblib.

Operational Feasibility: The system is easy to use and deploy. Once trained, the model can
serve multiple prediction requests in real time without needing re-training unless explicitly
required.

Economic Feasibility: Since the system uses open-source tools and publicly available
datasets, there are no direct costs involved. It is feasible for individual developers and
academic institutions.

3.4 Requirements Analysis

3.4.1 Functional Requirements


● User Registration and Login System.
● submission form with subject and body fields.
● ML-based prediction of or not .
● Result page displaying the classification output.
● Admin interface to monitor users (optional).

3.4.2 Non-Functional Requirements

● Usability: Clean, simple UI for ease of use.


● Performance: Fast prediction response (<1s).
● Scalability: Model can be retrained on larger datasets.
● Security: User data stored securely; authenticated access enforced.
● Maintainability: Modular code structure, following MVC architecture.

Chapter 4: System Design


4.1 System Architecture Overview
The system follows a three-tier architecture:
1. Presentation Layer (Frontend)
2. Application Layer (Backend with Django & ML Model)
3. Data Layer (Database & ML Model Storage)

1. Presentation Layer (Frontend)


Components:
 Web-based form for user input (HTML templates using Django's templating engine)

 Result page displaying prediction output


Responsibilities:
 Collect data from users (age, cholesterol, etc.)
 Display prediction results to users
 Provide navigation between pages (form, result, admin)
2. Application Layer (Backend)
Components:
 Django views and URLs

 Trained Machine Learning model (e.g., .pkl file)


 Business logic for prediction
Responsibilities:
 Handle HTTP requests and form submissions

 Validate and preprocess form data


 Load the ML model into memory
 Pass preprocessed data to the model for prediction
 Save results to the database
 Render appropriate templates with data (e.g., prediction result)
3. Data Layer
Components:
 Database: SQLite (db.sqlite3)

 Machine Learning Model File: Serialized model file (_model.pkl)


Responsibilities:
 Store input and prediction results
 Provide data persistence for admin view and record-keeping
 Store and load the trained ML model used for real-time predictions
Workflow Summary
1. User Accesses the Form
User navigates to the form page and enters required information.
2. Data Submitted to Django View
Django receives the data, validates it, and prepares it for prediction.
3. Data Passed to ML Model
The structured input is sent to the pre-trained model, which returns a prediction (0 or
1).
4. Prediction Stored and Displayed
The result is saved to the database and shown on a result page.
5. Admin Panel Access
Admin users can view all stored records and predictions through Django’s built-in
admin interface.
Optional Enhancements (Future-Proofing)
 Authentication Layer: Add login for /admin access.
 API Layer: REST API using Django REST Framework for external integration.
 Model Retraining: Periodic retraining with new data entries to improve prediction
accuracy.

4.2 Use case Diagram


Place screen shot

4.3 Data Flow Diagram and Database Design

1. Start
The process begins with the user requesting movie
recommendations.
2. Movie Data
This block represents the dataset containing details about
available movies (e.g., movie IDs, titles, genres). It feeds into both
the similarity calculation and final display process.

3. Transaction Data
This includes user interactions like movie ratings or viewing
history. It reflects what each user has watched and rated.
4. Finding User Similarity with Pearson Correlation
This module compares users based on their ratings of common
movies.
 Pearson correlation measures the strength of the linear

relationship between two users' rating vectors.


 This helps in identifying users with similar tastes.
5. Collaborative Filtering
Using the similarity scores from the previous step, the system
applies user-based collaborative filtering:
 It finds neighbors (similar users).

 Predicts how a target user would rate unseen movies based

on their neighbors' ratings.


6. User Profile
This includes stored data about a specific user — such as rated
movies and preferences — which is necessary for personalizing
predictions.
7. Rating Prediction
The system predicts how much the user would like unrated
movies using the weighted ratings from similar users.
8. Ranking
The predicted ratings are sorted so that the most relevant or
highest-rated movies for the user come first.
9. Display Movies
The top-ranked movies are displayed to the user as
recommendations.
10. Finish
The recommendation cycle completes, ready to repeat for the next
query or session.

4.4 UI Design

Place screen shot and write minimal explanation about the screenshot you can UI you
feel good
Chapter 5: Implementation

5.1 Technology Stack

1. Programming Languages
 Python
Used for data processing, model training (machine learning), and back-end
development (Django framework).
 HTML/CSS
Used for designing the web front-end interface (forms, templates).
2. Machine Learning and Data Science
 Pandas – For data loading and manipulation.

 NumPy – For numerical operations.


 Scikit-learn – For building and training the Logistic Regression model.
 Joblib – For saving the trained model ( _ .pkl) for reuse in the web app.

3. Web Framework
 Django (Python-based Web Framework)

o Handles URL routing, form submissions, rendering HTML templates,


and database interaction.
o Django Admin panel is used for managing data models through a web UI.

4. Database
 SQLite

o Lightweight, serverless relational database used for storing form


submissions and managing admin data.
o Default database engine used in Django during development.

5. Front-End
 Django Templates (HTML with template tags)
Used to render web forms, display results, and interact with users dynamically.

6. Deployment Tools (if applicable)


 No specific deployment tools were provided in the project, but typical options for
a Django project would include:
o Gunicorn + Nginx for production servers

o Heroku or PythonAnywhere for quick cloud deployment

7. Development Tools
 Jupyter Notebook / Python scripts (for model development)

 VS Code / PyCharm (likely used for coding)


 Command line / Terminal for running Django commands (runserver,
makemigrations, etc.)

5.2 Use Authentication


Place screenshot of log in page once you get login page
Second after filling login info

5.3 Dataset and Preprocessing


Project Root (myProject/)
 manage.py: Entry point for Django project management
commands.
 requirements.txt: Lists Python dependencies (e.g., Django,
pandas, scikit-learn).
 db.sqlite3: SQLite database for storing users, movie data, and
other models.
 movie_dataset.csv: Source dataset containing movie information
used to train the recommendation model.
 movie_model.pkl: Serialized machine learning model (likely
using collaborative filtering or content-based filtering).
 train_model.py: Python script to train the ML model using the
dataset.

App 1: home/
This handles static or general site pages.
 admin.py, apps.py, models.py, views.py, urls.py: Standard Django files
for model-view-template logic.
 templates/home/*.html: Pages like index.html, about.html, contact.html.
 migrations/: Tracks model changes in Django ORM.

App 2: movie/
This handles movie-related features, including recommendation and user
interaction.
 models.py: Defines Movie-related database models.
 forms.py: Contains Django forms for login, signup, and movie input.
 views.py: Contains logic for movie recommendations and result
rendering.
 urls.py: Routes requests to appropriate views.
 templates/movie/: Contains HTML templates like login.html,
signup.html, result.html, etc.

Machine Learning Used in the Movie Recommendation


System
The system uses a Content-Based Filtering approach with TF-IDF
Vectorization and Cosine Similarity. Here's a breakdown of the
train_model.py code and the ML logic:
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import joblib

# Load movie dataset


data = pd.read_csv("movie_dataset.csv")

# Create TF-IDF matrix based on movie descriptions


tfidf = TfidfVectorizer(stop_words='english')
tfidf_matrix = tfidf.fit_transform(data['description'])

# Calculate cosine similarity between all movie pairs


cosine_sim = cosine_similarity(tfidf_matrix, tfidf_matrix)

# Save model components for later use


joblib.dump({'data': data, 'cosine_sim': cosine_sim, 'tfidf': tfidf},
"movie_model.pkl")

Explanation
 TF-IDF Vectorizer: Converts movie descriptions into numerical vectors
while ignoring common English stopwords.
 Cosine Similarity: Measures how similar two movie descriptions are
based on the angle between their vector representations.
 Model Saving: joblib.dump stores the trained TF-IDF and similarity
matrix in a file (movie_model.pkl) to be loaded later during predictions in
the web app.

5.3 Chatbot and Genre Classifier


Chatbot in Movie Recommendation Systems
A chatbot in a movie recommendation system acts as a conversational
interface that allows users to interact with the application in a natural,
intuitive way. Instead of selecting options or typing structured
queries, users can simply "chat" with the system, asking questions
like:
 “Can you suggest a good action movie?”
 “I liked Inception, what should I watch next?”
 The chatbot parses these inputs, understands the user’s intent
(using Natural Language Processing), and generates
personalized movie suggestions in response.

Key Components of a Movie Recommendation Chatbot


1. Intent Recognition:
o Understands what the user wants: recommendation, genre-specific
query, mood-based suggestions, etc.
o Tools: spaCy, NLTK, transformers, or custom-trained intent
classifiers.
2. Entity Extraction:
o Extracts movie titles, genres, actors, release years, etc., from user
queries.
o Example: In “Suggest a thriller starring Leonardo DiCaprio”, it
extracts the genre "thriller" and actor "Leonardo DiCaprio".
3. Response Generation:
o Calls the recommendation engine with filtered parameters.
o Returns a list of recommended movies as a chat response.
4. Dialog Management:
o Maintains context over multiple exchanges.
o Example:
 User: “Show me action movies.”
 Bot: “Sure, here are 5 top-rated action movies. Want
something more recent?”
Benefits of Chatbots in Recommendation
 User-Friendly: No need to fill forms or use filters—just type a message.
 Engaging: Feels like talking to a personal assistant.
 Flexible: Can be integrated into messaging platforms (e.g., WhatsApp,
Telegram, websites).

train_model.py – Genre Classifier Explanation


This script is responsible for building a genre-based movie
recommendation engine.

import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import joblib

# Load movie dataset


data = pd.read_csv("movie_dataset.csv")

# TF-IDF Vectorization on movie descriptions


tfidf = TfidfVectorizer(stop_words='english')
tfidf_matrix = tfidf.fit_transform(data['description'])

# Compute cosine similarity between all movie descriptions


cosine_sim = cosine_similarity(tfidf_matrix, tfidf_matrix)
# Save model using joblib
joblib.dump({'data': data, 'cosine_sim': cosine_sim, 'tfidf': tfidf},
"movie_model.pkl")

Functionality
 TF-IDF Vectorization: Converts text-based movie descriptions into
numerical vectors based on term frequency and inverse document
frequency.
 Cosine Similarity: Measures how similar two movies are based on their
description vectors.
 Model Saving: Stores the dataset, vectorizer, and similarity matrix into
a .pkl file (movie_model.pkl) for use in the web application.
Output (Saved Model)
After running this script:
 A movie_model.pkl file is generated.
 This file contains preprocessed data and a similarity matrix, which is used
by the Django app to recommend similar movies based on input.

Genre Classification (Indirect)


While the script doesn't explicitly classify genres, the movie descriptions
implicitly relate to genres, and the similarity comparison enables genre-
relevant recommendations.

One screenshot on hatbot

Sample Input and Output


Example Input (User selects movie title “The Matrix”):
1. Load movie_model.pkl
2. Find index of "The Matrix" in the dataset.
3. Retrieve cosine similarity scores for that movie.
4. Sort and display top 10 similar movies based on description.
Example Output:

Top 5 recommendations for "The Matrix":


1. The Matrix Reloaded
2. The Matrix Revolutions
3. Inception
4. Equilibrium
5. Minority Report

5.4 Voice Integration


1. Overview
Voice integration enhances user interaction by allowing users to
speak their queries instead of typing them. This feature increases
accessibility and provides a hands-free experience, making it
particularly useful on mobile devices and for visually impaired
users.
2. Technology Used
Voice integration typically involves using the Web Speech API
(for browsers) or external libraries such as:
 JavaScript Web Speech API (client-side for speech-to-text)
 SpeechRecognition library (for Python-based applications)
 Integration with Google Speech-to-Text or IBM Watson
In this project, the Web Speech API can be used in the frontend
(HTML/JS) to capture voice input and convert it into text, which
is then submitted to the backend recommendation engine.
3. Workflow
1. User clicks a microphone icon.
2. The browser captures the spoken query using the Web
Speech API.
3. Speech is converted to text and automatically filled into the
input field.
4. The text is submitted to the backend where the
recommendation logic is applied.
5. Results are rendered based on the spoken query.
4. Code Snippet (Frontend)
<button onclick="startRecognition()">🎤 Speak</button>
<input type="text" id="queryInput" placeholder="Say a movie or
genre...">

<script>
function startRecognition() {
const recognition = new webkitSpeechRecognition();
recognition.lang = "en-US";
recognition.onresult = function(event) {
document.getElementById("queryInput").value = event.results[0]
[0].transcript;
};
recognition.start();
}
</script>

5. Advantages
 Improves user experience and accessibility
 Provides faster input, especially for mobile users
 Enables hands-free interaction
6. Limitations
 Requires a modern browser with speech recognition support
 Accuracy depends on noise levels and microphone quality
 Not always effective for users with strong accents or speech impairments

5.5 Result Display and Navigation


Result and Navigation Flow Explanation
1. Start
o The user enters the application, typically landing
on the homepage or search screen.
2. Enter Movie Title
o The user is prompted to enter a movie they liked
or are interested in. This is the input that drives
the recommendation engine.
3. View Recommendations
o Once the movie title is submitted, the system
processes it using the ML model (like cosine
similarity on TF-IDF vectors) and displays a list
of recommended movies.
o The output may include movie titles, posters,
genres, and release years.
4. Try Another Movie
o After seeing the recommendations, the user can
choose to:
 Click a "Try another movie" button to go
back to the input step.
 Enter a new title to get a fresh set of
suggestions.
5. Navigate to Homepage
o Users can also choose to go back to the homepage
if they want to start over or explore other
features like chatbot, genre search, or voice
input.
6. Finish
o The user session ends or the user exits the
recommendation loop.
Django Integration for web Application

Function: movie_result_view()
This function handles the recommendation process after a user
submits a movie title through the form.
Core logic:
model_data = joblib.load("movie_model.pkl")

Loads the previously trained TF-IDF and cosine similarity data


from disk.
movie_input = get_object_or_404(MovieInput, id=movie_id)
user_title = movie_input.movie_title
data = model_data['data']
cosine_sim = model_data['cosine_sim']

 Retrieves the movie title entered by the user from the


database.
 Loads the movie dataset (data) and cosine similarity matrix
(cosine_sim).

if user_title not in data['movie_title'].values:

recommendations = []

else:

idx = data.index[data['movie_title'] == user_title][0]

sim_scores = list(enumerate(cosine_sim[idx]))

sim_scores = sorted(sim_scores, key=lambda x: x[1],

reverse=True)

sim_scores = sim_scores[1:6]

rec_indices = [i[0] for i in sim_scores]

recommendations = data['movie_title'].iloc[rec_indices]

 Finds the index of the selected movie.


 Gets similarity scores with all other movies.
 Sorts and picks the top 5 most similar ones (excluding itself).
 Retrieves their titles as recommendations.
Example Output (Displayed in movie_result.html)
If the user inputs “Inception”, the output might be:

Put some movie name that you have in

1. The system uses content-based filtering via TF-IDF + Cosine


Similarity.
2. Movie title input triggers similarity-based recommendations.
3. Results are rendered on a result HTML page using Django
templating.
movie_result.html

{% extends 'base.html' %}

{% block content %}
<div class="container mt-5">
<h2 class="mb-4">Recommended Movies for
"{{ movie_input.movie_title }}"</h2>

{% if recommendations %}
<ul class="list-group">
{% for movie in recommendations %}
<li class="list-group-item">{{ forloop.counter }}. {{ movie
}}</li>
{% endfor %}
</ul>
{% else %}
<div class="alert alert-warning mt-3" role="alert">
Sorry, we couldn't find recommendations for that movie title.
</div>
{% endif %}

<a href="{% url 'movie_form' %}" class="btn btn-primary mt-


4">Try Another Movie</a>
</div>
{% endblock %}

1. Displays the input movie.


2. Lists recommendations with numbered bullets.
3. Graceful handling if no recommendations are found.
4. Includes a button to return and try a new movie.

movie_result.html (Plain HTML)


The plain HTML version of the movie_result.html template provides
a clean and simple interface for displaying movie recommendations. It
eliminates dependencies like Bootstrap while maintaining a user-
friendly layout using basic CSS
When a user submits a movie title, the system presents the top
recommended titles in an ordered list. If no recommendations are
found, a warning message notifies the user. The interface is styled for
readability using spacing, color, and borders, making the output
visually distinct without heavy frameworks.
Each recommended movie is shown clearly, with room to add
enhancements like images or descriptions later. The template uses
Django’s templating language to loop through and present results
dynamically. A styled button at the bottom allows users to try a new
search easily. This structure ensures accessibility across devices and
environments, even with limited frontend support. Overall, the
template provides a robust and extensible bridge between the backend
ML model and the user interface.
Summarizing
The movie_result.html template is responsible for presenting
movie recommendations to the user after a title is submitted. It
extends a base layout (base.html) and uses Django’s template
language to dynamically display content. The heading clearly shows
which movie the recommendations are based on, enhancing user
engagement.

It checks whether recommendations are available and displays them


in a clean, numbered list using Bootstrap’s list-group component. If
no recommendations exist—due to an invalid or unknown movie
input—it gracefully displays an alert message. The use of {% for
movie in recommendations %} allows iteration over the list of similar
movies returned by the machine learning model. Each movie title is
rendered inside a styled list item, maintaining a consistent and user-
friendly layout.

The template also provides a button to return to the input form,


allowing users to request new recommendations easily. It emphasizes
responsiveness and clarity, which are crucial for good user
experience. This HTML template is an essential bridge between the
machine learning logic and the end user, presenting intelligent results
in an intuitive format.

Chapter 6: Results and Discussion


Image Upload and Live Prediction
Upload every single step the movies everyting here

6.2 Chatbot Interaction Flow


Chatbot Interaction Flow – Step-by-Step Explanation
1. Start Interaction
o The user initiates a chat by typing or using voice (if voice integration is
enabled).
o Example: "Can you recommend a good thriller movie?"
2. Input Processing
o The chatbot receives the message and uses Natural Language Processing
(NLP) to:
 Detect intent (e.g., recommendation, genre preference, year, actor).
 Extract entities (e.g., genre: "thriller", actor: none, year: none).
3. Query Construction
o Based on parsed entities, a query is constructed and passed to the
Recommendation Engine.
o If the intent is unclear, the bot may ask a clarifying question:
"put question from the myproject list?"
4. Fetch Recommendations
o The backend (usually using a pre-trained model or content-based filtering)
returns a list of recommended movies matching the user’s preferences.
5. Display Results
o The chatbot replies with formatted results:
"Here are some top-rated movies:
Put 3 movies name
Follow-Up Options
The bot then asks:
6. Continue or End
o Based on user choice:
 The loop continues (go back to Input).
 Or the session ends.

6.3 Recommendation Accuracy

Can Recommendation Systems Have "Accuracy"?

Traditional accuracy metrics (like accuracy %, precision, recall) are not always meaningful
for content-based or collaborative filtering models, because:
 The system recommends items, not classifications.
 There's often no single correct answer—recommendations are subjective.

However, we can use alternative evaluation metrics:

Common Metrics for Recommendation Systems


1. Cosine Similarity Score (used in your project)
Measures how close two movie descriptions are in vector space.
o Not a percentage, but a similarity value between 0 and 1.
o Higher = more relevant.
2. Mean Squared Error (MSE) or RMSE
If using ratings predictions (collaborative filtering), you can evaluate how close
predictions are to real user ratings.
3. Precision@K / Recall@K
If you have user interaction data:
o Precision@5: Of the top 5 recommended movies, how many did the user
actually like?
o These are more aligned with "accuracy" in a recommendation context.

Example from Your Project


Since your model is content-based (TF-IDF + Cosine Similarity), here’s how we can
evaluate it:
from sklearn.metrics.pairwise import cosine_similarity

# Simulate checking similarity between two movies

similarity = cosine_similarity(tfidf_matrix[10], tfidf_matrix[20])

print("Cosine Similarity Score:", similarity[0][0])

Example Output:

Cosine Similarity Score: 0.85

That means Movie 10 and Movie 20 are 85% similar based on their description—so the
recommendation is reasonably strong.
6.4 User Feedback
Types of User Feedback
1. Explicit Feedback
o The user directly rates a movie (e.g., 1 to 5 stars).
o The user gives a thumbs-up/down to a recommendation.
o Example:
Like / Dislike buttons next to each recommended movie.
2. Implicit Feedback
o Based on user behaviour: clicks, time spent on a movie page, or
repeated searches.
o No direct input required.
How to Use Feedback?
1. Store Feedback in the Database
Add a new model in models.py:
from django.contrib.auth.models import User
from django.db import models

class MovieFeedback(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
movie_title = models.CharField(max_length=255)
liked = models.BooleanField() # True = Liked, False = Disliked
timestamp = models.DateTimeField(auto_now_add=True)

2. Update Your Recommendation Logic


 Track which genres or movies a user consistently likes.
 Use this to filter or prioritize future recommendations.
 For advanced implementations: use collaborative filtering or reinforcement
learning to adapt over time.

Benefits of Feedback Integration


 Enables personalized recommendations.
 Improves system accuracy over time.
 Helps identify trends or unpopular recommendations.
 Facilitates A/B testing to improve UI/UX and model performance.

Example Workflow with Feedback


1. User sees recommended movies.
2. They click "Like" or "Dislike".
3. Feedback is stored in MovieFeedback table.
4. Future recommendations for that user prioritize liked genres/movies.
5. Admin can also analyze this data to tune recommendation logic.

Chapter 7: Conclusion and Future Work


Conclusion

The Movie Recommendation System developed using Machine Learning and Django
demonstrates the practical application of data science in the entertainment domain. By
leveraging content-based filtering techniques, the system effectively suggests relevant movies
to users based on their preferences, such as previously liked titles or selected genres. This
enhances the user experience by reducing the effort required to discover new content in an
ever-growing digital library of movies.

Machine learning plays a critical role in this project through the use of TF-IDF vectorization
and cosine similarity for text-based recommendation. This enables the system to capture the
contextual similarities between movies based on their descriptions or metadata, allowing for
intelligent and human-like suggestions. The integration of additional components such as a
genre classifier and chatbot further enriches the interaction, enabling dynamic and natural
user engagement.

On the web development front, Django provides a robust and scalable backend infrastructure,
making it possible to manage users, store feedback, and render movie suggestions efficiently.
The frontend, enhanced with Bootstrap and optional voice input or chatbot support, ensures
that the application is both responsive and user-friendly. This synergy between backend logic
and frontend interaction creates a seamless recommendation flow for users.

Throughout development, emphasis was placed not only on technical performance but also
on usability. Features like voice-based search, chatbot queries, and user feedback collection
significantly enhance personalization and accessibility. This makes the application suitable
for real-world deployment, especially in platforms like streaming services, where user
retention depends heavily on meaningful recommendations.

In conclusion, this project showcases a well-rounded integration of machine learning and web
technologies to solve a relevant and engaging problem. It serves as a strong foundation for
future enhancements, such as incorporating collaborative filtering, hybrid recommendation
models, and multi-language support. With growing demand for personalization in digital
content, systems like this continue to prove their value in real-world applications.
Limitations of the Project
1. Cold Start Problem
New users or movies without prior interaction or metadata have limited or no
recommendations, as content-based filtering relies heavily on existing data.
2. Lack of Personalization
Without user-specific learning or collaborative filtering, recommendations are
generalized and may not reflect individual user preferences over time.
3. No Real-Time Learning
The model does not update dynamically with user feedback or behavior, requiring
manual retraining to incorporate new data or preferences.
4. Limited Data Scope
The dataset might only include metadata like titles and genres—lacking deep insights
such as user reviews, ratings, or watch history.
5. Text Similarity Constraints
Content-based filtering using TF-IDF may miss deeper semantic connections between
movies, as it doesn't fully understand narrative or context.
6. Scalability Issues
As the movie database grows, cosine similarity calculations become slower,
potentially impacting performance on larger datasets.
7. No Diversity in Results
Recommendations tend to be similar to the input, leading to a filter bubble and
reducing the discovery of varied or unexpected content.
8. Limited UI/UX Functionality
Features like voice input or chatbot might not work consistently across all browsers or
devices, affecting accessibility for some users.
Future Enhancements
1. Hybrid Recommendation System
Combine content-based and collaborative filtering to improve both personalization
and diversity in suggestions.
2. Real-Time Feedback Learning
Enable the system to update user profiles dynamically based on their likes, dislikes,
and interactions for more accurate future recommendations.
3. Deep Learning for NLP
Replace TF-IDF with more powerful NLP models like BERT or Word2Vec for
deeper semantic understanding of movie plots and descriptions.
4. User-Based Collaborative Filtering
Use user interaction data (ratings, watch history) to recommend movies liked by
similar users, enabling better personalization.
5. Genre and Actor-Based Filtering
Add advanced filters so users can request movies by genre, actor, director, or release
year more intuitively.
6. Recommendation Explanations
Show users why a movie was recommended (e.g., “because you liked Inception”),
increasing trust in the system.
7. Voice Command Integration
Fully implement voice input for search and chatbot interaction, making the app more
accessible.
8. Mobile App Version
Develop a mobile-friendly version or Android/iOS app for better reach and usability.
9. User Dashboard and Watchlists
Allow users to maintain watchlists, save favorite recommendations, and track viewing
history.
10. Sentiment Analysis on Reviews
Analyze user reviews or social media sentiment to enrich recommendations with
emotional tone and viewer satisfaction levels.
References
1. Ricci, F., Rokach, L., & Shapira, B. (2015). Recommender Systems Handbook.
Springer.
2. Aggarwal, C. C. (2016). Recommender Systems: The Textbook. Springer.
3. scikit-learn developers. (2024). scikit-learn: Machine Learning in Python.
https://scikit-learn.org
4. Django Software Foundation. (2024). Django Documentation.
https://docs.djangoproject.com/
5. IMDb Dataset. (2023). IMDb Movie Metadata. https://www.imdb.com/interfaces/
6. TF-IDF Vectorizer. (n.d.). Scikit-learn TF-IDF Guide.
https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.Tfidf
Vectorizer.html
7. Cosine Similarity. (n.d.). SciPy Spatial Distance Metrics.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cosine.html
8. Medium. (2021). Content-Based Movie Recommendation Systems Using Python.
https://medium.com
9. Towards Data Science. (2022). Building a Simple Recommender System in Python.
https://towardsdatascience.com
10. GeeksforGeeks. (2023). Movie Recommendation using Cosine Similarity.
https://www.geeksforgeeks.org
11. OpenAI. (2023). Chatbot integration techniques and NLP. https://openai.com
12. GitHub. (2024). Open-source Movie Recommendation Projects. https://github.com
13.  Koren, Y., Bell, R., & Volinsky, C. (2009). Matrix Factorization Techniques for
Recommender Systems. IEEE Computer, 42(8), 30–37.
14.  Coursera. (2022). Recommender Systems Specialization – University of
Minnesota. https://www.coursera.org/specializations/recommender-systems
15.  Krishnan, S. (2020). Machine Learning for Personalized Recommendations.
O'Reilly Media.
16.  Papers With Code. (2024). State-of-the-Art Recommender System Benchmarks.
https://paperswithcode.com/task/recommendation-systems
17.  Microsoft Azure Blog. (2021). Building Recommender Systems with Azure
Machine Learning. https://azure.microsoft.com/en-us/blog

You might also like