gramener / gramex

A visual analytics platform to build data-based web apps with less code.
https://gramener.com/gramex/guide/
Other
142 stars 57 forks source link

Create an ML app instead of MLHandler template #640

Open sanand0 opened 2 years ago

sanand0 commented 2 years ago

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:

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 commented 2 years ago

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 commented 2 years ago

Starting with this screen:

image

image