Documentation
¶
Overview ¶
Package goscore is a go scoring API for PMML files
Index ¶
- Variables
- func ArctanActivationFunction(Z float64) float64
- func CosineActivationFunction(Z float64) float64
- func ElliottActivationFunction(Z float64) float64
- func EtnGshl() error
- func ExponentialActivationFunction(Z float64) float64
- func GaussActivationFunction(Z float64) float64
- func IdentityActivationFunction(b float64) float64
- func LogisticActivationFunction(b float64) float64
- func ReciprocalActivationFunction(Z float64) float64
- func RectifierActivationFunction(Z float64) float64
- func SineActivationFunction(Z float64) float64
- func SoftmaxNormalizationMethod(input ...float64) []float64
- func SoftmaxNormalizationMethods(confidence map[string]float64) (map[string]float64, error)
- func SquareActivationFunction(Z float64) float64
- func TanhActivationFunction(b float64) float64
- type ActivationFunction
- type Contribution
- type DerivedField
- type FieldRef
- type GradientBoostedModel
- type LogisticRegression
- type MiningField
- type NeuralInputs
- type NeuralLayer
- type NeuralNetWorkStructure
- type NeuralNetwork
- type NeuralOutput
- type NeuralOutputs
- type Neuron
- type Node
- type NormDiscrete
- type NormalizationMethod
- type NormalizationMethodMap
- type NumericPredictor
- type OutputField
- type Outputs
- type PMMLLR
- type PMMLNN
- type RandomForest
- func (rf RandomForest) LabelScores(features map[string]interface{}) (map[string]float64, error)
- func (rf RandomForest) LabelScoresConcurrently(features map[string]interface{}) (map[string]float64, error)
- func (rf RandomForest) Score(features map[string]interface{}, label string) (float64, error)
- func (rf RandomForest) ScoreConcurrently(features map[string]interface{}, label string) (float64, error)
- type RegressionTable
- type SimplePredicate
- type SimpleSetPredicate
Constants ¶
This section is empty.
Variables ¶
var ActivationFunctionNotImplemented = errors.New("Activation Function Not Implemented Yet")
var ActivationFunctions map[string]ActivationFunction
var NormalizationMethodMaps map[string]NormalizationMethodMap
var NormalizationMethodNotImplemented = errors.New("Normalization Method Not Implemented Yet")
var NormalizationMethods map[string]NormalizationMethod
Functions ¶
func GaussActivationFunction ¶
func SineActivationFunction ¶
func SoftmaxNormalizationMethods ¶
function for compute confidence value into probability using softMax function input : map of confidence value with float64 type output : map of probability each class with float64 type
func TanhActivationFunction ¶
Types ¶
type ActivationFunction ¶
func NewThresHoldFunction ¶
func NewThresHoldFunction(a float64) ActivationFunction
type Contribution ¶
type DerivedField ¶
type DerivedField struct { DataType string `xml:"dataType,attr"` FieldRef FieldRef NormDiscrete NormDiscrete }
func (*DerivedField) GetInputName ¶
func (d *DerivedField) GetInputName() string
type GradientBoostedModel ¶
type GradientBoostedModel struct { Version string `xml:"version,attr"` Trees []Node `xml:"MiningModel>Segmentation>Segment>MiningModel>Segmentation>Segment>TreeModel"` Target target `xml:"MiningModel>Segmentation>Segment>MiningModel>Targets>Target"` Constant float64 `xml:"MiningModel>Segmentation>Segment>MiningModel>Output>OutputField>Apply>Constant"` }
GradientBoostedModel - GradientBoostedModel PMML
func LoadGradientBoostedModel ¶
func LoadGradientBoostedModel(fileName string) (gbm GradientBoostedModel, err error)
LoadGradientBoostedModel - Load Gradient Boosted Model PMML file to GradientBoostedModel struct
func (*GradientBoostedModel) Score ¶
func (gbm *GradientBoostedModel) Score(features map[string]interface{}) (float64, error)
Score - traverses all trees in GradientBoostedModel with features and returns exp(sum) / (1 + exp(sum)) where sum is sum of trees + rescale constant
func (*GradientBoostedModel) ScoreConcurrently ¶
func (gbm *GradientBoostedModel) ScoreConcurrently(features map[string]interface{}) (float64, error)
ScoreConcurrently - same as Score but concurrent
type LogisticRegression ¶
type LogisticRegression struct { // struct xml:PMML>RegressionModel NormalizationMethod string `xml:"normalizationMethod,attr"` Fields []MiningField `xml:"MiningSchema>MiningField"` RegressionTable []RegressionTable `xml:"RegressionTable"` }
func NewLogisticRegression ¶
func NewLogisticRegression(source []byte) (*LogisticRegression, error)
func (*LogisticRegression) RegressionFunctionContinuous ¶
func (lr *LogisticRegression) RegressionFunctionContinuous(features map[string]float64) map[string]float64
method for calculate feature using logistic regression function for countinous independent variable
func (*LogisticRegression) Score ¶
func (lr *LogisticRegression) Score(args ...interface{}) (string, map[string]float64, error)
method for score test data input : independent variable with map["var name"]value
voting with boolean type true (default) -> using normalization false -> without normalization
return : -label with string type
-confident/prob with map type -errors
func (*LogisticRegression) SetupNumbericPredictorMap ¶
func (lr *LogisticRegression) SetupNumbericPredictorMap()
create map for containing numeric predictor
type MiningField ¶
type MiningField struct {
Name string `xml:"name,attr"`
}
type NeuralInputs ¶
type NeuralInputs struct {
Input []Neuron `xml:"NeuralInput"`
}
type NeuralLayer ¶
type NeuralNetWorkStructure ¶
type NeuralNetWorkStructure struct { }
type NeuralNetwork ¶
type NeuralNetwork struct { XMLName xml.Name //Struct NeuralNetWorkStructure `xml:"PMML>NeuralNetwork"` InputLayer NeuralInputs `xml:"NeuralInputs"` NeuralOutputs NeuralOutputs `xml:"NeuralOutputs"` OutputLayer Outputs `xml:"Output"` Fields []MiningField `xml:"MiningSchema>MiningField"` Layers []NeuralLayer `xml:"NeuralLayer"` ActivationFunction string `xml:"activationFunction,attr"` NormalizationMethod string `xml:"normalizationMethod,attr"` Threshold float64 `xml:"threshold,attr"` }
func NewNeuralNetwork ¶
func NewNeuralNetwork(source []byte) (*NeuralNetwork, error)
func NewNeuralNetworkFromReader ¶
func NewNeuralNetworkFromReader(source io.Reader) (*NeuralNetwork, error)
type NeuralOutput ¶
type NeuralOutput struct { OutputNeuron string `xml:"outputNeuron,attr"` DerivedField DerivedField `xml:"DerivedField"` }
type NeuralOutputs ¶
type NeuralOutputs struct {
NeuralOutput []NeuralOutput `xml:"NeuralOutput"`
}
type Neuron ¶
type Neuron struct { Id string `xml:"id,attr"` DerivedFieldType DerivedField `xml:"DerivedField"` Bias float64 `xml:"bias,attr"` Contribution []Contribution `xml:"Con"` }
type Node ¶
type Node struct { XMLName xml.Name Attrs []xml.Attr `xml:",any,attr"` Content []byte `xml:",innerxml"` Nodes []Node `xml:",any"` True truePredicate `xml:"True"` DummyMiningSchema dummyMiningSchema `xml:"MiningSchema"` SimplePredicate SimplePredicate `xml:"SimplePredicate"` SimpleSetPredicate SimpleSetPredicate `xml:"SimpleSetPredicate"` }
Node - PMML tree node
type NormDiscrete ¶
type NormDiscrete struct {
Value string `xml:"value,attr"`
}
type NormalizationMethod ¶
type NormalizationMethodMap ¶
type NumericPredictor ¶
type OutputField ¶
type Outputs ¶
type Outputs struct {
OutputField []OutputField `xml:"OutputField"`
}
type PMMLLR ¶
type PMMLLR struct { // struct xml:PMML LogisticRegression LogisticRegression `xml:"RegressionModel"` }
type PMMLNN ¶
type PMMLNN struct {
NeuralNetwork NeuralNetwork `xml:"NeuralNetwork"`
}
type RandomForest ¶
type RandomForest struct { XMLName xml.Name Trees []Node `xml:"MiningModel>Segmentation>Segment>TreeModel"` }
RandomForest - PMML Random Forest
func LoadRandomForest ¶
func LoadRandomForest(fileName string) (rf RandomForest, err error)
LoadRandomForest - Load Random Forest PMML file to RandomForest struct
func (RandomForest) LabelScores ¶
func (rf RandomForest) LabelScores(features map[string]interface{}) (map[string]float64, error)
LabelScores - traverses all trees in RandomForest with features and maps result labels to how many trees returned those label
func (RandomForest) LabelScoresConcurrently ¶
func (rf RandomForest) LabelScoresConcurrently(features map[string]interface{}) (map[string]float64, error)
LabelScoresConcurrently - same as LabelScores but concurrent
func (RandomForest) Score ¶
func (rf RandomForest) Score(features map[string]interface{}, label string) (float64, error)
Score - traverses all trees in RandomForest with features and returns ratio of given label results count to all results count
func (RandomForest) ScoreConcurrently ¶
func (rf RandomForest) ScoreConcurrently(features map[string]interface{}, label string) (float64, error)
ScoreConcurrently - same as Score but concurrent
type RegressionTable ¶
type RegressionTable struct { // struct xml:PMML>RegressionModel>RegressionTable Intercept float64 `xml:"intercept,attr"` TargetCategory string `xml:"targetCategory,attr"` NumericPredictor []NumericPredictor `xml:"NumericPredictor"` NumericPredictorMap *map[string]float64 }
type SimplePredicate ¶
type SimplePredicate struct { Field string `xml:"field,attr"` Operator string `xml:"operator,attr"` Value string `xml:"value,attr"` }
SimplePredicate - PMML simple predicate
func (SimplePredicate) True ¶
func (p SimplePredicate) True(features map[string]interface{}) bool
True - Evaluates to true if features input is true for SimplePredicate
type SimpleSetPredicate ¶
type SimpleSetPredicate struct { Field string `xml:"field,attr"` Operator string `xml:"booleanOperator,attr"` Values string `xml:"Array"` }
SimpleSetPredicate - PMML simple set predicate
func (SimpleSetPredicate) True ¶
func (p SimpleSetPredicate) True(features map[string]interface{}) bool
True - Evaluates to true if features input is true for SimpleSetPredicate