stan

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HmcNUTSFunction = "stan::services::sample::hmc_nuts_diag_e_adapt"
)

Variables

This section is empty.

Functions

func ModelCode

func ModelCode() string

Types

type CreateFitErrResp

type CreateFitErrResp struct {
	Code    int `json:"code"`
	Details []struct {
	} `json:"details"`
	Message string `json:"message"`
	Status  string `json:"status"`
}

type CreateFitReq

type CreateFitReq struct {
	Chain          int                    `json:"chain,omitempty"`
	Data           map[string]interface{} `json:"data,omitempty"`
	Delta          int                    `json:"delta,omitempty"`
	Function       string                 `json:"function,omitempty"`
	Gamma          int                    `json:"gamma,omitempty"`
	Init           map[string]interface{} `json:"init,omitempty"`
	InitBuffer     int                    `json:"init_buffer,omitempty"`
	InitRadius     int                    `json:"init_radius,omitempty"`
	Kappa          int                    `json:"kappa,omitempty"`
	MaxDepth       int                    `json:"max_depth,omitempty"`
	NumSamples     int                    `json:"num_samples,omitempty"`
	NumThin        int                    `json:"num_thin,omitempty"`
	NumWarmup      int                    `json:"num_warmup,omitempty"`
	RandomSeed     int                    `json:"random_seed,omitempty"`
	Refresh        int                    `json:"refresh,omitempty"`
	SaveWarmup     bool                   `json:"save_warmup,omitempty"`
	Stepsize       int                    `json:"stepsize,omitempty"`
	StepsizeJitter int                    `json:"stepsize_jitter,omitempty"`
	T0             int                    `json:"t0,omitempty"`
	TermBuffer     int                    `json:"term_buffer,omitempty"`
	Window         int                    `json:"window,omitempty"`
}

type CreateFitResp

type CreateFitResp struct {
	Name string `json:"name"`
}

type GetOperationResp

type GetOperationResp struct {
	Name     string `json:"name"`
	Done     bool   `json:"done"`
	Metadata struct {
		Fit struct {
			Name string `json:"name"`
		} `json:"fit"`
		Progress string `json:"progress"`
	} `json:"metadata"`
	Result struct {
		Name string `json:"name"`
	} `json:"result"`
}

GetOperationResp example json:

{
 "name": "operations/cpyhg3rz",
 "done": true,
 "metadata": {
   "fit": {
     "name": "models/nld3pk7n/fits/cpyhg3rz"
   },
   "progress": "Iteration: 22000 / 22000 [100%]  (Sampling)"
 },
 "result": {
   "name": "models/nld3pk7n/fits/cpyhg3rz"
 }
}

type GetParamsResp

type GetParamsResp struct {
	Id     string `json:"id"`
	Params []struct {
		ConstrainedNames []string `json:"constrained_names"`
		Dims             []int    `json:"dims"`
		Name             string   `json:"name"`
	} `json:"params"`
}

type ModelCompileReq

type ModelCompileReq struct {
	ProgramCode string `json:"program_code"`
}

type ModelCompileResp

type ModelCompileResp struct {
	Name           string `json:"name"`
	CompilerOutput string `json:"compiler_output"`
	StancWarnings  string `json:"stanc_warnings"`
}

type Stan

type Stan struct {
	// contains filtered or unexported fields
}

func NewStan

func NewStan(host, port string) *Stan

func (Stan) CompileModel

func (s Stan) CompileModel(ctx context.Context, programCode string) (ModelCompileResp, error)

CompileModel compiles the model Status Codes:

201 Created – Identifier for compiled Stan model and compiler output.
400 Bad Request – Error associated with compile request.

func (Stan) CreateFit

func (s Stan) CreateFit(ctx context.Context, modelID string, req CreateFitReq) (string, error)

CreateFit Post request /v1/models/{model_id}/fits to start a long-running fit operation

Status Codes:

201 Created – Identifier for completed Stan fit
400 Bad Request – Error associated with request.
404 Not Found – Fit not found.

func (Stan) ExtractFromFitResult

func (s Stan) ExtractFromFitResult(ctx context.Context, res io.ReadCloser) dataframe.DataFrame

func (Stan) GetFitResult

func (s Stan) GetFitResult(ctx context.Context, modelID, fitID string) (io.ReadCloser, error)

GetFitResult GET /v1/models/{model_id}/fits/{fit_id}

Get results returned by a function. Result (draws, logger messages) from calling a function defined in stan::services.

Status Codes:

200 OK – Newline-delimited JSON-encoded messages from Stan. Includes draws.
404 Not Found – Fit not found.

func (Stan) GetOperationDetails

func (s Stan) GetOperationDetails(ctx context.Context, operationID string) (GetOperationResp, error)

GetOperationDetails GET /v1/operations/{operation_id}

Return Operation details. Details about an Operation include whether the operation is done and information about the progress of sampling.

Status Codes:

200 OK – Operation name and metadata.
404 Not Found – Operation not found.

func (Stan) StanParams

func (s Stan) StanParams(ctx context.Context, modelID string, data map[string]interface{}) ([]string, []string)

StanParams POST /v1/models/{model_id}/params to get parameter names and dimensions.

Status Codes:

200 OK – Parameters for Stan Model
400 Bad Request – Error associated with request.
404 Not Found – Model not found.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL