Documentation ¶
Index ¶
- Constants
- Variables
- type AgglomerativeClustering
- type DBScan
- type FILInferenceAlgorithm
- type FILModel
- type FILModelType
- type FILStorageType
- type GlmSolverAlgo
- type Kmeans
- type KmeansInit
- type LinearRegression
- func (m *LinearRegression) Close() error
- func (m *LinearRegression) Fit(x []float32, numRow int, numCol int, labels []float32) error
- func (m *LinearRegression) GetParams() []float32
- func (m *LinearRegression) Predict(x []float32, numRow int, numCol int, result []float32) ([]float32, error)
- func (m *LinearRegression) SetParams(coef []float32)
- type LogLevel
- type Metric
- type RidgeRegression
- func (m *RidgeRegression) Close() error
- func (m *RidgeRegression) Fit(x []float32, numRow int, numCol int, labels []float32) error
- func (m *RidgeRegression) GetParams() []float32
- func (m *RidgeRegression) Predict(x []float32, numRow int, numCol int, result []float32) ([]float32, error)
- func (m *RidgeRegression) SetParams(coef []float32)
Constants ¶
const ( KMeansPlusPlus = iota Random Array )
const ( Svd = 0 Eig = 1 Qr = 2 )
const ( /** evaluate as dist_ij = sum(x_ik^2) + sum(y_ij)^2 - 2*sum(x_ik * y_jk) */ L2Expanded = 0 /** same as above, but inside the epilogue, perform square root operation */ L2SqrtExpanded = 1 /** cosine distance */ CosineExpanded = 2 /** L1 distance */ L1 = 3 /** evaluate as dist_ij += (x_ik - y-jk)^2 */ L2Unexpanded = 4 /** same as above, but inside the epilogue, perform square root operation */ L2SqrtUnexpanded = 5 /** basic inner product **/ InnerProduct = 6 /** Chebyshev (Linf) distance **/ Linf = 7 /** Canberra distance **/ Canberra = 8 /** Generalized Minkowski distance **/ LpUnexpanded = 9 /** Correlation distance **/ CorrelationExpanded = 10 /** Jaccard distance **/ JaccardExpanded = 11 /** Hellinger distance **/ HellingerExpanded = 12 /** Haversine distance **/ Haversine = 13 /** Bray-Curtis distance **/ BrayCurtis = 14 /** Jensen-Shannon distance**/ JensenShannon = 15 /** Hamming distance **/ HammingUnexpanded = 16 /** KLDivergence **/ KLDivergence = 17 /** RusselRao **/ RusselRaoExpanded = 18 /** Dice-Sorensen distance **/ DiceExpanded = 19 /** Precomputed (special value) **/ Precomputed = 100 )
Variables ¶
var ( // ErrFILModelLoad is returned when fail to load model. ErrFILModelLoad = errors.New("fail to load model") // ErrFILModelFree is returned when fail to free model. ErrFILModelFree = errors.New("fail to free model") // ErrFILModelPredict is returned when fail to predict. ErrFILModelPredict = errors.New("fail to predict") )
var (
ErrAgglomerativeClustering = errors.New("fail to agglomerative clustering")
)
var (
ErrDBScan = errors.New("fail to dbscan")
)
var (
ErrKmeans = errors.New("fail to kmeans")
)
Functions ¶
This section is empty.
Types ¶
type AgglomerativeClustering ¶
type AgglomerativeClustering struct {
// contains filtered or unexported fields
}
func (*AgglomerativeClustering) Close ¶
func (c *AgglomerativeClustering) Close() error
type FILInferenceAlgorithm ¶
type FILInferenceAlgorithm int
FILInferenceAlgorithm is the inference algorithm.
const ( // AlgoAuto choose the algorithm automatically; currently chooses NAIVE for sparse forests // and BatchTreeReorg for dense ones AlgoAuto FILInferenceAlgorithm = iota // Naive naive algorithm: 1 thread block predicts 1 row; the row is cached in // shared memory, and the trees are distributed cyclically between threads Naive // TreeReorg tree reorg algorithm: same as naive, but the tree nodes are rearranged // into a more coalescing-friendly layout: for every node position, // nodes of all trees at that position are stored next to each other TreeReorg // BatchTreeReorg batch tree reorg algorithm: same as tree reorg, but predictions multiple rows (up to 4) // in a single thread block BatchTreeReorg )
type FILModel ¶
type FILModel struct {
// contains filtered or unexported fields
}
FILModel is a Forest Inference Library model.
func NewFILModel ¶
func NewFILModel( modelType FILModelType, filePath string, algo FILInferenceAlgorithm, classification bool, threshold float32, storageType FILStorageType, blocksPerSm int, threadsPerTree int, nItems int, ) (*FILModel, error)
NewFILModel algo is the inference algorithm. threshold may be used for thresholding if classification == true, and is ignored otherwise. threshold is ignored if leaves store vectorized class labels. in that case, a class with most votes is returned regardless of the absolute vote count. blocksPerSm if nonzero, works as a limit to improve cache hit rate for larger forests suggested values (if nonzero) are from 2 to 7. if zero, launches ceildiv(num_rows, NITEMS) blocks. threadsPerTree determines how many threads work on a single tree at once inside a block can only be a power of 2 nItems is how many input samples (items) any thread processes. If 0 is given, choose most (up to 4) that fit into shared memory.
func (*FILModel) Predict ¶
func (m *FILModel) Predict( x []float32, numRow int, outputClassProbability bool) ([]float32, error)
Predict returns the prediction result. result is a float array of size num_row * num_class if output_class_probability is true, or num_row otherwise. given a row r and class c, the probability of r belonging to c is stored in result[r * num_class + c].
type FILModelType ¶
type FILModelType int
FILModelType is the type of the forest.
const ( // XGBoost xgboost model (binary model file) XGBoost FILModelType = iota // XGBoostJSON xgboost model (json model file) XGBoostJSON // LightGBM lighgbm model (binary model file) LightGBM )
type FILStorageType ¶
type FILStorageType int
FILStorageType is the storage type of the forest.
const ( // Auto decide automatically; currently always builds dense forests Auto FILStorageType = iota // Dense import the forest as dense Dense // Sparse import the forest as sparse (currently always with 16-byte nodes) Sparse // Sparse8 (experimental) import the forest as sparse with 8-byte nodes; can fail if // 8-byte nodes are not enough to store the forest, e.g. there are too many // nodes in a tree or too many features; note that the number of bits used to // store the child or feature index can change in the future; this can affect // whether a particular forest can be imported as SPARSE8 */ Sparse8 )
type GlmSolverAlgo ¶
type GlmSolverAlgo int
type KmeansInit ¶
type KmeansInit int
type LinearRegression ¶
type LinearRegression struct {
// contains filtered or unexported fields
}
func NewLinearRegression ¶
func NewLinearRegression( fitIntercept bool, normalize bool, algo GlmSolverAlgo, ) (*LinearRegression, error)
func (*LinearRegression) Close ¶
func (m *LinearRegression) Close() error
func (*LinearRegression) GetParams ¶
func (m *LinearRegression) GetParams() []float32
func (*LinearRegression) SetParams ¶
func (m *LinearRegression) SetParams(coef []float32)
type RidgeRegression ¶
type RidgeRegression struct {
// contains filtered or unexported fields
}
func NewRidgeRegression ¶
func NewRidgeRegression( alpha float32, fitIntercept bool, normalize bool, algo GlmSolverAlgo, ) (*RidgeRegression, error)
func (*RidgeRegression) Close ¶
func (m *RidgeRegression) Close() error
func (*RidgeRegression) GetParams ¶
func (m *RidgeRegression) GetParams() []float32
func (*RidgeRegression) SetParams ¶
func (m *RidgeRegression) SetParams(coef []float32)