human
Solve the following python programming problem given the following code:
# Libraries
import pandas as pd
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity

class cos_engine:
    def __init__(self, data_all):
        """Constructor for cos_engine class
        
        Args:
            data_all: Raw dataset containing all movies to build
                    a list of movies already seen by each user.
        """
        # Create copy of data
        self.data_all = data_all.copy()
        
        # Now build a list of movies each of you has seen
        self.seen = []
        for user in data_all.user_id.unique():
            cur_seen = {}
            cur_seen["user"] = user
            cur_seen["seen"] = self.data_all[data_all.user_id == user].item_id
            self.seen.append(cur_seen)
            
        
    def fit(self, data_train):
        """Performs cosine similarity on a sparse matrix data_train
        
        Args:
            data_train: A pandas data frame data to estimate cosine similarity
        """
        # Create a copy of the dataframe
        self.data_train = data_train.copy()
        
        # Save the indices and column names
        self.users = self.data_train.index
        self.items = self.data_train.columns
           
        # Compute mean vectors
        self.user_means = self.data_train.replace(0, np.nan).mean(axis = 1)
        self.item_means = self.data_train.T.replace(0, np.nan).mean(axis = 1)
        
        # Get similarity matrices and compute sums for normalization
        # For non adjusted cosine similarity, neglect subtracting the means.
        self.data_train_adj = (self.data_train.replace(0, np.nan).T - self.user_means).fillna(0).T
        self.user_cos = cosine_similarity(self.data_train_adj)
        self.item_cos = cosine_similarity(self.data_train_adj.T)
        
        self.user_cos_sum = np.abs(self.user_cos).sum(axis = 1)
        self.item_cos_sum = np.abs(self.item_cos).sum(axis = 1)
        
        self.user_cos_sum = self.user_cos_sum.reshape(self.user_cos_sum.shape[0], 1)
       ...
Given the above code, generate some markdown instructions for it.
assistant
#Here is Python program to compute mean vectors
.

Now split the data into a training and test set, using a ratio 80/20 for train/test.
Cosine Similarity
Building a recommendation engine can be thought of as "filling in the holes" in the sparse matrix you made above.  For example, take a look at the MovieLense data.  You'll see that that matrix is mostly zeros.  Our task here is to predict what a given user will rate a given movie depending on the users tastes.  To determine a users taste, we can use cosine similarity which is given by $$s_u^{cos}(u_k,u_a)
 = \frac{ u_k \cdot u_a }{ \left \| u_k \right \| \left \| u_a \right \| }
 = \frac{ \sum x_{k,m}x_{a,m} }{ \sqrt{\sum x_{k,m}^2\sum x_{a,m}^2} }$$
for users $u_a$ and $u_k$ on ratings given by $x_{a,m}$ and $x_{b,m}$.  This is just the cosine of the angle between the two vectors.  Likewise, this can also be calculated for the similarity between two items, $i_a$ and $i_b$, given by $$s_u^{cos}(i_m,i_b)
 = \frac{ i_m \cdot i_b }{ \left \| i_m \right \| \left \| i_b \right \| }
 = \frac{ \sum x_{a,m} x_{a,b} }{ \sqrt{ \sum x_{a,m}^2 \sum x_{a,b}^2 } }$$
Then, the similarity between two users is given by $$\hat{x}{k,m} = \bar{x}{k} + \frac{\sum\limits_{u_a} s_u^{cos}(u_k,u_a) (x_{a,m})}{\sum\limits_{u_a}|s_u^{cos}(u_k,u_a)|}$$ and for items given by $$\hat{x}{k,m} = \frac{\sum\limits{i_b} s_u^{cos}(i_m,i_b) (x_{k,b}) }{\sum\limits_{i_b}|s_u^{cos}(i_m,i_b)|}$$
Use these ideas to construct a class cos_engine which can be used to recommend movies for a given user.  Be sure to also test your algorithm, reporting its accuracy.  Bonus: Use adjusted cosine similiarity.