Skip to content

Unsupervised Clustering with Keras #648

@gaoxx643

Description

@gaoxx643

Is your feature request related to a problem? Please describe.
Pattern recognition in user behavior data is frequently performed by DiDi's data scientists to help the decision makers better understand the dynamics of demand and supply.

Describe the solution you'd like
Autoencoder is desired as it is a data compression algorithm that can help extract the patterns in data.

Code Snippet

nfeat=144
encoding_dim = 2
#layers number
input_dim = tf.keras.Input(shape=(144,))
#encoded1 = tf.keras.layers.Dense(100, activation=tf.compat.v2.keras.activations.relu, name='encoded1')(input_dim)
#encoded1 = tf.keras.layers.Dense(100, activation='relu', name='encoded1')(input_dim)
encoded2 = tf.keras.layers.Dense(7, activation='relu', name='encoded2')(input_dim)
#decoded1 = tf.keras.layers.Dense(100, activation='relu', name='decoded1')(encoded2)
decoded2 = tf.keras.layers.Dense(144, activation='relu', name='decoded2')(encoded2)

model = tf.keras.Model(inputs=input_dim, outputs=decoded2)
model.summary()
model.compile("adam",
              loss='mean_squared_error',
              metrics=['accuracy'])
history = model.fit(x,x,epochs=EPOCHES,
          batch_size=BATCH_SIZE,
          verbose=1)

encoded_layer_model = tf.keras.Model(inputs=model.input,
                           outputs=model.get_layer('encoded2').output)
x_encoded = encoded_layer_model.predict(x)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions