Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/recommendations/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- kind: app
name: recommendations
27 changes: 27 additions & 0 deletions examples/recommendations/implementations/models/basic_embedding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import tensorflow as tf


def create_estimator(run_config, model_config):
user_id_index = model_config["aggregates"]["user_id_index"]
movie_id_index = model_config["aggregates"]["movie_id_index"]

feature_columns = [
tf.feature_column.embedding_column(
tf.feature_column.categorical_column_with_identity(
"user_id_indexed", len(user_id_index)
),
model_config["hparams"]["embedding_size"],
),
tf.feature_column.embedding_column(
tf.feature_column.categorical_column_with_identity(
"movie_id_indexed", len(movie_id_index)
),
model_config["hparams"]["embedding_size"],
),
]

return tf.estimator.DNNRegressor(
feature_columns=feature_columns,
hidden_units=model_config["hparams"]["hidden_units"],
config=run_config,
)
5 changes: 5 additions & 0 deletions examples/recommendations/resources/apis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- kind: api
name: rating-predictor
model_name: basic_embedding
compute:
replicas: 1
24 changes: 24 additions & 0 deletions examples/recommendations/resources/environments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- kind: environment
name: dev
data:
type: csv
path: s3a://cortex-examples/movie-ratings.csv
csv_config:
header: true
schema: ['user_id','movie_id','rating','timestamp']

- kind: raw_column
name: user_id
type: STRING_COLUMN

- kind: raw_column
name: movie_id
type: STRING_COLUMN

- kind: raw_column
name: rating
type: FLOAT_COLUMN

- kind: raw_column
name: timestamp
type: INT_COLUMN
19 changes: 19 additions & 0 deletions examples/recommendations/resources/models.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- kind: model
name: basic_embedding
type: regression
target_column: rating
feature_columns:
- user_id_indexed
- movie_id_indexed
aggregates:
- user_id_index
- movie_id_index
hparams:
embedding_size: 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split embedding_size for each of the features?

hidden_units: [128]
data_partition_ratio:
training: 0.8
evaluation: 0.2
training:
batch_size: 50
num_steps: 8000
31 changes: 31 additions & 0 deletions examples/recommendations/resources/transformed_columns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- kind: aggregate
name: user_id_index
aggregator: cortex.index_string
inputs:
columns:
col: user_id

- kind: transformed_column
name: user_id_indexed
transformer: cortex.index_string
inputs:
columns:
text: user_id
args:
index: user_id_index

- kind: aggregate
name: movie_id_index
aggregator: cortex.index_string
inputs:
columns:
col: movie_id

- kind: transformed_column
name: movie_id_indexed
transformer: cortex.index_string
inputs:
columns:
text: movie_id
args:
index: movie_id_index
8 changes: 8 additions & 0 deletions examples/recommendations/samples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"samples": [
{
"user_id": "71",
"movie_id": "91529"
}
]
}