Import Predictions to Rasgo

_Please see the accompanying demonstration video, _linked here.

Once you have imported data into Rasgo and created features, created collections of those features, transformed them and extracted modeling data, you are ready to build and deploy models. While this modeling and deployment happens outside of Rasgo, you can still serve data to the model for prediction from Rasgo. Beyond using the model’s predictions for decision making and business use, you should save the predictions back into your data warehouse for additional analysis and ongoing model monitoring. Rasgo makes it easy to save prediction back to Rasgo and update the features as new predictions are made.\

To start, assuming a model object exists in Python, we will need to read the data from Rasgo for scoring.\

First authenticate with Rasgo

rasgo = pyrasgo.connect(config.api_key)

Then pull the data between day1 and day2 from Rasgo

today = pd.to_datetime("today").strftime("%Y-%m-%d") df ='845', filters={"DATE":f"BETWEEN '{day1}' AND '{day2}'"})

Score the data and create a new dataframe containing the dimensions and prediction

prediction = model.predict(df[training_vars]) prediction_df = df[['DIMENSION1', 'DIMENSION2'']].copy() prediction_df['PREDICTION'] = prediction

Publish this data as a data source in Rasgo to a specified table stored in source_table with source name data_source_name

source = rasgo.publish.source_data(source_type="dataframe", df=prediction_df, data_source_name=data_source_name, data_source_table_name=source_table, if_exists='append')

And publish features from this source

data_source_id = dimensions = ['DIMENSION1', 'DIMENSION2'] features = ['PREDICTION'] granularity = ['granularity1', 'granularity2'] tags = ['tag1', 'tag2'] feature_set_name = 'production predictions' featureset = rasgo.publish.features_from_source( data_source_id = data_source_id, features = features, dimensions = dimensions, granularity = granularity, tags = tags, feature_set_name = feature_set_name, if_exists="edit")

You have now created a feature containing the predictions from your model for all data between day1 and day2. As you make further predictions, you can simply rerun this process from reading the data from Rasgo through to publishing features from source. The argument if_exists causes Rasgo to update the source and features instead of replacing them.\

Last updated