Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an ML app instead of MLHandler template #640

Open
sanand0 opened this issue Nov 14, 2022 · 2 comments
Open

Create an ML app instead of MLHandler template #640

sanand0 opened this issue Nov 14, 2022 · 2 comments
Assignees

Comments

@sanand0
Copy link
Contributor

sanand0 commented Nov 14, 2022

There are 4 use cases (in order of priority)

  1. Developer: Use the API, with an interface and code generation -- like POSTMan
  2. Data scientist: Optimize the model
  3. Data Consultant: Explainable AI
  4. Data engineer: Connect to data source

When creating an app, use apps/admin2 as a reference:

  • You can import apps within apps
  • End all url, schedule, alert keys with -$* to allow multiple imports
  • You can specify arguments in the import and use them in the app
import:
  my-ml-app:
    path: $GRAMEXAPPS/mlapp/gramex.yaml
    YAMLURL: /$YAMLURL/ml-app-page/        # URL to show the admin page at
    MLAPP_KWARGS:
      handler: my-mlhandler
      # anything-else-related-to-configuring-the-app, not the handler, comes here

url:
  my-mlhandler:
    pattern: /ml/
    handler: MLHandler
    # ...

Use gramex.conf to read the configuration.

@jaidevd
Copy link
Member

jaidevd commented Nov 15, 2022

Download a dataset here: https://gramener.com/gramex/guide/mlhandler/titanic?_download=titanic.csv&_format=csv

Use this config to test the app:

url:
  mlhandler-tutorial:
    pattern: /$YAMLURL/ml
    handler: MLHandler
    kwargs:
      data:
        url: $YAMLPATH/titanic.csv  # Path to the training dataset

      # Path where the serialized model, training data and configuration is
      # saved
      config_dir: $YAMLPATH

      model:
        # The classification or regression algorithm to use
        class: LogisticRegression

        # The column to predict
        target_col: Survived

        # Columns to ignore during training
        exclude: [PassengerId, Ticket, Cabin, Name]

        # Columns to be treated as categorical variables
        cats: [Embarked, SibSp, Parch, Pclass, Sex]

import:
  ml:
    path: $GRAMEXAPPS/ml/gramex.yaml
    YAMLURL: $YAMLURL/app/
    MLAPP_KWARGS:
      key: mlhandler-tutorial
      title: My ML App

@sanand0
Copy link
Contributor Author

sanand0 commented Nov 15, 2022

Starting with this screen:

image

  • Display the URL that we'll be taken to on clicking ./ml. This should be copy-able. We're generating the URL and letting users know what the URL should be
  • Create the API spec as OpenAPI
  • Evaluate rendering the API spec with a library, perhaps Swagger UI, but ideally more componentized / customizable
  • Create an interface that displays how to interact with the REST API via curl, python (node, etc later) (like below)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants