Package: auger.ai.predict
Installpip install auger.ai.predictAuger.ai.predictAuger ML predict Python API and command line interfaceDownload exported modelTo download exported model you can use:Auger.ai web :https://app.auger.aiauger.ai command line interface:https://pypi.org/project/auger.ai/Predict using exported modelUnzip file with modelRun 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 fileFor example:python ./models/export_9BB0BFA3D368454/client.py --path_to_predict ./files/baseball_predict.csv --model_path ./models/export_9BB0BFA3D368454/modelClient.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 targetAuger.ai.predict Python APIauger_ml.model_exporter.ModelExporterModelExporter provides interface to Auger predict API.ModelExporter(options)- constructs ModelExporter instance.options - optional parameters. Must be {} for nowpredict_by_model(model_path, path_to_predict=None, records=None, features=None, threshold=None)- produce prediction based on exported model and datamodel_path - folder which contain model.pkl.gz filepath_to_predict - data to predictrecords - 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 Nonethreshold - set threshold to produce prediction for classification based on probabilities. proba_ column will be added to prediction result for each target classRETURN: predictions - if path_to_predict is not None, then file in same directory with predcitions, or pandas dataframeExample: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 predictionsload_model(model_path)- load model from file.model_path - folder which contain model.pkl.gz fileRETURN: model, timeseries_modelmodel - ML model to call predicttimeseries_model - flag is this timeseries model or notpreprocess_data(model_path, data_path, records=None, features=None)- preprocess data for predict. It will process data same way as train data used for modelmodel_path - folder which contain model.pkl.gz filedata_path - data to preprocessrecords - 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 NoneRETURN: X_test, Y_test, target_categoricalsX_test - data to call predictY_test - array with target valuestarget_categoricals - dict with categories for target, may be used to get actual target valuesExample: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:])