Documentation
¶
Index ¶
- func ParseClass(entity PythonClass, obj interface{}) (err error)
- type Build
- type Decoder
- type Dict
- type Global
- type List
- type None
- type NumpyArrayRaw
- type NumpyDType
- type NumpyElementFunc
- type NumpyRawBytes
- type NumpyScalarRaw
- type PythonClass
- type Reduce
- type SKlearnInitEstimator
- type SklearnDecisionTreeRegressor
- type SklearnGradientBoosting
- type SklearnNode
- type SklearnTree
- type Tuple
- type Unicode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseClass ¶
func ParseClass(entity PythonClass, obj interface{}) (err error)
ParseClass calls PythonClass's Reduce and Build methods
Types ¶
type Build ¶
type Build struct {
Object interface{}
// Args are usually represented like Tuple (arguments for custom __setstate__) or Dict (class members)
Args interface{}
}
Build is result of BUILD pickle command (usually class __setstate__ call)
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements decoding pickle file from `reader`. It reads op byte (pickle command), do command, push result in `machine` object. Main method is `Decode`
type Dict ¶
type Dict map[string]interface{}
Dict represents python's dict. For our purpose it's sufficient to have only string keys
type NumpyArrayRaw ¶
type NumpyArrayRaw struct {
Type NumpyDType
Shape []int
// For plain data objects array data are stored in NumpyRawBytes
Data NumpyRawBytes
// But in case when data objects are python objects, they are parsed to []interface{}
DataList []interface{}
}
NumpyArrayRaw represent numpy ndarray parsed from pickle
func (*NumpyArrayRaw) Build ¶
func (a *NumpyArrayRaw) Build(build Build) (err error)
func (*NumpyArrayRaw) Reduce ¶
func (a *NumpyArrayRaw) Reduce(reduce Reduce) (err error)
type NumpyDType ¶
func (*NumpyDType) Build ¶
func (d *NumpyDType) Build(build Build) error
func (*NumpyDType) Reduce ¶
func (d *NumpyDType) Reduce(reduce Reduce) error
type NumpyElementFunc ¶
type NumpyRawBytes ¶
type NumpyRawBytes []byte
func (*NumpyRawBytes) Build ¶
func (b *NumpyRawBytes) Build(build Build) (err error)
func (*NumpyRawBytes) Iterate ¶
func (b *NumpyRawBytes) Iterate(length int, parse NumpyElementFunc) (err error)
Iterate iterates over bytes chunks of length `length` and call `parse` function on each
func (*NumpyRawBytes) Reduce ¶
func (b *NumpyRawBytes) Reduce(reduce Reduce) (err error)
type NumpyScalarRaw ¶
type NumpyScalarRaw struct {
Type NumpyDType
Data NumpyRawBytes
}
func (*NumpyScalarRaw) Build ¶
func (s *NumpyScalarRaw) Build(build Build) (err error)
func (*NumpyScalarRaw) Reduce ¶
func (s *NumpyScalarRaw) Reduce(reduce Reduce) (err error)
type PythonClass ¶
PythonClass is interface to restore python class representation in Go struct. Pickle restore python classes in two steps: 1. REDUCE (like __init__ call). 2. BUILD (like __setstate__ call)
type Reduce ¶
type Reduce struct {
Callable interface{}
Args Tuple
}
Reduce is result of REDUCE pickle command (usually class __init__ call)
type SKlearnInitEstimator ¶
func (*SKlearnInitEstimator) Build ¶
func (e *SKlearnInitEstimator) Build(build Build) (err error)
func (*SKlearnInitEstimator) Reduce ¶
func (e *SKlearnInitEstimator) Reduce(reduce Reduce) (err error)
type SklearnDecisionTreeRegressor ¶
type SklearnDecisionTreeRegressor struct {
Tree SklearnTree
NClasses int
MaxFeatures int
NOutputs int
}
func (*SklearnDecisionTreeRegressor) Build ¶
func (t *SklearnDecisionTreeRegressor) Build(build Build) (err error)
func (*SklearnDecisionTreeRegressor) Reduce ¶
func (t *SklearnDecisionTreeRegressor) Reduce(reduce Reduce) (err error)
type SklearnGradientBoosting ¶
type SklearnGradientBoosting struct {
NClasses int
Classes []int
NEstimators int
MaxFeatures int
Estimators []SklearnDecisionTreeRegressor
LearningRate float64
InitEstimator SKlearnInitEstimator
}
func (*SklearnGradientBoosting) Build ¶
func (t *SklearnGradientBoosting) Build(build Build) (err error)
func (*SklearnGradientBoosting) Reduce ¶
func (t *SklearnGradientBoosting) Reduce(reduce Reduce) (err error)
type SklearnNode ¶
type SklearnNode struct {
LeftChild int
RightChild int
Feature int
Threshold float64
Impurity float64
NNodeSamples int
WeightedNNodeSamples float64
}
SklearnNode represents tree node data structure
func SklearnNodeFromBytes ¶
func SklearnNodeFromBytes(bytes []byte) SklearnNode
SklearnNodeFromBytes converts 56 raw bytes into SklearnNode struct The rule described in https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_tree.pyx#L70 (NODE_DTYPE) 'names': ['left_child', 'right_child', 'feature', 'threshold', 'impurity', 'n_node_samples', 'weighted_n_node_samples'], 'formats': [np.intp, np.intp, np.intp, np.float64, np.float64, np.intp, np.float64]
type SklearnTree ¶
type SklearnTree struct {
NOutputs int
Classes []int
NNodes int
Nodes []SklearnNode
Values []float64
}
SklearnTree represents parsed tree struct
func (*SklearnTree) Build ¶
func (t *SklearnTree) Build(build Build) (err error)
func (*SklearnTree) Reduce ¶
func (t *SklearnTree) Reduce(reduce Reduce) (err error)