Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now you can use `process` on new data with the fetched Pipeline!

Quick Example using KerasPipe

Using snippets from the DTI created mnistExample, We'll show quickly how you can use the KerasPipe MLLeafPipe.

Suppose we have already prepapred data XTrain, and YTrain. We can build a tensorflow keras model and use a KerasPipe. First, define your model as you usually would:

Code Block
import tensorflow as tf

# Build tensorflow model.
one_layer_simple_model = tf.keras.Sequential([
    tf.keras.layers.Reshape((28*28,), input_shape=(28,28)),
    tf.keras.layers.Dense(1000, activation='relu'),
    tf.keras.layers.Dense(10, activation='softmax')
])
one_layer_simple_model.compile(optimizer='Adam', loss='categorical_crossentropy')

Then, we create a KerasPipe Type using this model definition using the 'upsertNativeModel' function. This function creates a new KerasPipe Type using the model definition object passed with the 'model' parameter.

Code Block
# Create the KerasPipe using the upsertNativeModel method
keras_pipe = c3.KerasPipe().upsertNativeModel(model=model)
# Set the epoch number to an appropriate amount for your model and data.
keras_pipe.technique.numEpochs = 10

Then we can train the model as we did with the sklearn model:

Code Block
trained_pipe = keras_pipe.train(input=train_X, targetOutput=train_Y)

And finally, we can use the trained pipe with the 'process' function:

Code Block
result = trained_pipe.process(input=test_X)


Example Notebooks

Several jupyter notebooks exist which demonstrate the usage of these Pipeline types. We list directions to each here.

...