Documentation ¶
Index ¶
- Constants
- func Accuracy(lr fu.Struct) float64
- func AccuracyScore(train, test fu.Struct) float64
- func BatchUpdateMetrics(result, label *tables.Column, mu MetricsUpdater)
- func Error(lr fu.Struct) float64
- func ErrorScore(train, test fu.Struct) float64
- func Evaluate(source tables.AnyData, label string, m PredictionModel, batchsize int, ...) (lr fu.Struct, err error)
- func Loss(lr fu.Struct) float64
- func LossScore(train, test fu.Struct) float64
- func LuckyEvaluate(source tables.AnyData, label string, m PredictionModel, batchsize int, ...) fu.Struct
- func LuckyMemorize(output iokit.Output, m MemorizeMap)
- func Memorize(output iokit.Output, m MemorizeMap) error
- func Objectify(input iokit.Input, m ObjectifyMap) (pm map[string]PredictionModel, err error)
- func Path(s string) string
- type Classification
- type CollectionWriter
- type Dataset
- type FatModel
- type GpuPredictionModel
- type HungryModel
- type MemorizeMap
- type Metrics
- type MetricsUpdater
- type Mnemosyne
- type ModelStash
- type ObjectifyMap
- type Params
- type PredictionModel
- type Regression
- type Report
- type Score
- type Training
- type UnifiedTraining
- type Workout
Constants ¶
const AccuracyCol = "Accuracy"
AccuracyCol is the Error column name
const CorrectCol = "Correct"
CorrectCol i th Correct column name
const DefaultScoreHistory = 3
const ErrorCol = "Error"
ErrorCol is the Error column name
const F1ScoreCol = "F1score"
F1ScoreCol is the F1score column name
const FeatureCol = "Feature"
FeatureCol is the default name of single feature column
const IterationCol = "Iteration"
IterationCol is the Iteration column name
const LabelCol = "Label"
LabelCol is the default name of column containing a training label
const LossCol = "Loss"
LossCol is the Loss column name
const MaeCol = "Mae"
MaeCol is the Mean of Absolute Error column name
const MeCol = "Me"
MaeCol is the Mean of Error column name
const PrecisionCol = "Precision"
PrecisionCol is the Precision column name
const PredictedCol = "Predicted"
PredictedCol is the default name of column containing a result of prediction
const RmseCol = "Rmse"
RmseCol is the Root Mean fo Squared Error column name
const SensitivityCol = "Sensitivity"
SensitivityCol is the Sensitivity column name
const SubsetCol = "Subset"
SubsetCol is the Subset column naime
const TestCol = "Test"
TestCol is the default name of Test column containing a boolean flag
const TestSubset = "test"
TestSubset is the Subset column item value for test rows
const TotalCol = "Total"
TotalCol is the Total column name
const TrainSubset = "train"
TrainSubset is the Subset column item value for train rows
Variables ¶
This section is empty.
Functions ¶
func AccuracyScore ¶
AccuracyScore scores accuracy in interval [0,1], Greater is better
func BatchUpdateMetrics ¶
func BatchUpdateMetrics(result, label *tables.Column, mu MetricsUpdater)
BatchUpdateMetrics updates metrics for a batch of training results
func ErrorScore ¶
ErrorScore scores error in interval [0,1], Greater is better
func Evaluate ¶
func Evaluate(source tables.AnyData, label string, m PredictionModel, batchsize int, metricsf Metrics) (lr fu.Struct, err error)
Evaluate metrics of the given source with the prediction model
func LuckyEvaluate ¶
func LuckyEvaluate(source tables.AnyData, label string, m PredictionModel, batchsize int, metricsf Metrics) fu.Struct
LuckyEvaluate is the same as Evaluate function with handling error as a panic
func LuckyMemorize ¶
func LuckyMemorize(output iokit.Output, m MemorizeMap)
LuckyMemorize writes models directory to single output
func Memorize ¶
func Memorize(output iokit.Output, m MemorizeMap) error
Memorize writes models directory to single output
func Objectify ¶
func Objectify(input iokit.Input, m ObjectifyMap) (pm map[string]PredictionModel, err error)
Objectify reads and reconstructs prediction models from a directory
Types ¶
type Classification ¶
type Classification struct { Accuracy float64 // accuracy goal Error float64 // error goal Confidence float32 // threshold for binary classification }
Classification metrics factory
func (Classification) Names ¶
func (m Classification) Names() []string
Names is the list of calculating metrics
func (Classification) New ¶
func (m Classification) New(iteration int, subset string) MetricsUpdater
New metrics updater for the given iteration and subset
type CollectionWriter ¶
type CollectionWriter struct {
// contains filtered or unexported fields
}
CollectionWriter is an abstraction of a collection creator
type Dataset ¶
type Dataset struct { Source tables.AnyData // It can be tables.Table or lazy stream of mlutil.Struct objects Validation tables.AnyData // optional, equal to Source if nil Label string // name of float32/Tensor field containing label to train Test string // name of boolean field to select test data Features []string // patterns of feature names to train model or predict }
Dataset is an abstraction of some source of a data to feed hungry models
type FatModel ¶
FatModel is fattened model (a training function of model instance bounded to a dataset)
func (FatModel) LuckyTrain ¶
func (f FatModel) LuckyTrain(training UnifiedTraining) *Report
LuckyTrain trains fattened (Fat) model and trows any occurred errors as a panic
type GpuPredictionModel ¶
type GpuPredictionModel interface { PredictionModel // Gpu changes context of prediction backend to gpu enabled // it's a recommendation only, if GPU is not available or it's impossible to use it // the cpu will be used instead Gpu(...int) PredictionModel }
GpuPredictionModel is a prediction interface able to use GPU
type HungryModel ¶
HungryModel is an ML algorithm grows from a data to predict something Needs to be fattened by Feed method to fit.
type MemorizeMap ¶
MemorizeMap maps names of models in directory to Mnemosyne abstraction
type Metrics ¶
type Metrics interface { New(iteration int, subset string) MetricsUpdater Names() []string }
Metrics interface
type MetricsUpdater ¶
type MetricsUpdater interface { // updates metrics with prediction result and label // loss is an optional and can be used in LossScore on the training Update(result, label reflect.Value, loss float64) Complete() (fu.Struct, bool) }
MetricsUpdater interface
type Mnemosyne ¶
type Mnemosyne interface {
Memorize(*CollectionWriter) error
}
Mnemosyne is a Serialization interface for an ML model parts
type ModelStash ¶
type ModelStash struct {
// contains filtered or unexported fields
}
func NewStash ¶
func NewStash(histlen int, pattern string) *ModelStash
func (*ModelStash) Close ¶
func (ms *ModelStash) Close() error
func (*ModelStash) Length ¶
func (ms *ModelStash) Length() int
type ObjectifyMap ¶
ObjectifyMap mpas names of models in directory to objectification functions
type Params ¶
Params is a set of hyper-parameters used by hyper-parameter optimization to generate new model
type PredictionModel ¶
type PredictionModel interface { // Features model uses when maps features // the same as Features in the training dataset Features() []string // Column name model adds to result table when maps features. // By default it's 'Predicted' Predicted() string // Returns new table with all original columns except features // adding one new column with prediction FeaturesMapper(batchSize int) (tables.FeaturesMapper, error) }
PredictionModel is a predictor interface
type Regression ¶
type Regression struct {
Error float64 // error goal
}
Regression - the regression metrics factory
func (Regression) Names ¶
func (m Regression) Names() []string
Names is the list of calculating metrics
func (Regression) New ¶
func (m Regression) New(iteration int, subset string) MetricsUpdater
New iteration metrics
type Report ¶
type Report struct { History *tables.Table // all iterations history TheBest int // the best iteration Test, Train fu.Struct // the best iteration metrics Score float64 // the best score }
Report is an ML training report
type Training ¶
type Training struct { Iterations int // maximum iterations Metrics Metrics // evaluating metrics Score Score // score function ScoreHistory int // possible count of forehead training with lower score ModelFile iokit.Output // file to store final model Verbose interface{} // print function func(string) }
Training is the default implementation of unified training interface
type UnifiedTraining ¶
type UnifiedTraining interface { // Workout returns the first iteration workout Workout() Workout }
UnifiedTraining is an interface allowing to write any logging/staging backend for ML training
type Workout ¶
type Workout interface { Iteration() int TrainMetrics() MetricsUpdater TestMetrics() MetricsUpdater Complete(m MemorizeMap, train, test fu.Struct, metricsDone bool) (*Report, bool, error) Next() Workout Verbose(string) }
Workout is a training iteration abstraction