in src/responsibleai/rai_analyse/create_counterfactual.py [0:0]
def main(args):
my_run = Run.get_context()
# Load the RAI Insights object
rai_i: RAIInsights = create_rai_insights_from_port_path(
my_run, args.rai_insights_dashboard
)
# Add the counterfactual
rai_i.counterfactual.add(
total_CFs=args.total_CFs,
method=args.method,
desired_class=args.desired_class,
desired_range=args.desired_range,
permitted_range=args.permitted_range,
features_to_vary=args.features_to_vary,
feature_importance=args.feature_importance,
)
_logger.info("Added counterfactual")
# Compute
rai_i.compute()
_logger.info("Computation complete")
# Save
save_to_output_port(rai_i, args.counterfactual_path, RAIToolType.COUNTERFACTUAL)
_logger.info("Saved to output port")
# Copy the dashboard info file
copy_dashboard_info_file(args.rai_insights_dashboard, args.counterfactual_path)
_logger.info("Completing")