on 11-09-2022 04:06 PM
In Incorta Notebook:
Add property:
Code sample:
import datarobot as dr
API_KEY = 'NjFhNzNhNzllZjc0ZTljYWEyMDBkZjgxOnBCamZ6dzcvUHVWaEprejhja3VZOXdxaEU0Nm5wSVQ5bDRCeG5CanFjRnM9'
BATCH_PREDICTIONS_URL = 'https://app2.datarobot.com/api/v2'
DEPLOYMENT_ID = '61ca66aebea608e72b70e008'
dr.Client(
endpoint=BATCH_PREDICTIONS_URL,
token=API_KEY,
user_agent_suffix='IntegrationSnippet-ApiClient'
)
df = read('CreditRisk.CreditRiskPredPrepared')
tenant_path = spark.conf.get("ml.incorta.tenant_path")
pdf = df.toPandas()
pdf.to_csv(tenant_path + '/data/CreditRiskPredPrepared.csv')
in_path = tenant_path + '/data/CreditRiskPredPrepared.csv'
out_path = tenant_path + '/data/CreditRiskPredPrediction.csv'
dr.BatchPredictionJob.score(deployment = DEPLOYMENT_ID,
intake_settings = {
'type': 'localFile',
'file': in_path
},
output_settings = {
'type': 'localFile',
'path': out_path
})
import pandas as pd
pdf_data = pd.read_csv(out_path)
pdf2 = pd.DataFrame(pdf_data, columns = ['RiskStatusPrediction_PREDICTION'])
# concat prediction data frame and original data frame
result = pd.concat([pdf, pdf2], axis=1)
# create spark data frame
df_output=spark.createDataFrame(result)
incorta.head(df_output, 10)
save(df_output)