Uppdatera README samt kommentar i trainmodel

This commit is contained in:
jwradhe 2024-11-06 22:58:36 +01:00
parent 5c9f0ffdc8
commit a26b150a19
2 changed files with 4 additions and 3 deletions

View File

@ -27,7 +27,8 @@ I will use a dataset from TMBD
https://www.kaggle.com/datasets/asaniczka/full-tmdb-tv-shows-dataset-2023-150k-shows https://www.kaggle.com/datasets/asaniczka/full-tmdb-tv-shows-dataset-2023-150k-shows
### Model: ### Model:
I will use NearestNeighbors (NN) alhorithm together with K-NearestNeighbors alhorithm. I must first preprocess data with vectorization so that i can use it in NearestNeighbors (NN) alhorithm.
I will use NearestNeighbors (NN) output as input to K-NearestNeighbors alhorithm.
### Features: ### Features:
1. Load data from dataset and preprocessing. 1. Load data from dataset and preprocessing.

View File

@ -34,7 +34,7 @@ class TrainModel:
# Preprocess title data # Preprocess title data
preproccessed_data = self.preprocess_title_data() preproccessed_data = self.preprocess_title_data()
# Train the NN model # Train the NearestNeighbors model
self.model.fit(preproccessed_data) self.model.fit(preproccessed_data)
stop = time.time() stop = time.time()
@ -51,7 +51,7 @@ class TrainModel:
# Preprocess target data # Preprocess target data
target_vector = self.preprocess_target_data(target_row) target_vector = self.preprocess_target_data(target_row)
# Get nearest neighbors # Use NearestNeighbors model as input to K-nearest neighbors
distances, indices = self.model.kneighbors(target_vector, n_neighbors=num_recommendations) distances, indices = self.model.kneighbors(target_vector, n_neighbors=num_recommendations)
recommendations = self.title_data.iloc[indices[0]].copy() recommendations = self.title_data.iloc[indices[0]].copy()
recommendations['distance'] = distances[0] recommendations['distance'] = distances[0]