Menu

Predictive Analytics - (LAB PROGRAMS)


Aim:

  Crowdsource Predictive Analytics – Netflix Data

Solution :


Library Installation:

To install required library files, Open Command Prompt or Terminal and execute the following commands


$ pip install surprise


PROGRAM: (CROWD_SOURCE.py)

 
from surprise import Dataset, SVD
from surprise.model_selection import train_test_split
from surprise.accuracy import rmse
# Load dataset (example: MovieLens)
data = Dataset.load_builtin('ml-100k')
trainset, testset = train_test_split(data, test_size=0.2, random_state=42)
# Initialize SVD model
model = SVD()
model.fit(trainset)
# Make predictions
predictions = model.test(testset)
# Evaluate RMSE
rmse(predictions)
# Show sample predictions
print("\nSample Predictions (userID, itemID, actual rating, predicted rating):")
for pred in predictions[:10]:
    print(f"{pred.uid}, {pred.iid}, {pred.r_ui} => {round(pred.est, 2)}")


OUTPUT:

 
Dataset ml-100k could not be found. Do you want to download it? [Y/n] Y
Trying to download dataset from https://files.grouplens.org/datasets/movielens/ml-100k.zip...
Done! Dataset ml-100k has been saved to C:\Users\madhu/.surprise_data/ml-100k
RMSE: 0.9347

Sample Predictions (userID, itemID, actual rating, predicted rating):
907, 143, 5.0 => 4.78
371, 210, 4.0 => 4.21
218, 42, 4.0 => 3.62
829, 170, 4.0 => 3.99
733, 277, 1.0 => 3.31
363, 1512, 1.0 => 3.02
193, 487, 5.0 => 3.86
808, 313, 5.0 => 5
557, 682, 2.0 => 2.89
774, 196, 3.0 => 2.24




Related Content :

1. Simple Linear regression.   View Solution


2. Multiple Linear regression.   View Solution


3. Logistic Regression.   View Solution


4. CHAID.   View Solution


5. CART.   View Solution


6. ARIMA - stock market data.   View Solution


7. Exponential Smoothing.   View Solution


8. Hierarchical clustering.   View Solution


9. Ward's method of clustering.   View Solution


10. Crowdsource predictive analytics- Netflix data.   View Solution