director and cast preprocessing

This commit is contained in:
IshaAtteri
2026-03-25 18:21:16 -04:00
parent 233fa3df17
commit 496761ca78

View File

@@ -1,22 +1,17 @@
import pandas as pd
from sentence_transformers import SentenceTransformer
from preprocessing import clean_plot, get_genre
from preprocessing import clean_plot, get_genre, pre_director, clean_cast
from sklearn.metrics.pairwise import cosine_similarity
df = pd.read_excel('C:\\Users\\ishaa\\OneDrive\\Documents\\MSU\\Spring 2026\\Data mining\\Project\\updated_data.xlsx', engine='openpyxl')
print(len(df))
df = df.dropna(subset=['Genre', 'Plot'])
print(len(df))
# df = df[:2]
df['Processed_Plot'] = df['Plot'].apply(clean_plot)
df['Genre'] = df[['Genre', 'Title']].apply(get_genre, axis=1)
df['Pre_genre'] = df[['Genre', 'Title']].apply(get_genre, axis=1)
df.to_excel('C:\\Users\\ishaa\\OneDrive\\Documents\\MSU\\Spring 2026\\Data mining\\Project\\preprocessed_data.xlsx', index=False)
df['Pre_director'] = df['Director'].apply(pre_director)
df['Pre_cast'] = df['Cast'].apply(clean_cast)
print(df.columns)
df.to_excel('C:\\Users\\ishaa\\OneDrive\\Documents\\MSU\\Spring 2026\\Data mining\\Project\\preprocessed_data.xlsx', index=False)