// Explain generates a Python program to explain a trained model.
Explain generates a Python program to explain a trained model.
// Explain generates a Python program to explain a trained model .
func Explain(explainStmt *ir.ExplainStmt, session *pb.Session) (string, error) {
	summaryParams := resolveParams(explainStmt.Attributes, shapSummaryAttrPrefix)
	jsonSummary, err := json.Marshal(summaryParams)
	if err != nil {
		return "", err
	}
	featureColumnCode, xs, y, err := deriveFeatureColumnCodeAndFieldDescs(explainStmt.TrainStmt.Features["feature_columns"], explainStmt.TrainStmt.Label)
	if err != nil {
		return "", err
	}
	f, fs, err := resolveFeatureMeta(xs)
	if err != nil {
		return "", err
	}
	l, err := json.Marshal(resolveFieldMeta(&y))
	if err != nil {
		return "", err
	}
	fr := &explainFiller{
		DataSource:           session.DbConnStr,
		DatasetSQL:           explainStmt.Select,
		ShapSummaryParams:    string(jsonSummary),
		FeatureFieldMetaJSON: string(f),
		FeatureColumnNames:   fs,
		FeatureColumnCode:    featureColumnCode,
		LabelJSON:            string(l),
		IsPAI:                tf.IsPAI(),
		PAIExplainTable:      explainStmt.TmpExplainTable,
	}
	var analysis bytes.Buffer
	if err := explainTemplate.Execute(&analysis, fr); err != nil {
		return "", err
	}
	return analysis.String(), nil
}
func Explain ( explainStmt * ir . ExplainStmt , session * pb . Session ) ( string , error ) { summaryParams := resolveParams ( explainStmt . Attributes , shapSummaryAttrPrefix ) jsonSummary , err := json . Marshal ( summaryParams ) if err != nil { return " " , err } featureColumnCode , xs , y , err := deriveFeatureColumnCodeAndFieldDescs ( explainStmt . TrainStmt . Features [ " " ] , explainStmt . TrainStmt . Label ) if err != nil { return " " , err } f , fs , err := resolveFeatureMeta ( xs ) if err != nil { return " " , err } l , err := json . Marshal ( resolveFieldMeta ( & y ) ) if err != nil { return " " , err } fr := & explainFiller { DataSource : session . DbConnStr , DatasetSQL : explainStmt . Select , ShapSummaryParams : string ( jsonSummary ) , FeatureFieldMetaJSON : string ( f ) , FeatureColumnNames : fs , FeatureColumnCode : featureColumnCode , LabelJSON : string ( l ) , IsPAI : tf . IsPAI ( ) , PAIExplainTable : explainStmt . TmpExplainTable , } var analysis bytes . Buffer if err := explainTemplate . Execute ( & analysis , fr ) ; err != nil { return " " , err } return analysis . String ( ) , nil }
Explain generates a Python program to explain a trained model.
Explain generates a Python program to explain a trained model .