Esempio n. 1
0
# ===================== Part 5: Collaborative Filtering Gradient Regularization =====================
# Once your cost matches up with ours, you should proceed to implement
# regularization for the gradient.
print('Checking Gradients (with regularization) ...')

# Check gradients by running check_cost_function
check_cost_function(1.5)

input('Program paused. Press ENTER to continue')

# ===================== Part 6: Entering ratings for a new user =====================
# Before we will train the collaborative filtering model, we will first
# add ratings that correspond to a new user that we just observed. This
# part of the code will also allow you to put in your own ratings for the
# movies in our dataset!
movie_list = load_movie_list()

# Initialize my ratings
my_ratings = np.zeros(len(movie_list))

# Check the file movie_ids.txt for id of each movie in our dataset
# For example, Toy Story (1995) has ID 0, so to rate it "4", you can set
my_ratings[0] = 4

# Or suppose did not enjoy Silence of the lambs (1991), you can set
my_ratings[97] = 2

# We have selected a few movies we liked / did not like and the ratings we
# gave are as follows:
my_ratings[6] = 3
my_ratings[11] = 5
Esempio n. 2
0
#

print('Checking Gradients (with regularization) ...')

# Check gradients by running check_cost_function
cf.check_cost_function(1.5)

input('Program paused. Press ENTER to continue')

# ===================== Part 6: Entering ratings for a new user =====================
# Before we will train the collaborative filtering model, we will first
# add ratings that correspond to a new user that we just observed. This
# part of the code will also allow you to put in your own ratings for the
# movies in our dataset!
#
movie_list = lm.load_movie_list()

# Initialize my ratings
my_ratings = np.zeros(len(movie_list))

# Check the file movie_ids.txt for id of each movie in our dataset
# For example, Toy Story (1995) has ID 0, so to rate it "4", you can set
my_ratings[0] = 4

# Or suppose did not enjoy Silence of the lambs (1991), you can set
my_ratings[97] = 2

# We have selected a few movies we liked / did not like and the ratings we
# gave are as follows:
my_ratings[6] = 3
my_ratings[11] = 5
Esempio n. 3
0
print('Cost at loaded parameters (lambda = 1.5): {} \n (this value should be \
      about 31.34)'.format(J))

input('\nProgram paused. Press enter to continue.\n')

# ======= Part 5: Collaborative Filtering Gradient Regularization ======
print('\nChecking Gradients (with regularization) ... ')

# Check gradients by running checkNNGradients
check_cost_function(1.5)

input('\nProgram paused. Press enter to continue.\n')

# ============== Part 6: Entering ratings for a new user ===============
movie_list = load_movie_list()

# Initialize my ratings
my_ratings = np.zeros(1682)

my_ratings[0] = 4
my_ratings[97] = 2

my_ratings[6] = 3
my_ratings[11] = 5
my_ratings[53] = 4
my_ratings[63] = 5
my_ratings[65] = 3
my_ratings[68] = 5
my_ratings[182] = 4
my_ratings[225] = 5