Skip to main content

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:

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:])
    

Release files for auger.ai.predict 1.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for auger.ai.predict 1.1.13
File Interpreter ABI Platform
auger.ai.predict-1.1.13-py3-none-any.whl Python 3 none any Details

Release files / auger.ai.predict-1.1.13-py3-none-any.whl

Download URL auger.ai.predict-1.1.13-py3-none-any.whl
Size 134.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66aaeabd0c83f7f3750d97c76c117c008bce1d0baa28762ff131cfcacfc57589
BLAKE2b-256 checksum
How to use checksums
c48260345f13b8e2cdfc2773d9bd732eb5bf578ff6b91a7b7cb95d8807e5f1f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.1.13 This release

1 release file

1.1.12

1 release file

1.1.7

1 release file

1.1.1

1 release file

1.0.110

1 release file

1.0.109

1 release file

1.0.104

1 release file

1.0.103

1 release file

1.0.102

1 release file

1.0.101

1 release file

1.0.98

1 release file

1.0.97

1 release file

1.0.96

1 release file

1.0.94

1 release file

1.0.93

1 release file

1.0.92

1 release file

1.0.91

1 release file

1.0.90

1 release file

1.0.88

1 release file

1.0.87

1 release file

1.0.86

1 release file

1.0.85

1 release file

1.0.83

1 release file

1.0.82

1 release file

1.0.80

1 release file

1.0.79

1 release file

1.0.76

1 release file

1.0.75

1 release file

1.0.73

1 release file

1.0.72

1 release file

1.0.71

1 release file

1.0.70

1 release file

1.0.69

1 release file

1.0.63

1 release file

1.0.62

1 release file

1.0.61

1 release file

1.0.60

1 release file

1.0.59

1 release file

1.0.57

1 release file

1.0.43

1 release file

1.0.39

1 release file

1.0.27

1 release file

1.0.26

1 release file

1.0.17

1 release file

1.0.15

1 release file

1.0.14

1 release file

1.0.12

1 release file

1.0.11

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page