Skip to content

evalphobia/go-datarobot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-datarobot

GoDoc License: Apache 2.0 Release Build Status Codecov Coverage Go Report Card Code Climate BCH compliance

  • go-datarobot is golang cli app to get prediction result from Datarobot API and add class probabilities into the csv file.

  • go-datarobot/apiclient is Datarobot API client for Golang.

Quick Usage

command line

# install
$ go get github.com/evalphobia/go-datarobot


# check input data
$ cat ./example/input.csv

user_id,flag
1,true
2,false

# execute to predict from input csv data
$ go-datarobot \
    -input ./example/input.csv \
    -output ./example/output.csv \
    -user example@example.com \
    -token <your api token> \
    -project <project id> \
    -model <model id>

======== running setting ==========
input: ./example/input.csv
output: ./example/output.csv
user: example@example.com
project: <project id>
model: <model id>
block size: 1000
====================================
[INFO] send request: part=0
[INFO] send request: part=1
[INFO] finished reading all lines
[INFO] finished request: part=1
[INFO] write line: part=1
[INFO] finished request: part=0
[INFO] write line: part=0
[INFO] finished all requests
end


# show predict result
$ cat ./example/output.csv

user_id,flag,true,false
1,true,0.9929134249687195,0.007086575031280518
2,false,0.0012341737747192383,0.9987658262252808

Options

  • -input: input csv file path (required)
  • -output: output csv file path (required)
  • -user: datarobot account user name (required)
  • -token: datarobot account api token (required)
  • -project: datarobot account project id (required)
  • -model: datarobot account model id (required)
  • -block: row data size to send api request (default:1000)

API client

predict API

import(
	"github.com/evalphobia/go-datarobot/apiclient/config"
	"github.com/evalphobia/go-datarobot/apiclient/predict"
)

func main(){
	user := "example@example.com"
	token := "<your api token>"
	c := config.NewWithToken(user, token)

	row1 := map[string]interface{}{
		"user_id": 1,
		"flag": true,
	}
	row2 := map[string]interface{}{
		"user_id": 2,
		"flag": false,
	}
	items := []map[string]interface{}{
		row1,
		row2,
	}

	resp, err := predict.Predict(c, predict.Param{
		ProjectID: "<project id>",
		ModelID:   "<model id>",
		Data:      items,
	})
	if err != nil {
		panic(err)
	}

	fmt.Printf("predictions: %v\n", resp.Predictions)
}

License

Apache License, Version 2.0