MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / ExecuteExplain

Method ExecuteExplain

go/executor/executor.go:265–307  ·  view source on GitHub ↗
(cl *ir.ExplainStmt)

Source from the content-addressed store, hash-verified

263}
264
265func (s *pythonExecutor) ExecuteExplain(cl *ir.ExplainStmt) error {
266 // NOTE(typhoonzero): model is already loaded under s.Cwd
267 var code string
268 var err error
269 db, err := database.OpenAndConnectDB(s.Session.DbConnStr)
270 if err != nil {
271 return err
272 }
273 defer db.Close()
274
275 var modelType int
276 if cl.TrainStmt.GetModelKind() == ir.XGBoost {
277 code, err = xgboost.Explain(cl, s.Session)
278 modelType = model.XGBOOST
279 } else {
280 code, err = tensorflow.Explain(cl, s.Session)
281 modelType = model.TENSORFLOW
282 }
283
284 if cl.Into != "" {
285 err := createExplainResultTable(db, cl, cl.Into, modelType, cl.TrainStmt.Estimator)
286 if err != nil {
287 return err
288 }
289 }
290
291 if err != nil {
292 return err
293 }
294 if err = s.runProgram(code, false); err != nil {
295 return err
296 }
297 img, err := readExplainResult(path.Join(s.Cwd, "summary.png"))
298 if err != nil {
299 return err
300 }
301 termFigure, err := ioutil.ReadFile(path.Join(s.Cwd, "summary.txt"))
302 if err != nil {
303 return err
304 }
305 s.Writer.Write(Figures{img, string(termFigure)})
306 return nil
307}
308
309func (s *pythonExecutor) ExecuteEvaluate(cl *ir.EvaluateStmt) error {
310 // NOTE(typhoonzero): model is already loaded under s.Cwd

Callers

nothing calls this directly

Calls 9

runProgramMethod · 0.95
OpenAndConnectDBFunction · 0.92
ExplainFunction · 0.92
ExplainFunction · 0.92
createExplainResultTableFunction · 0.85
readExplainResultFunction · 0.85
GetModelKindMethod · 0.80
CloseMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected