Documentation
¶
Overview ¶
Package model is the one bound-model namespace: the in-memory form of a fitted regression a request reads by name, the set those names resolve in, and the structural rules a ComposedRequest `fits` list must satisfy.
It is a leaf over the standard library plus types and errors (TestModel_ImportBoundary), so the runtime (internal/service, the engine) and the no-execute predict path (internal/descriptor) share ONE rule set and ONE resolver — predict refuses exactly what the runtime refuses, with the same code, message and details.
Index ¶
- Constants
- func CheckChainModels(stages []*types.ChainStage) *errors.CodedError
- func CheckCoef(cat Catalog, fit, term, stat string) *errors.CodedError
- func CheckComposeBatch(fits []types.FitSpec, requests []*types.Request) *errors.CodedError
- func CheckFits(fits []types.FitSpec) error
- func CheckModelRefs(refs []types.ModelRef, outer Catalog) *errors.CodedError
- func CheckRegressionSaves(regs []*types.RegressionSpec) *errors.CodedError
- func CheckRequestSaves(req *types.Request) *errors.CodedError
- func CheckSaveDuplicates(sites []SaveSite) *errors.CodedError
- func CheckSavePath(p string) *errors.CodedError
- func CheckScore(attr *types.Attribute, cat Catalog) (ScoreParams, Signature, *errors.CodedError)
- func Coef(set *Set, fit, term, stat string) (float64, *errors.CodedError)
- func CoefStats() []string
- func DefaultScoreLabel(attr *types.Attribute) string
- func FileFormatVersions() []int
- func FitRequest(spec types.FitSpec) *types.Request
- func IntervalsUnavailable(fit, key, value string) *errors.CodedError
- func NameCollision(name string, first, second Source) *errors.CodedError
- func Overwritten(p, name string) *errors.CodedError
- func PredictorMissing(fit, column string) *errors.CodedError
- func PredictorNotNumeric(fit, column, fieldType string) *errors.CodedError
- func ScorableType(t types.RegressionType) bool
- func StatUnknown(fit, stat string) *errors.CodedError
- func TermUnknown(fit, term string, terms []string) *errors.CodedError
- func UnknownModel(name string, available []string) *errors.CodedError
- func WithSet(ctx context.Context, set *Set) context.Context
- func WriteFailed(p, name, stage string, cause error) *errors.CodedError
- type Bound
- type Catalog
- type File
- type FileMatrix
- type FitCatalog
- type Float
- type Provenance
- type ReadFunc
- type SaveSite
- type ScoreParams
- type Set
- type Signature
- type Source
Constants ¶
const ( // StatPoint is the coefficient (REG_BAYES_LINEAR: the posterior // mean). The default. StatPoint = "point" // StatLower is the coefficient's lower confidence bound. StatLower = "lower" // StatUpper is the coefficient's upper confidence bound. StatUpper = "upper" // StatSE is the coefficient's standard error. StatSE = "se" )
The stat values coef() reads (its optional third argument).
const ( ReasonSavePathEmpty = "path_empty" ReasonSaveSuffix = "suffix" ReasonSaveEscapesRoot = "escapes_root" ReasonSaveNameMissing = "name_missing" )
The PULSE_MODEL_SAVE_INVALID reasons.
const ( ReasonFileJSON = "json" ReasonFileVersionMissing = "version_missing" ReasonFileSchema = "schema" )
The PULSE_MODEL_FILE_INVALID reasons.
const ( ReasonNameMissing = "name_missing" ReasonRequestMissing = "request_missing" ReasonRegressionCount = "regression_count" ReasonGrouped = "grouped" )
The PULSE_FIT_INVALID reasons.
const ( SlotFits = "fits" SlotModels = "models" )
The Source slots.
const ( ReasonFileMissing = "missing" ReasonFileUnreadable = "unreadable" )
The PULSE_MODEL_FILE_UNREADABLE reasons.
const ( // ScaleResponse scores a GLM on the response scale: the inverse link // of the linear predictor (the fit's own fitted means). The default. ScaleResponse = "response" // ScaleLink scores a GLM on the link scale: the linear predictor. ScaleLink = "link" )
Scale values of ATTR_REG_PREDICT's params.scale (REG_GLM only).
const ( ReasonParamsInvalid = "params_invalid" ReasonFitMissing = "fit_missing" ReasonSlotFields = "slot_fields" ReasonTermsEmpty = "terms_empty" ReasonTermDuplicate = "term_duplicate" ReasonScaleUnknown = "scale_unknown" ReasonScaleNotGLM = "scale_not_glm" ReasonTypeUnsupported = "type_unsupported" ReasonBoundUnknown = "bound_unknown" ReasonBoundTerms = "bound_terms" )
The PULSE_MODEL_SCORE_INVALID reasons.
const ( // BoundPoint scores with the coefficient itself. The default. BoundPoint = "point" // BoundLower scores with the coefficient's lower confidence bound // (RegressionResult.CILower) — single-term only. BoundLower = "lower" // BoundUpper scores with the coefficient's upper confidence bound // (RegressionResult.CIUpper) — single-term only. BoundUpper = "upper" )
Bound values of ATTR_REG_PREDICT's params.bound: which coefficient figure a single-term score multiplies its column by.
const CoefFunc = "coef"
CoefFunc is the expression function that reads a bound model's figures: coef(fit, term[, stat]) in ATTR_FORMULA and FILTER_EXPRESSION.
const FileFormatVersion = 2
FileFormatVersion is the newest model_format_version this build writes. The version is a function of the content, never a flag (the .pulse header's rule): a fit whose standard errors came from a robust RegressionSpec.Covariance writes 2 — version 1 plus the `covariance` echo — and every other fit writes 1, byte-identical to the files earlier builds wrote. Both stay readable (FileFormatVersions).
const FileSuffix = ".pulse-model.json"
FileSuffix is the model file name suffix every save path carries. The label- and range-table directory loaders skip it (a model file beside a table is not a table).
const InterceptKey = "(intercept)"
InterceptKey is the RegressionResult.Coefficients / StdErrors key of the intercept term (the engine's synthesized "(intercept)").
const ReasonRefNameEmpty = "name_empty"
The PULSE_MODEL_REF_INVALID reasons beyond the shared path reasons (ReasonSavePathEmpty, ReasonSaveSuffix, ReasonSaveNameMissing, ReasonSaveEscapesRoot — the one model-file path rule).
const ReasonSaveDuplicate = "duplicate"
ReasonSaveDuplicate is the PULSE_MODEL_SAVE_INVALID reason of a second save naming a file an earlier save in the same tree writes.
Variables ¶
This section is empty.
Functions ¶
func CheckChainModels ¶
func CheckChainModels(stages []*types.ChainStage) *errors.CodedError
CheckChainModels is the chain pre-pass rule, run by the runtime before the cohort opens and by PredictChain: every stage's `models` (each stage its own namespace; details.stage). A chain writes no model file — the chain gate refuses a regression on every stage (PULSE_CHAIN_NOT_MERGEABLE), stage 0 before it runs — so its saves need no rule here.
func CheckCoef ¶
func CheckCoef(cat Catalog, fit, term, stat string) *errors.CodedError
CheckCoef is the static rule over one coef(fit, term, stat) call — what can be judged from the names alone, so the runtime (every call) and predict (every all-literal call) refuse the same call the same way. In order: fit resolves in cat (PULSE_MODEL_UNKNOWN), term is InterceptKey or one of the fit's terms (PULSE_MODEL_TERM_UNKNOWN), stat is one of CoefStats (PULSE_MODEL_STAT_UNKNOWN). The first fault wins. Whether the fit reports the stat is the runtime's call (Coef): predict cannot see a fit's numbers.
func CheckComposeBatch ¶
CheckComposeBatch is the Compose pre-pass rule, run right after CheckFits by the runtime (serial and parallel, before any fit or slot runs) and by PredictCompose, in this order, the first fault winning:
- every slot's regression save path (CheckRegressionSaves, details.request = the slot index) — the fits' own were CheckFits';
- the uniqueness of every save in the batch — fits[i], fits[i].request.regressions[j], requests[k].regressions[j] (CheckSaveDuplicates);
- every fit request's `models` (CheckModelRefs, nothing bound outside it — a fit runs before the batch binds; details.fit);
- every slot's `models` against the fits' names (CheckModelRefs, details.request).
requests are the effective slots (sweep slots included).
func CheckFits ¶
CheckFits is the structural rule set over a ComposedRequest `fits` list, run by the runtime (before any fit or slot runs) and by PredictCompose alike, so both refuse the same batch with the same error. Entries are judged in order, each fully before the next; the first fault wins:
- an empty name — PULSE_FIT_INVALID name_missing
- no request — PULSE_FIT_INVALID request_missing
- zero or more than one regression — PULSE_FIT_INVALID regression_count
- groups or a crosstab — PULSE_FIT_INVALID grouped
- an invalid `save` path, the entry's own or its regression's (CheckSavePath) — PULSE_MODEL_SAVE_INVALID
- a name an earlier entry already binds — PULSE_MODEL_NAME_COLLISION
Every refusal carries details.fit (the 0-based entry index) and details.name. Nil for an empty list. Every save path is judged here, before any fit runs, so no fit writes a model file in a batch a later entry's path would refuse.
func CheckModelRefs ¶
func CheckModelRefs(refs []types.ModelRef, outer Catalog) *errors.CodedError
CheckModelRefs is the static rule over a `models` list, judged entry by entry in order, the first fault winning: a blank name (PULSE_MODEL_REF_INVALID name_empty), a path the save-path rule refuses (PULSE_MODEL_REF_INVALID, the path reason), then a name an earlier entry or outer already binds (PULSE_MODEL_NAME_COLLISION, details.sources). outer is what the request already sees bound — a Compose slot's fits; nil for none. No file is read.
func CheckRegressionSaves ¶
func CheckRegressionSaves(regs []*types.RegressionSpec) *errors.CodedError
CheckRegressionSaves applies CheckSavePath to every RegressionSpec that sets Save, in order; the first fault wins and gains details.regression (the 0-based spec index).
func CheckRequestSaves ¶
func CheckRequestSaves(req *types.Request) *errors.CodedError
CheckRequestSaves is the standalone request's save rule: every regression save path (CheckRegressionSaves), then their uniqueness.
func CheckSaveDuplicates ¶
func CheckSaveDuplicates(sites []SaveSite) *errors.CodedError
CheckSaveDuplicates refuses the first site whose path (cleaned) an earlier site already writes: PULSE_MODEL_SAVE_INVALID reason duplicate, details.path and details.sites (the earlier site, then this one). Nil when every path is distinct.
func CheckSavePath ¶
func CheckSavePath(p string) *errors.CodedError
CheckSavePath is the rule over a `save` path, shared by the runtime and predict: non-blank, a file name ending in FileSuffix with a stem before it, and never above the filesystem root (no leading ".." once cleaned). A violation is PULSE_MODEL_SAVE_INVALID with details.path and details.reason. Nil for a valid path.
func CheckScore ¶
func CheckScore(attr *types.Attribute, cat Catalog) (ScoreParams, Signature, *errors.CodedError)
CheckScore is the one rule over a scoring reference (an ATTR_REG_PREDICT slot), run by the runtime's field-reference pass, the attribute's own bind and predict alike: params decode, the slot carries none of the refit attributes' fields, the fit name resolves in cat, the fit type is scorable, `terms` lists distinct names of the fit's terms (InterceptKey included), `scale` is a GLM-only response|link and `bound` is point|lower|upper, a non-point one with exactly one predictor term. The first fault wins. It does not judge the scoring frame's columns — the caller's field-reference walk does, with PredictorMissing / PredictorNotNumeric over Signature.Terms.
func Coef ¶
func Coef(set *Set, fit, term, stat string) (float64, *errors.CodedError)
Coef is coef(fit, term, stat) over the request's bound models, at full float64 precision: CheckCoef, then the figure. stat lower / upper on a fit that reports no intervals, or se on one that reports no standard errors, is PULSE_MODEL_INTERVALS_UNAVAILABLE. A figure the fit reports for other terms but not this one — a lasso-dropped predictor's interval, an undefined (df ≤ 0) bound — is NaN, an undefined figure (null on the wire), never 0. A candidate predictor the fit's selection dropped has point coefficient 0 (it scores 0 in ATTR_REG_PREDICT) and NaN for every other stat.
func CoefStats ¶
func CoefStats() []string
CoefStats are the stats coef() reads, in documentation order.
func DefaultScoreLabel ¶
DefaultScoreLabel is ATTR_REG_PREDICT's output label when the slot sets none: "ATTR_REG_PREDICT_<fit>" (params unreadable: no suffix).
func FileFormatVersions ¶
func FileFormatVersions() []int
FileFormatVersions are the model_format_version values this build reads, oldest first.
func FitRequest ¶
FitRequest returns the request a fit runs: a shallow clone of spec.Request with its `return` cleared. The fit's figures surface whole as ComposedResponse.Fits[name] (outside every `return`), and a `return` that skipped the regressions slot would leave nothing to bind. The caller's request is never mutated.
func IntervalsUnavailable ¶
func IntervalsUnavailable(fit, key, value string) *errors.CodedError
IntervalsUnavailable is the PULSE_MODEL_INTERVALS_UNAVAILABLE refusal: a reference reads a coefficient interval (or standard error) from a fit that reports none. key names the reference's knob — "stat" for coef(), "bound" for ATTR_REG_PREDICT — and value its setting.
func NameCollision ¶
func NameCollision(name string, first, second Source) *errors.CodedError
NameCollision is the PULSE_MODEL_NAME_COLLISION refusal of a `models` entry (second) whose name first already binds — details.name and details.sources (both bindings, first then second).
func Overwritten ¶
func Overwritten(p, name string) *errors.CodedError
Overwritten is the PULSE_MODEL_OVERWRITTEN warning: a save replaced an existing file at path.
func PredictorMissing ¶
func PredictorMissing(fit, column string) *errors.CodedError
PredictorMissing is the PULSE_MODEL_PREDICTOR_MISSING refusal: the scoring frame (schema, feature outputs and earlier attribute labels) has no column for one of fit's predictors.
func PredictorNotNumeric ¶
func PredictorNotNumeric(fit, column, fieldType string) *errors.CodedError
PredictorNotNumeric is the PULSE_MODEL_PREDICTOR_NOT_NUMERIC refusal: a predictor column of fit is a schema field of a type a regression cannot read (fieldType is its type name).
func ScorableType ¶
func ScorableType(t types.RegressionType) bool
ScorableType reports whether a fit of type t can be scored: the linear-predictor regressions (REG_OLS — penalties and selection included — REG_GLM, REG_BAYES_LINEAR at its posterior mean).
func StatUnknown ¶
func StatUnknown(fit, stat string) *errors.CodedError
StatUnknown is the PULSE_MODEL_STAT_UNKNOWN refusal: a coef() stat other than point, lower, upper or se.
func TermUnknown ¶
func TermUnknown(fit, term string, terms []string) *errors.CodedError
TermUnknown is the PULSE_MODEL_TERM_UNKNOWN refusal: term is neither one of fit's terms nor InterceptKey. available lists the terms a reference may name, intercept first.
func UnknownModel ¶
func UnknownModel(name string, available []string) *errors.CodedError
UnknownModel is the PULSE_MODEL_UNKNOWN refusal for name against the bound names available — the one constructor the runtime resolver and predict share.
func WriteFailed ¶
func WriteFailed(p, name, stage string, cause error) *errors.CodedError
WriteFailed is the PULSE_MODEL_WRITE_FAILED refusal: the save of model name to path failed at stage (mkdir, create, write, sync, close, rename, stat). The target is left as it was.
Types ¶
type Bound ¶
type Bound struct {
// Name is the bound name (the `fits` entry name).
Name string
// Type is the regression operator that produced the fit.
Type types.RegressionType
// Target is the fit's response field.
Target string
// Predictors are the predictor columns in fit order: the spec's
// predictors, or — under Selection — the predictors the selection
// retained. The list is authoritative: a scorer never infers a
// column the fit did not use (an absent one-hot column is the
// reference level).
Predictors []string
// Terms are the predictor columns the fit was offered, in spec
// order — Predictors without Selection, the candidate superset
// under it. A scoring reference may name any of them in `terms` (a
// candidate the selection dropped scores 0) and a scoring frame must
// hold all of them, so predict, which sees only the spec, judges a
// reference exactly as the runtime does.
Terms []string
// Intercept is the fitted intercept.
Intercept float64
// Coefficients are the fitted coefficients aligned with Predictors
// (REG_BAYES_LINEAR: the posterior mean).
Coefficients []float64
// InterceptStdErr is the intercept's standard error (NaN when the
// fit reports none).
InterceptStdErr float64
// StdErrors are the coefficients' standard errors aligned with
// Predictors (NaN where the fit reports none).
StdErrors []float64
// InterceptCILower / InterceptCIUpper are the intercept's
// confidence bounds and CILower / CIUpper the coefficients' aligned
// with Predictors, at ConfLevel (RegressionResult.CILower /
// CIUpper, full precision); NaN where the fit reports none.
InterceptCILower float64
InterceptCIUpper float64
CILower []float64
CIUpper []float64
// ConfLevel is the intervals' coverage (0 when the fit reports no
// intervals).
ConfLevel float64
// Family and Link are the GLM error family and link ("" otherwise).
Family string
Link string
// Vcov is the coefficient covariance matrix when the fit computed
// it (RegressionSpec.Vcov), nil otherwise.
Vcov *types.MatrixValues
// Result is the fit's full RegressionResult (shared, read-only).
Result *types.RegressionResult
// Source is where the name was bound: a `fits` entry or a `models`
// entry (the zero value when unknown). A name collision names both
// bindings' sources.
Source Source
}
Bound is one fitted regression bound under a name: everything a scorer needs, at full float64 precision, in the fit's own predictor order. Built from the engine's RegressionResult before any rounding (a `return` precision applies to the wire only, never to a Bound).
func Bind ¶
func Bind(name string, spec *types.RegressionSpec, res *types.RegressionResult) (*Bound, error)
Bind builds the Bound for a finished fit: spec is the regression as the fit ran it, res its result. A coefficient the result lacks for a fitted predictor is an engine invariant violation (PROCESSING_INTERNAL).
func (*Bound) ReportsIntervals ¶
ReportsIntervals reports whether the fit carries coefficient confidence intervals (RegressionResult.ConfLevel set). A fit without standard errors — a degenerate intercept-only GLM — has none.
func (*Bound) ReportsStdErrors ¶
ReportsStdErrors reports whether the fit carries any standard error.
type Catalog ¶
type Catalog interface {
// Signature returns name's signature and whether name is bound.
Signature(name string) (Signature, bool)
// Names returns the bound names, sorted.
Names() []string
}
Catalog resolves bound names to their Signatures: the runtime's Set, or predict's FitCatalog. A nil Catalog binds nothing.
type File ¶
type File struct {
// ModelFormatVersion is 2 when Covariance is set, else 1.
ModelFormatVersion int `json:"model_format_version"`
// Name is the name the model was saved under (informational: a load
// binds the name the loading request gives it).
Name string `json:"name"`
// Type is the regression operator that produced the fit.
Type types.RegressionType `json:"type"`
// Family and Link are the GLM error family and link.
Family string `json:"family,omitempty"`
Link string `json:"link,omitempty"`
// Penalty, Selection and Resample echo the fit's modifiers.
Penalty string `json:"penalty,omitempty"`
Selection string `json:"selection,omitempty"`
Resample string `json:"resample,omitempty"`
// Target is the fit's response field.
Target string `json:"target"`
// Predictors are the predictor columns the fit uses, in fit order —
// under Selection the retained ones only.
Predictors []string `json:"predictors"`
// Terms are the predictor columns the fit was offered, in spec
// order (equal to Predictors without Selection).
Terms []string `json:"terms"`
// Coefficients, StdErrors, CILower and CIUpper are the fit's
// per-term figures.
Coefficients map[string]Float `json:"coefficients"`
StdErrors map[string]Float `json:"std_errors,omitempty"`
CILower map[string]Float `json:"ci_lower,omitempty"`
CIUpper map[string]Float `json:"ci_upper,omitempty"`
// DF is the intervals' Student-t degrees of freedom (absent: Wald;
// null: undefined).
DF Float `json:"df,omitempty"`
// ConfLevel is the intervals' coverage (absent: no intervals).
ConfLevel Float `json:"conf_level,omitempty"`
// Vcov is the coefficient covariance when the fit computed one.
Vcov *FileMatrix `json:"vcov,omitempty"`
// Covariance (version 2 only, and required there) names the robust
// estimator the standard errors, intervals, df and vcov came from —
// RegressionResult.Covariance: type, and the cluster field and its
// level count or the order_by field and resolved lag. Absent: the
// fit's classical covariance.
Covariance *types.RegressionCovarianceResult `json:"covariance,omitempty"`
// NObs, SumWeights and NEff are the fit's sample sizes (the last
// two present on a weighted fit only).
NObs int `json:"n_obs"`
SumWeights Float `json:"sum_weights,omitempty"`
NEff Float `json:"n_eff,omitempty"`
// Provenance records where the fit came from. Informational only:
// a load never compares it with anything.
Provenance Provenance `json:"provenance"`
}
File is one model file document (model_format_version 1 or 2): the fitted regression's scoring figures at full float64 precision plus informational provenance. Maps are keyed like RegressionResult's (InterceptKey included); a term absent from a map has no figure.
func DecodeFile ¶
DecodeFile parses a model file. The version is read first: absent or not an integer is PULSE_MODEL_FILE_INVALID (reason version_missing / schema), any value outside FileFormatVersions PULSE_MODEL_VERSION_UNSUPPORTED. The document is then decoded strictly — an unknown key, a wrong type or a structural fault (no type or target, a predictor without a coefficient, a predictor outside terms, a malformed vcov, a covariance on a version 1 file or none on a version 2 one, a covariance type outside the robust estimators) is PULSE_MODEL_FILE_INVALID reason schema; malformed JSON reason json. source names the file in messages and details.path.
func LoadModelFiles ¶
LoadModelFiles reads and decodes every `models` entry in order (the refs passed CheckModelRefs): a read error is PULSE_MODEL_FILE_UNREADABLE (missing / unreadable), a decode fault DecodeFile's PULSE_MODEL_FILE_INVALID / _VERSION_UNSUPPORTED — every refusal gaining details.model (the entry index) and details.name. The first fault wins. The files are index-aligned with refs.
func NewFile ¶
func NewFile(name string, spec *types.RegressionSpec, res *types.RegressionResult, prov Provenance) (*File, error)
NewFile builds the model file of a finished fit: spec is the regression as the fit ran it, res its full-precision result (never a `return`-rounded one). It holds what Bind needs to rebuild the same Bound — under Selection the retained predictors, with the candidate set as Terms.
func (*File) Bind ¶
Bind rebuilds the Bound the saved fit had, under name: the same predictors, terms and figures, bit for bit. Its Result carries the saved figures only (no R² or deviance).
func (*File) Encode ¶
Encode writes f as the model file's bytes: indented JSON (map keys sorted, so a file is deterministic) with a trailing newline.
func (*File) Result ¶
func (f *File) Result() *types.RegressionResult
Result is the RegressionResult the file's figures describe.
type FileMatrix ¶
type FileMatrix struct {
Kind types.MatrixKind `json:"kind"`
Encoding types.MatrixEncoding `json:"encoding"`
RowKeys []string `json:"row_keys"`
ColumnKeys []string `json:"column_keys"`
Labels []string `json:"labels,omitempty"`
Values [][]Float `json:"values"`
}
FileMatrix is a model file's matrix (the vcov): MatrixValues with bit-exact floats.
type FitCatalog ¶
FitCatalog is the static Catalog of a ComposedRequest `fits` list — predict's view of the names the runtime's pre-pass binds. Entries CheckFits would refuse are skipped (that refusal comes first).
func CatalogFromFits ¶
func CatalogFromFits(fits []types.FitSpec) FitCatalog
CatalogFromFits builds the FitCatalog of fits.
func CatalogWithModels ¶
func CatalogWithModels(outer Catalog, refs []types.ModelRef, files []*File) FitCatalog
CatalogWithModels is predict's WithModels: outer's signatures plus every loaded file's, under its entry's name — the static view of the names the runtime binds. outer may be nil.
type Float ¶
type Float float64
Float is a model-file float64: shortest round-trip form when finite, null for NaN, "+Inf" / "-Inf" for the infinities.
func (Float) MarshalJSON ¶
MarshalJSON writes f bit-exactly (see Float).
func (*Float) UnmarshalJSON ¶
UnmarshalJSON reads what MarshalJSON writes: null is NaN.
type Provenance ¶
type Provenance struct {
// Cohort is the training request's cohort path.
Cohort string `json:"cohort,omitempty"`
// Fingerprint is "sha256:<hex>" of the training cohort file's bytes
// at save time (absent when it could not be computed).
Fingerprint string `json:"fingerprint,omitempty"`
// RequestDigest is the training request's canonical hash
// (types.Request.Hash).
RequestDigest string `json:"request_digest,omitempty"`
}
Provenance is a model file's informational origin.
type ReadFunc ¶
ReadFunc reads a model file's bytes at a path relative to the instance filesystem root.
type SaveSite ¶
SaveSite is one `save` in a request tree: where it sits (e.g. "regressions[0]", "fits[1]", "requests[2].regressions[0]") and the path it writes.
type ScoreParams ¶
type ScoreParams struct {
// Fit names the bound model to score.
Fit string `json:"fit"`
// Terms restricts the score to a subset of the model's terms — its
// predictor names, plus InterceptKey to include the intercept. Nil
// scores the whole model, intercept included.
Terms []string `json:"terms,omitempty"`
// Scale is ScaleResponse (default) or ScaleLink; REG_GLM only.
Scale string `json:"scale,omitempty"`
// Bound is BoundPoint (default), BoundLower or BoundUpper. A
// non-point bound needs Terms to list exactly one predictor: it is
// that term's coefficient-interval contribution (bound × column),
// never a prediction interval.
Bound string `json:"bound,omitempty"`
}
ScoreParams is ATTR_REG_PREDICT's params block, decoded by the one function both the runtime and predict call (DecodeScoreParams).
func DecodeScoreParams ¶
func DecodeScoreParams(raw json.RawMessage) (ScoreParams, *errors.CodedError)
DecodeScoreParams decodes ATTR_REG_PREDICT's params; anything but a JSON object of the ScoreParams keys (with their types) is PULSE_MODEL_SCORE_INVALID reason params_invalid. Absent params decode to the zero ScoreParams (and then refuse as fit_missing).
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is the request's bound-model namespace: every name a reference may resolve. The zero value and nil are empty sets. A Set is built once, before any slot runs, and only read afterwards — safe for concurrent readers.
func (*Set) Lookup ¶
Lookup resolves name; an unbound name is PULSE_MODEL_UNKNOWN with the bound names under details.available. Nil-receiver-safe.
func (*Set) WithModels ¶
WithModels returns a new Set holding s's bindings plus every loaded file bound under its entry's name (Source models[j]). refs passed CheckModelRefs against s, so no name collides; files are LoadModelFiles' result. s is never mutated; nil s is empty.
type Signature ¶
type Signature struct {
// Name is the bound name.
Name string
// Type is the regression operator that produces the fit.
Type types.RegressionType
// Terms are the predictor columns the fit was offered, in spec
// order: the names `terms` may list and the columns a scoring frame
// must hold. Under Selection it is the candidate set, a superset of
// the predictors the fit keeps (a dropped candidate scores 0).
Terms []string
// Source is where the name is bound (a `fits` or `models` entry).
Source Source
}
Signature is the static face of a bound model: what a scoring reference is judged against without the fit's numbers. The runtime takes it from a Bound, predict from the fit request as written, so both judge one reference the same way.
type Source ¶
type Source struct {
// Slot is SlotFits or SlotModels ("" when unknown).
Slot string
// Index is the 0-based entry index in that slot.
Index int
// Path is a `models` entry's file path ("" for a fit).
Path string
}
Source names where a bound name came from: the `fits` entry or the `models` entry (with its file path) that bound it.
func ModelSource ¶
ModelSource is the Source of models[j] loading path.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package coefcall finds the coef(fit, term[, stat]) calls an ATTR_FORMULA / FILTER_EXPRESSION expression makes with literal arguments and judges them by internal/model.CheckCoef — the static half of the coef() rule, shared by the engine's build (internal/ processing) and the no-execute field-reference pass (internal/ descriptor: predict and the runtime's entry check), so both refuse the same call with the same code, message and details.
|
Package coefcall finds the coef(fit, term[, stat]) calls an ATTR_FORMULA / FILTER_EXPRESSION expression makes with literal arguments and judges them by internal/model.CheckCoef — the static half of the coef() rule, shared by the engine's build (internal/ processing) and the no-execute field-reference pass (internal/ descriptor: predict and the runtime's entry check), so both refuse the same call with the same code, message and details. |