Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to know how to apply the prediction function, please python 1. Import pandas and libraries 2. Upload the dataset file that is provided

I need to know how to apply the prediction function, please

python

image text in transcribed

1. Import pandas and libraries 2. Upload the dataset file that is provided on the Blackboard and show its content 3. Use the read_csv function to assign the data to a dataframe called user_item_df 4. Display the dataframe content using the function 5. Apply the Pearson correlation using Pandas: The Pearson correlation is computed using the below formula. In this part, however, you are asked to use the corr function provided by pandas to compute the correlation between all the users in the dataset. In the second part, you will implement the formula yourself. For more information about how to use the corr function, check this link for example sim(a,b)=pP(rapra)2pP(rbpprb)2pP(ra,pra)(rb,prb) 6. Assign the result of calling the function to a dataframe called 7. Identify the neighbors: Use the function to display the correlation dataframe (i.e. 1. Next, locate the top two neighbors to Alice. Those neighbors will be used as the base for predicting Item5's rating for Alice. Lastly, you can confirm that the correlation values for Alice are equal to the ones provided in the main textbook (page 15) 8. Prepare the values for the prediction: The prediction function (shown below) contains several variables that need to be prepared before applying the formula. sim(a,b) is nothing but the correlation values between Alice and her two neighbors. pred(a,p)=ra+bNsim(a,b)bNsim(a,b)(rb,prb) a. ra is the mean ratings for Alice and can be computed using the function provided by pandas. For more information on the function, use the following link. Assign the mean value to a variable called b. rb,p is the ratings that the top n neighbors gave to the target item. In our case the top two neighbors are "User1" and "User2". To extract those ratings, one way is to use the function. Feel free to use other ways to extract the ratings values of the top two neighbors (manually entering the values is not accepted). More information about nlargest is here. c. Lastly, we need to compute rb, the mean ratings values for the neighbors, which can be computed using the function like what you did in (a). 9. Now you should be ready to apply the prediction function as specified in the provided formula. 10. Lastly, print out the value for Item5 that should be predicted for Alice. Compare your results with the result in page 16 of the main textbook

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

List the three layers in ANN.

Answered: 1 week ago

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

What are the classifications of Bank?

Answered: 1 week ago