Datagran allows you to upload a python Scikit-Learn or Tensor Flow trained model.

To do so, go to your project and select Models.

Screen Shot 2021-10-13 at 1.21.36 PM.png

Then upload your trained model into Datagran:

Screen Shot 2021-10-13 at 1.21.55 PM.png

How does Custom Model Work?

When a custom model operator runs; it has 2 main roles:

Dumping the Model

As a quick start; the following code block shows how to create a dump of a model.

import cloudpickle
f = open('./model.cloudpickle', 'wb')
cloudpickle.dump(model, f)

You can upload a model that has complex sklearn pipelines including your custom transformers. The following code block shows how to create such a pipeline. Once the model is ready, you can use the code above to dump the model. (The full example of this code can be found on this notebook:

class CustomTransformer(BaseEstimator):
    This CustomTransformer only returns the incoming values as it is
    The goal of this transformer is to demonstrate custom transformers are supported when deployed to Datagran platform with cloudpickle library
    def fit(self, X, y = None):
        return self
    def transform(self, X, y = None):
        return X

numericTransfomer = Pipeline(
        ("imputer", SimpleImputer(strategy="median")),
        ("scaler", StandardScaler()),
        ('CustomTransformer', CustomTransformer())

categoricalTransformer = OneHotEncoder(handle_unknown="ignore")

preprocessor = ColumnTransformer(
        ("num", numericTransfomer, numericCols),
        ("cat", categoricalTransformer, categoricalCols),

model = Pipeline(
    steps=[("preprocessor", preprocessor), ("classifier", LogisticRegression())]
), y_train)