(no subject)

Inbox

William Harrigan

10:08 AM (7 minutes ago)
to me
Input A (input_layer_8) ───────────────┐ This is an input of the user number.
                                      │
                          ┌─────────▼──────────┐
                          │ Embedding (200-d) │ ← vocab_size = 10,000 -> Our model generates an embedding from the ratings that user number rated movies with.
                          └─────────┬──────────┘
                                    │
                          ┌────────▼──────────┐
                          │ Reshape (200,)    │ -> We reshape the user embedding so that we can compare it to the embedding of a movie.
                          └────────┬──────────┘
                                   │
Input B (input_layer_9) ───────────────┐ Here is where we input the movie number. Each movie was given a rating of 1-5 by over 10,000 netflix user.
                                      │
                          ┌─────────▼──────────┐
                          │ Embedding (200-d) │ ← vocab_size = 2,000 -> Again, our model takes the movie number and generates an embedding based off the ratings users gave that movie.
                          └─────────┬──────────┘
                                    │
                          ┌────────▼──────────┐
                          │ Reshape (200,)    │ -> Here our model reshapes the embedding to be the same shape as our user embedding so we can compute a dot product.
                          └────────┬──────────┘
                                   │
         ┌────────────────────────▼────────────────────────────┐
         │ Dot Product (dot_4 → shape=(1,))                    │ -> The dot product compares the user and movie embeddings and produces a number that represents if
         └────────────────────────┬────────────────────────────┘    the user and the movie are a good match. A good match is represented by a high dot product and is determined both by what other movies the user liked and how other users rated the movie.
                                   │
                ┌────────────────────────▼────────────────────────┐
                │ Concatenate([reshape_8, reshape_9, dot_4])      │ → shape = (401,) -> Here we combine the user embedding with the movie embedding and the dot product.
                └────────────────────────┬────────────────────────┘
                                         │
                          ┌────────────▼────────────┐
                          │ Dropout (rate=0.X)       │ -> This component of our model learns patterns from the combined embedding of our user movie and dot product.
                          └────────────┬────────────┘
                                       │
                          ┌───────────▼───────────┐
                          │ Dense (401 → 256)     │ ← ReLU -> ReLU stands for rectified linear unit. this component determines if the patterns learned in the last component improve our model's overall understanding of relationships between movies and users. This is important to ignoring outliers or relationships that are not representative of rating trends.
                          └───────────┬───────────┘
                                      │
                          ┌────────────▼────────────┐
                          │ Dropout (rate=0.X)       │ -> We have another drop out layer to make sure that our model is learning from the strong user/ movie relationships.
                          └────────────┬────────────┘
                                       │
                          ┌───────────▼───────────┐
                          │ Dense (256 → 1)       │ ← Output (e.g., regression) -> This last layer takes the information learned and outputs a prediction for what a user will rate a movie. The model compares the prediction to our observed data and self corrects.
                          └───────────────────────┘


On Fri, Jun 27, 2025 at 9:50 AM William Harrigan <wlh3@hawaii.edu> wrote:

On Wed, Jun 25, 2025 at 11:10 AM William Harrigan <wlh3@hawaii.edu> wrote:
Input A (input_layer_8) ───────────────┐
                                       │
                             ┌─────────▼──────────┐
                             │ Embedding (200-d)  │  ← vocab_size = 10,000
                             └─────────┬──────────┘
                                       │
                            ┌──────────▼──────────┐
                            │   Reshape (200,)    │
                            └──────────┬──────────┘
                                       │
                                       │
Input B (input_layer_9) ───────────────┐
                                       │
                             ┌─────────▼──────────┐
                             │ Embedding (200-d)  │  ← vocab_size = 2,000
                             └─────────┬──────────┘
                                       │
                            ┌──────────▼──────────┐
                            │   Reshape (200,)    │
                            └──────────┬──────────┘
                                       │
         ┌─────────────────────────────▼────────────────────────────┐
         │                 Dot Product (dot_4 → shape=(1,))          │
         └─────────────────────────────┬────────────────────────────┘
                                       │
             ┌────────────────────────▼────────────────────────┐
             │ Concatenate([reshape_8, reshape_9, dot_4])      │  → shape = (401,)
             └────────────────────────┬────────────────────────┘
                                       │
                         ┌────────────▼────────────┐
                         │     Dropout (rate=0.X)   │
                         └────────────┬────────────┘
                                       │
                          ┌───────────▼───────────┐
                          │ Dense (401 → 256)     │  ← ReLU
                          └───────────┬───────────┘
                                       │
                         ┌────────────▼────────────┐
                         │     Dropout (rate=0.X)   │
                         └────────────┬────────────┘
                                       │
                          ┌───────────▼───────────┐
                          │ Dense (256 → 1)       │  ← Output (e.g., regression)
                          └───────────────────────┘

On Wed, Jun 25, 2025 at 11:01 AM William Harrigan <wlh3@hawaii.edu> wrote:
# Build user and movie embedding matrix
user = Input(shape=(1,))
u = Embedding(n_users, e_dimension, embeddings_initializer='he_normal',
embeddings_regularizer=l2(1e-7))(user) # embedding was 1e-6
u = Reshape((e_dimension,))(u)
movie = Input(shape=(1,))
m = Embedding(n_movies, e_dimension, embeddings_initializer='he_normal',
embeddings_regularizer=l2(1e-7))(movie) # embedding was 1e-6
m = Reshape((e_dimension,))(m)

x = Dot(axes=1)([u, m])
## new : concat user, id along with dot
x = Concatenate()([u, m,x])
x = Dropout(0.2)(x)

# Build last deep learning layers
x = Dense(256, activation='relu')(x)
x = Dropout(0.2)(x)
# x = Dense(128, activation='relu')(x)
# x = Dropout(0.2)(x)
x = Dense(1)(x)

model = Model(inputs=[user, movie], outputs=x)
model.compile(loss='mean_squared_error',
optimizer=Adam(learning_rate=0.003), ## 0.001
metrics=[tf.keras.metrics.RootMeanSquaredError()]
)

# Set up for early stop if the validation loss stop improving for more than 1 epoch
callbacks_list = [
keras.callbacks.EarlyStopping(
monitor='val_loss',
patience=1,
),
keras.callbacks.ModelCheckpoint(
filepath='Model_1.keras', # must end with .keras
monitor='val_loss',
save_best_only=True,
)
]

# Print model info summary
model.summary()

history = model.fit(x=X_train_array, y=y_train, batch_size=64,
epochs=10, # 20
verbose=1,
callbacks=callbacks_list,
validation_data=(X_val_array, y_val)
)

# Save the model (we should make a good habit of always saving our models after training)
model.save("Model_1")

On Wed, Jun 25, 2025 at 10:13 AM William Harrigan <wlh3@hawaii.edu> wrote:

On Mon, Jun 23, 2025 at 11:29 AM William Harrigan <wlh3@hawaii.edu> wrote:
netflix_ratings = {}
current_key = None

with open('/Users/williamharrigan/Downloads/netflix_data/netflix_inspect.txt', 'r') as f:
lines = f.readlines()
for line in lines:
line = line.strip()
if line.endswith(':'):
current_key = line[:-1] # remove the colon
# print(f"Key: {current_key}")
netflix_ratings[current_key] = []
elif current_key is not None:
# print(f"Value: {line}")
netflix_ratings[current_key].append(line)


On Mon, Jun 23, 2025 at 11:08 AM William Harrigan <wlh3@hawaii.edu> wrote:


On Mon, Jun 23, 2025 at 11:00 AM William Harrigan <wlh3@hawaii.edu> wrote:

On Mon, Jun 23, 2025 at 10:30 AM William Harrigan <wlh3@hawaii.edu> wrote: