This notebook goes through the steps of setting up and running inference on Models that weren't generated in SageWorks.
model = Model("the old model")
model.onboard()
Answer all the Model onboarding questions, the tricky one is 'features' (note: capitalization matters)
end = Endpoint("the old endpoint")
end.onboard()
Answer all the onboard questions, if you're asked for input put the Model Name.
After this is done, you'll need follow this notebook for 'remapping' the evaluation data into a form that the old model can use.
import os
# Set the environment variable
os.environ['SAGEWORKS_CONFIG'] = '/Users/briford/.sageworks/scp_sandbox.json'
# Grab the features from the model (this will be set during onboard())
from sageworks.api.model import Model
model = Model("LogS-pH7-Class-0-231025")
target = model.target()
print(target)
features = model.features()
print(f"{features[:5]}...")
# Grab the evaluation data
from sageworks.api.feature_set import FeatureSet
fs = FeatureSet("solubility_featurized_fs")
training_view = fs.view("training").table
eval_data = fs.query(f"select * from {training_view} where training=0")
data_columns = eval_data.columns
def build_map(data_columns, features):
map = dict()
for f in features:
if f.lower() in data_columns:
map[f.lower()] = f
return map
map = build_map(data_columns, features)
map["class"] = target # Add the target variable name change
# Rename the feature and target columns to 'match' what the Legacy Model expects
eval_data.rename(columns=map, inplace=True)
# Grab the Legacy Endpoint
from sageworks.api.endpoint import Endpoint
end = Endpoint("LogS-pH7-Class-0-231025")
# Run inference on the Legacy Endpoint
end.inference(eval_data, capture_uuid="2024_03_19_holdout")
# This might not be strictly necssary but it will make sure the details are up to date
model.details(recompute=True)