Python Activity : Invoke Python Method

Hi again,

I think you should avoid reading the same creditcard.csv both in the python function and UiPath

Keep it simple and short.

import joblib
import json

def predict():
    """ 
    This function predicts (Something)
    in_argument : Your input argument
    Returns : Predicted json string to UiPath
    """

    with open(‘./creditcard.csv’, ‘rb’) as input_file:
    bytes = input_file.read()

    model = joblib.load(‘finalized_model.sav’)
    payload = json.loads(in_argument)
    result = model.predict_proba(payload)
    return json.dumps(result.tolist())
  1. Python Scope
  2. Load Python Script
  3. Invoke Python Method (without any parameters) for example you only have to call “predict”
    without any parameters
  4. Get Python Object