Generating model insights
This section describes how to generate and get model insights in AI & Analytics Engine.
For those that are trained successfully, you can generate and get model insights as in the following example:
from aiaengine import Model, ModelInsightType
# get the model we want to generate the insights
model = Model(id='cfbeab51-8d38-4038-a0b9-cd526940fae9')
# generate the insights
model_insights = model.generate_insights()
for insight in model_insights:
print('-' * 80)
print(insight.type)
print(insight.data)
# can get individual insights if generated
feature_importance_insight = model.get_insight(ModelInsightType.FeatureImportance)
print(feature_importance_insight.data)
package com.aiaengine.examples.model;
import com.aiaengine.Engine;
import com.aiaengine.Model;
import com.aiaengine.model.ModelInsight;
import com.aiaengine.model.ModelInsightType;
import com.aiaengine.model.request.GenerateInsightsRequest;
import com.aiaengine.model.request.GetInsightRequest;
import java.io.IOException;
import java.util.List;
public class GenerateModelInsightsApp {
public static void main(String[] args) throws IOException {
Engine engine = new Engine();
//replace with your model id
Model model = engine.getModel("56223541-7157-4221-972b-443d298371b1");
// generate the insights
List<ModelInsight> insights = model.generateInsights(GenerateInsightsRequest.builder().build());
for(ModelInsight insight: insights) {
System.out.println("-----------------------------------------------------");
System.out.println(insight.getType().getValue());
System.out.println(insight.getData());
}
//can get individual insights if generated
ModelInsight insight = model.getInsight(GetInsightRequest.builder().type(ModelInsightType.FEATURE_IMPORTANCE).build());
System.out.println(insight.getData());
}
}