Example #1
0
val_X_numerical, val_X_categorical = criteo.get_x_numerical(
    val_X), criteo.get_x_categorical(val_X)
test_X_numerical, test_X_categorical = criteo.get_x_numerical(
    test_X), criteo.get_x_categorical(test_X)
numerical_count = criteo.get_numerical_count()
categorical_count = criteo.get_categorical_count()
hash_size = criteo.get_hash_size()

# Step 2: Build the recommender, which provides search space
# Step 2.1: Setup mappers to handle inputs
dense_input_node = Input(shape=[numerical_count])
sparse_input_node = Input(shape=[categorical_count])
dense_feat_emb = DenseFeatureMapper(num_of_fields=numerical_count,
                                    embedding_dim=2)(dense_input_node)
sparse_feat_emb = SparseFeatureMapper(num_of_fields=categorical_count,
                                      hash_size=hash_size,
                                      embedding_dim=2)(sparse_input_node)

# Step 2.2: Setup interactors to handle models
attention_output = SelfAttentionInteraction()(
    [dense_feat_emb, sparse_feat_emb])
bottom_mlp_output = MLPInteraction()([dense_feat_emb])
top_mlp_output = MLPInteraction()([attention_output, bottom_mlp_output])

# Step 2.3: Setup optimizer to handle the target task
output = CTRPredictionOptimizer()(top_mlp_output)
model = CTRRecommender(inputs=[dense_input_node, sparse_input_node],
                       outputs=output)

# Step 3: Build the searcher, which provides search algorithm
searcher = Search(
Example #2
0
]
train_y = mini_criteo['y']
val_X, val_y = train_X, train_y

# build the pipeline.
dense_input_node = Input(shape=[13])
sparse_input_node = Input(shape=[26])
dense_feat_emb = DenseFeatureMapper(num_of_fields=13,
                                    embedding_dim=2)(dense_input_node)

# TODO: preprocess data to get sparse hash_size
sparse_feat_emb = SparseFeatureMapper(num_of_fields=26,
                                      hash_size=[
                                          1444, 555, 175781, 128509, 306, 19,
                                          11931, 630, 4, 93146, 5161, 174835,
                                          3176, 28, 11255, 165206, 11, 4606,
                                          2017, 4, 172322, 18, 16, 56456, 86,
                                          43356
                                      ],
                                      embedding_dim=2)(sparse_input_node)

attention_output = SelfAttentionInteraction()(
    [dense_feat_emb, sparse_feat_emb])
bottom_mlp_output = MLPInteraction()([dense_feat_emb])
top_mlp_output = MLPInteraction()([attention_output, bottom_mlp_output])

output = PointWiseOptimizer()(top_mlp_output)
model = CTRRecommender(inputs=[dense_input_node, sparse_input_node],
                       outputs=output)

# AutoML search and predict.