def _prepare_X(self, X_raw):
        X_raw, self.bad_movie_indexes = remove_bad_movies(
            X_raw, self.bad_movie_indexes)
        X, _ = fill_ratings_with_mean_per_user(X_raw)
        X = X[:, 1, :]  # only ratings

        return X.reshape(X.shape[0], -1)
コード例 #2
0
    def _prepare_X(self, X_raw, train = True):
        X_raw, self.bad_movie_indexes = remove_bad_movies(X_raw, self.bad_movie_indexes)
        X, _ = fill_ratings_with_mean_per_user(X_raw)
        X = X[:,1,:] # only ratings
        X = X.reshape(X.shape[0], -1)

        if train:
            self.release_date = np.min(X_raw[:,2,0])

        X = np.hstack((X, diff_in_time_to_rate_target_movie(X_raw, self.release_date)))

        return X
コード例 #3
0
    def _prepare_X(self, X_raw, Y=None, train=False):
        X_raw, self.bad_movie_indexes = remove_bad_movies(
            X_raw, self.bad_movie_indexes)
        X, _ = fill_ratings_with_mean_per_user(X_raw)
        X = X[:, 1, :]  # only ratings

        if train:
            self.scaler.fit(X)
        X_rescaled = self.scaler.transform(X)

        if train:
            self.pca = PCA(n_components=75).fit(X_rescaled)
        X_components = self.pca.transform(X_rescaled)

        return X_components.reshape(X.shape[0], -1)