Ejemplo n.º 1
0
        predictions_bounded = np.maximum(y_pred,
                                         np.ones(num_example) *
                                         min(y_true))  # bound the lower values
        predictions_bounded = np.minimum(
            predictions_bounded,
            np.ones(num_example) * max(y_true))  # bound the higher values
        RMSE = math.sqrt(mean_squared_error(y_true, predictions_bounded))
        return RMSE


if __name__ == '__main__':
    # Data loading
    LD = LoadData(0.8)  #80% train
    batch_size = 32
    train_batch = LD.get_batches(LD.train_user,
                                 LD.train_item,
                                 LD.train_rating,
                                 batch_size=batch_size)
    test_batch = LD.get_batches(LD.test_user,
                                LD.test_item,
                                LD.test_rating,
                                batch_size=batch_size)

    Train_data = [
        LD.train_user, LD.train_item, LD.train_friends, LD.train_sim,
        LD.train_rating
    ]
    Train_data = [np.reshape(x, [-1, 1]) for x in Train_data]

    Test_data = [
        LD.test_user, LD.test_item, LD.test_friends, LD.test_sim,
        LD.test_rating