A Java-based movie recommendation engine using Weighted Cosine Similarity.
Given a movie or personal preferences, the system finds the 3 most similar movies from a CSV dataset.
project/
├── movies.csv
├── lib/
│ └── junit-platform-console-standalone-1.10.0.jar
└── src/
└── netflix/
├── Movie.java
├── CsvReader.java
├── RecommendationEngine.java
├── Main.java
└── RecommendationEngineTest.java
Each movie is represented as a feature vector (values between 0.0 and 1.0).
The CSV file contains:
- Row 1 – feature names (e.g. action, comedy, romance...)
- Row 2 – feature weights (importance in the matching algorithm)
- Row 3+ – movie name and its feature values
Similarity is calculated using Weighted Cosine Similarity:
- Score of
1.0= perfect match - Score of
0.0= completely different
javac -cp lib/junit-platform-console-standalone-1.10.0.jar -d out src/netflix/*.javajava -cp out netflix.Mainjava -jar lib/junit-platform-console-standalone-1.10.0.jar --cp out --select-class=netflix.RecommendationEngineTest| Option | Description |
|---|---|
| 1 | Pick a movie from the list — get 3 similar movies |
| 2 | Rate features (0–5) — get 3 movies matching your taste |
| 3 | Exit |
| Test | Description |
|---|---|
testIdenticalVectors |
Identical vectors must return similarity 1.0 |
testOrthogonalVectors |
Orthogonal vectors must return similarity 0.0 |
testWeightedSimilarity |
Higher weights must influence the final score |
testLengthMismatch |
Mismatched vector lengths must throw IllegalArgumentException |
- Java 17+
- JUnit Jupiter 5.10 (jar included in
lib/)
name,action,comedy,romance,sci-fi,horror
weights,0.8,0.5,0.4,0.7,0.6
The Matrix,0.9,0.1,0.2,1.0,0.3
Interstellar,0.6,0.1,0.5,1.0,0.2
...