<jupyter_start><jupyter_text>TransformWe need to prepare the data for using Deep Learning algorithms. There are two main transformations:- **Preprocessing**:    - Users: Convert to label encoded values    - Items: Convert to label encoded values    - User Side Features: Convert to     - Ratings: Convert the interaction to Explicit or Implicit signals- **Data Spliting**: Create train & test datasets for evaluating the dataset    - Random Split    - Stratified Split    - Chronological Split<jupyter_code># set the environment path to find reco
import sys
sys.path.append("../")
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
users = pd.read_csv("data/users.csv")
items = pd.read_csv("data/items.csv")
ratings = pd.read_csv("data/ratings.csv")
users.head()
ratings.head()
items.head()
items.iloc[0]<jupyter_output><empty_output><jupyter_text>Preprocessing<jupyter_code>from reco.preprocess import encode_user_item
encoded_ratings, user_encoder, item_encoder = encode_user_item(ratings, "user_id", "movie_id")
encoded_ratings.head()
ratings['rating'] = ratings['rating'].values.astype(np.float32)
min_rating = min(ratings['rating'])
max_rating = max(ratings['rating'])<jupyter_output><empty_output><jupyter_text>Data Splitting- Random Split- Stratified Split- Chronological Split<jupyter_code>from reco.preprocess import random_split, user_split, sample_data
sampledf = sample_data()<jupyter_output><empty_output><jupyter_text>Random Split<jupyter_code>train_random, val_random, test_random = random_split(sampledf, [0.6, 0.2, 0.2])
train_random
val_random
test_random<jupyter_output><empty_output><jupyter_text>User Chronological Split<jupyter_code>train_chrono, val_chrono, test_chrono = user_split(sampledf, "timestamp", "user_index", [0.6, 0.2, 0.2])
train_chrono
val_chrono
test_chrono<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1078590785907859, 'fraction_numerical': 0.008130081300813009, 'mean_word_length': 7.0964912280701755, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '297665', 'license': 'MIT', 'n_tokens_mistral': 621, 'n_tokens_neox': 599, 'n_words': 144, 'path': '04-Transform.ipynb', 'repo_name': 'Abhishek-Aditya-bs/Recommender-System-MovieLens', 'size': '1845'}