github.com/wlattner/mlserver@v0.0.0-20141113171038-895f261d2bfd/main.go (about) 1 package main 2 3 /* 4 This app allows Scikit-Learn classifiers to fitted and used through an HTTP/JSON 5 api. Each models is run inside a dedicated python child process. Go communicates with 6 each process using zeromq, although using stdin/stdout may also work. The fitting 7 script does some primitive model selection. Currently using RandomForestClassifier, 8 LogisticRegression, and GradientBoostingClassifier. RandomForestClassifier and 9 GradientBoostingClassifier are each called with n_estimators=150, LogisticRegression 10 uses the default arguments. 11 */ 12 13 import ( 14 "flag" 15 "net/http" 16 17 "github.com/coreos/go-log/log" 18 ) 19 20 var ( 21 port = flag.String("port", "5000", "port for api server") 22 modelDir = flag.String("model-path", "models", "location of model directory") 23 ) 24 25 func main() { 26 flag.Parse() 27 28 models := NewModelRepo(*modelDir) 29 30 log.Info("started indexing model directory") 31 models.IndexModelDir() 32 log.Info("finished indexing model directory") 33 34 s := NewAPIHandler(models) 35 36 log.Info("listening on http://localhost:" + *port) 37 log.Fatalln(http.ListenAndServe(":"+*port, requestLogger(s))) 38 }