Skip to content

Collaborative filtering was updated to avoid problems caused by recen… - #32

Open
SErfanR wants to merge 1 commit into
jadijadi:mainfrom
SErfanR:main
Open

Collaborative filtering was updated to avoid problems caused by recen…#32
SErfanR wants to merge 1 commit into
jadijadi:mainfrom
SErfanR:main

Conversation

@SErfanR

@SErfanR SErfanR commented Aug 26, 2026

Copy link
Copy Markdown

درود استاد گرامی

بخش هایی از کد collaborative filtering بدلیل تغییرات صورت گرفته در pandas و سایر کتابخانه ها، در نسخه های جدید امکان اجرا نداشت.
تغییرات کوچکی صورت گرفته تا از این مشکلات جلوگیری شود.

1.

old:

#Using regular expressions to find a year stored between parentheses
#We specify the parantheses so we don't conflict with movies that have years in their titles
movies_df['year'] = movies_df.title.str.extract('(\(\d\d\d\d\))',expand=False)
#Removing the parentheses
movies_df['year'] = movies_df.year.str.extract('(\d\d\d\d)',expand=False)
#Removing the years from the 'title' column
movies_df['title'] = movies_df.title.str.replace('(\(\d\d\d\d\))', '', regex=True)
#Applying the strip function to get rid of any ending whitespace characters that may have appeared
movies_df['title'] = movies_df['title'].apply(lambda x: x.strip())

new:

#Using regular expressions to find a year stored between parentheses
#We specify the parantheses so we don't conflict with movies that have years in their titles
movies_df['year'] = movies_df.title.str.extract(r'(\(\d\d\d\d\))',expand=False)
#Removing the parentheses
movies_df['year'] = movies_df.year.str.extract(r'(\d\d\d\d)',expand=False)
#Removing the years from the 'title' column
movies_df['title'] = movies_df.title.str.replace(r'(\(\d\d\d\d\))', '', regex=True)
#Applying the strip function to get rid of any ending whitespace characters that may have appeared
movies_df['title'] = movies_df['title'].apply(lambda x: x.strip())

2.

old:

userSubsetGroup.get_group(1130)

new:

userSubsetGroup.get_group((1130,))

3.

این بخش به طوری کلی اجرا نمی شد، اما مشکل بسیار کوچک بود تنها با تبدیل tuple به int

old:

pearsonDF = pd.DataFrame.from_dict(pearsonCorrelationDict, orient='index')
pearsonDF.columns = ['similarityIndex']
pearsonDF['userId'] = pearsonDF.index
pearsonDF.index = range(len(pearsonDF))
pearsonDF.head()

new:

pearsonDF = pd.DataFrame.from_dict(pearsonCorrelationDict, orient='index')
pearsonDF.columns = ['similarityIndex']
pearsonDF['userId'] = pearsonDF.index
#Using int not tuple
pearsonDF["userId"] = pearsonDF["userId"].apply(lambda x: x[0])
pearsonDF.index = range(len(pearsonDF))
pearsonDF.head()

سپاس از شما بابت دوره بسیار عالی و کاربردی
خندون بمونید ... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant