model

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package model include models for perceptron

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FeatureClassKey

func FeatureClassKey(feat string, clas string) string

Types

type Class

type Class = KV

type Feature

type Feature = KV

type KV

type KV struct {
	Label string
	Value float64
}

func (KV) IsZero

func (k KV) IsZero() bool

type KVSlice

type KVSlice []KV

func NewKVSlice

func NewKVSlice(cap int) KVSlice

func (KVSlice) Len

func (s KVSlice) Len() int

func (KVSlice) Less

func (s KVSlice) Less(i, j int) bool

func (KVSlice) Swap

func (s KVSlice) Swap(i, j int)

type PerceptronJSONModel

type PerceptronJSONModel struct {
	Weights map[string]map[string]float64
	Classes map[string]struct{}
}

type Sentence

type Sentence struct {
	Words []string
	Tags  []string
}

type Weights

type Weights struct {
	// contains filtered or unexported fields
}

Each feature gets its own weight vector, so weights is a dict-of-dicts

func NewWeights

func NewWeights(cap int) *Weights

NewWeights init Weights

func NewWeightsFromMap

func NewWeightsFromMap(mp map[string]map[string]float64) *Weights

func (Weights) Features

func (w Weights) Features() <-chan string

Features

func (Weights) GetFeatureLength

func (w Weights) GetFeatureLength(feat string) int

func (Weights) GetFeatureWeights

func (w Weights) GetFeatureWeights(feat string) <-chan KV

GetFeatureWeights get a feat classes weights

func (Weights) GetWeight

func (w Weights) GetWeight(feat string, clas string) float64

GetWeight get class weight value

func (Weights) Map

func (w Weights) Map() map[string]map[string]float64

Map convert weights to map

func (*Weights) SetWeight

func (w *Weights) SetWeight(feat string, clas string, value float64)

SetWeight set a weight value for feat->clas

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL