auger.ai.predict


Nameauger.ai.predict JSON
Version 1.1.12 PyPI version JSON
download
home_pagehttps://github.com/deeplearninc/auger-ai
SummaryAuger ML predict python and command line interface
upload_time2024-01-20 18:12:29
maintainer
docs_urlNone
authorDeep Learn, Inc.
requires_python>=3
licenseApache
keywords augerai auger ai machine learning automl deeplearn api sdk prediction predict
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Install
```
pip install auger.ai.predict
```

# Auger.ai.predict
Auger ML predict Python API and command line interface


# Download exported model

To download exported model you can use:

- Auger.ai web : https://app.auger.ai
- auger.ai command line interface: https://pypi.org/project/auger.ai/

# Predict using exported model

- Unzip file with model
- Run client.py from model folder:

python <model_path>/client.py --path_to_predict <data_path> --model_path model_path

--path_to_predict - path to file with data to predict. Should contain features used to train model
--model_path - folder which contain model.pkl.gz file

For example:

python ./models/export_9BB0BFA3D368454/client.py --path_to_predict ./files/baseball_predict.csv --model_path ./models/export_9BB0BFA3D368454/model

## Client.py command line parameters

  --path_to_predict Path to file for predict

  --model_path Path to folder with model

  --threshold Threshold to use for calculate target using predict_proba

  --score 0/1 Build scores after prediction if prediction data contain actual target

# Auger.ai.predict Python API
## auger_ml.model_exporter.ModelExporter
ModelExporter provides interface to Auger predict API.

- **ModelExporter(options)** - constructs ModelExporter instance.
  - options - optional parameters. Must be {} for now

- **predict_by_model(model_path, path_to_predict=None, records=None, features=None, threshold=None)** - produce prediction based on exported model and data
  - model_path - folder which contain model.pkl.gz file
  - path_to_predict - data to predict
  - records - data to predict: list of lists. path_to_predict should be None in this case. For example: [[0.1,0.2],[0.1, 0.3]]
  - features - feature names for records. Used only when records is not None
  - threshold - set threshold to produce prediction for classification based on probabilities. proba_ column will be added to prediction result for each target class

  - RETURN: predictions - if path_to_predict is not None, then file in same directory with predcitions, or pandas dataframe

  Example:
  ```
  def predict_by_model_example(path_to_predict=None, threshold=None, model_path=None):
      #features is an array mapping your data to the feature, your feature and data should be
      #the same that you trained your model with.
      #If it is None, features read from model/options.json file
      #['feature1', 'feature2']
      features = None 

      # data is an array of arrays to get predictions for, input your data below
      # each record should contain values for each feature
      records = [[],[]]

      if path_to_predict:
          path_to_predict=os.path.abspath(path_to_predict)

      predictions = ModelExporter({}).predict_by_model(
          records=records,
          model_path=model_path,
          path_to_predict=path_to_predict,
          features=features,
          threshold=threshold
      )

      return predictions
  ```

- **load_model(model_path)** - load model from file.
  - model_path - folder which contain model.pkl.gz file

  - RETURN: model, timeseries_model
    - model - ML model to call predict    
    - timeseries_model - flag is this timeseries model or not

- **preprocess_data(model_path, data_path, records=None, features=None)** - preprocess data for predict. It will process data same way as train data used for model
  - model_path - folder which contain model.pkl.gz file
  - data_path - data to preprocess
  - records - data to predict: list of lists. data_path should be None in this case. For example: [[0.1,0.2],[0.1, 0.3]]
  - features - feature names for records. Used only when records is not None

  - RETURN: X_test, Y_test, target_categoricals
    - X_test - data to call predict    
    - Y_test - array with target values
    - target_categoricals - dict with categories for target, may be used to get actual target values

  Example:
  ```
  def predict_by_model_example(path_to_predict=None, model_path=None):
      model_exporter = ModelExporter({})
      model, timeseries_model = model_exporter.load_model(model_path)
      X_test, Y_test, target_categoricals = model_exporter.preprocess_data(model_path, 
          data_path=path_to_predict)

      results = model.predict(X_test)

      # If your target is categorical you can translate predicted values back to original:
      # target_feature = "target"
      # categories = target_categoricals[target_feature]['categories']
      # results = map(lambda x: categories[int(x)], results)
  ```

  Example for timeseries data:
  ```
  def predict_by_model_timeseries_example(path_to_predict=None, model_path=None):
      model_exporter = ModelExporter({})
      model, timeseries_model = model_exporter.load_model(model_path)
      X_test, Y_test, target_categoricals = model_exporter.preprocess_data(model_path, 
          data_path=path_to_predict)

      if timeseries_model:
          results = model.predict((X_test, Y_test, False))[-1:]
      else:
          results = model.predict(X_test.iloc[-1:])
  ```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deeplearninc/auger-ai",
    "name": "auger.ai.predict",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "augerai auger ai machine learning automl deeplearn api sdk prediction predict",
    "author": "Deep Learn, Inc.",
    "author_email": "augerai@dplrn.com",
    "download_url": "",
    "platform": "any",
    "description": "# Install\n```\npip install auger.ai.predict\n```\n\n# Auger.ai.predict\nAuger ML predict Python API and command line interface\n\n\n# Download exported model\n\nTo download exported model you can use:\n\n- Auger.ai web : https://app.auger.ai\n- auger.ai command line interface: https://pypi.org/project/auger.ai/\n\n# Predict using exported model\n\n- Unzip file with model\n- Run client.py from model folder:\n\npython <model_path>/client.py --path_to_predict <data_path> --model_path model_path\n\n--path_to_predict - path to file with data to predict. Should contain features used to train model\n--model_path - folder which contain model.pkl.gz file\n\nFor example:\n\npython ./models/export_9BB0BFA3D368454/client.py --path_to_predict ./files/baseball_predict.csv --model_path ./models/export_9BB0BFA3D368454/model\n\n## Client.py command line parameters\n\n  --path_to_predict Path to file for predict\n\n  --model_path Path to folder with model\n\n  --threshold Threshold to use for calculate target using predict_proba\n\n  --score 0/1 Build scores after prediction if prediction data contain actual target\n\n# Auger.ai.predict Python API\n## auger_ml.model_exporter.ModelExporter\nModelExporter provides interface to Auger predict API.\n\n- **ModelExporter(options)** - constructs ModelExporter instance.\n  - options - optional parameters. Must be {} for now\n\n- **predict_by_model(model_path, path_to_predict=None, records=None, features=None, threshold=None)** - produce prediction based on exported model and data\n  - model_path - folder which contain model.pkl.gz file\n  - path_to_predict - data to predict\n  - records - data to predict: list of lists. path_to_predict should be None in this case. For example: [[0.1,0.2],[0.1, 0.3]]\n  - features - feature names for records. Used only when records is not None\n  - threshold - set threshold to produce prediction for classification based on probabilities. proba_ column will be added to prediction result for each target class\n\n  - RETURN: predictions - if path_to_predict is not None, then file in same directory with predcitions, or pandas dataframe\n\n  Example:\n  ```\n  def predict_by_model_example(path_to_predict=None, threshold=None, model_path=None):\n      #features is an array mapping your data to the feature, your feature and data should be\n      #the same that you trained your model with.\n      #If it is None, features read from model/options.json file\n      #['feature1', 'feature2']\n      features = None \n\n      # data is an array of arrays to get predictions for, input your data below\n      # each record should contain values for each feature\n      records = [[],[]]\n\n      if path_to_predict:\n          path_to_predict=os.path.abspath(path_to_predict)\n\n      predictions = ModelExporter({}).predict_by_model(\n          records=records,\n          model_path=model_path,\n          path_to_predict=path_to_predict,\n          features=features,\n          threshold=threshold\n      )\n\n      return predictions\n  ```\n\n- **load_model(model_path)** - load model from file.\n  - model_path - folder which contain model.pkl.gz file\n\n  - RETURN: model, timeseries_model\n    - model - ML model to call predict    \n    - timeseries_model - flag is this timeseries model or not\n\n- **preprocess_data(model_path, data_path, records=None, features=None)** - preprocess data for predict. It will process data same way as train data used for model\n  - model_path - folder which contain model.pkl.gz file\n  - data_path - data to preprocess\n  - records - data to predict: list of lists. data_path should be None in this case. For example: [[0.1,0.2],[0.1, 0.3]]\n  - features - feature names for records. Used only when records is not None\n\n  - RETURN: X_test, Y_test, target_categoricals\n    - X_test - data to call predict    \n    - Y_test - array with target values\n    - target_categoricals - dict with categories for target, may be used to get actual target values\n\n  Example:\n  ```\n  def predict_by_model_example(path_to_predict=None, model_path=None):\n      model_exporter = ModelExporter({})\n      model, timeseries_model = model_exporter.load_model(model_path)\n      X_test, Y_test, target_categoricals = model_exporter.preprocess_data(model_path, \n          data_path=path_to_predict)\n\n      results = model.predict(X_test)\n\n      # If your target is categorical you can translate predicted values back to original:\n      # target_feature = \"target\"\n      # categories = target_categoricals[target_feature]['categories']\n      # results = map(lambda x: categories[int(x)], results)\n  ```\n\n  Example for timeseries data:\n  ```\n  def predict_by_model_timeseries_example(path_to_predict=None, model_path=None):\n      model_exporter = ModelExporter({})\n      model, timeseries_model = model_exporter.load_model(model_path)\n      X_test, Y_test, target_categoricals = model_exporter.preprocess_data(model_path, \n          data_path=path_to_predict)\n\n      if timeseries_model:\n          results = model.predict((X_test, Y_test, False))[-1:]\n      else:\n          results = model.predict(X_test.iloc[-1:])\n  ```\n\n\n",
    "bugtrack_url": null,
    "license": "Apache",
    "summary": "Auger ML predict python and command line interface",
    "version": "1.1.12",
    "project_urls": {
        "Homepage": "https://github.com/deeplearninc/auger-ai"
    },
    "split_keywords": [
        "augerai",
        "auger",
        "ai",
        "machine",
        "learning",
        "automl",
        "deeplearn",
        "api",
        "sdk",
        "prediction",
        "predict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de5f3b399fc5b92d7b534d95c05c5db362e1cad938b67f8dd0f138519564edb5",
                "md5": "c76864473be2a06d7d497cd80b8fdb29",
                "sha256": "b6d0520145834104fbf3e2846c6567aa0b7485fd5d6ea7d49e007c54ec3746bc"
            },
            "downloads": -1,
            "filename": "auger.ai.predict-1.1.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c76864473be2a06d7d497cd80b8fdb29",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 134519,
            "upload_time": "2024-01-20T18:12:29",
            "upload_time_iso_8601": "2024-01-20T18:12:29.634075Z",
            "url": "https://files.pythonhosted.org/packages/de/5f/3b399fc5b92d7b534d95c05c5db362e1cad938b67f8dd0f138519564edb5/auger.ai.predict-1.1.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-20 18:12:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deeplearninc",
    "github_project": "auger-ai",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "lcname": "auger.ai.predict"
}
        
Elapsed time: 0.17978s