set

package
v0.0.0-...-dbea759 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package set defines interfaces for sets as samples.

It also provides some basic implementations for them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sample

type Sample interface {
	ValueFor(feature.Feature) (interface{}, error)
}

Sample represents an item to process or from which to learn how to process them.

Its ValueFor method returns the value of the sample corresponding to the feature passed as parameter.

func NewSample

func NewSample(featureValues map[string]interface{}) Sample

NewSample takes a map of feature string names to values and a class and returns a sample.

type Set

type Set interface {
	Entropy(context.Context, feature.Feature) (float64, error)
	SubsetWith(context.Context, feature.Criterion) (Set, error)
	FeatureValues(context.Context, feature.Feature) ([]interface{}, error)
	CountFeatureValues(context.Context, feature.Feature) (map[string]int, error)
	Samples(context.Context) ([]Sample, error)
	Count(context.Context) (int, error)
}

Set represents a collection of samples.

Its Entropy method returns the entropy of the set for a given Feature: a measure of the disinformation we have on the classes of samples that belong to it.

Its Classes method returns the set of uniq classes of samples belonging to the set.

Its SubsetWith method takes a feature.Criterion and returns a subset that only contains samples that satisfy it.

Its Samples method returns the samples it contains

func New

func New(samples []Sample) Set

New takes a slice of samples and returns a set built with them. The set will be a CPU intensive one when the number of samples is over sampleCountThresholdForSetImplementation

func NewCPUIntensive

func NewCPUIntensive(samples []Sample) Set

NewCPUIntensive takes a slice of samples and returns a Set built with them. A cpu-intensive set is an implementation that instead of replicating the samples when subsetting, stores the applying feature criteria to define the subset and keeps the same sample slice. This can achieve a drastic reduction in memory use that comes at the cost of CPU time: every calculation that goes over the samples of the set will apply the feature criteria of the set on all original samples (the ones provided to this method).

func NewMemoryIntensive

func NewMemoryIntensive(samples []Sample) Set

NewMemoryIntensive takes a slice of samples and returns a Set built with them. A memory-intensive set is an implementation that replicates the slice of samples when subsetting to reduce calculations at the cost of increased memory.

Directories

Path Synopsis
Package csv provides functions to read/write a set.Set as CSV
Package csv provides functions to read/write a set.Set as CSV
Package inputsample provides an implementation of set.Sample that is read from an io.Reader.
Package inputsample provides an implementation of set.Sample that is read from an io.Reader.
Package sqlset provides implementations of set.Set that use SQL database as backends.
Package sqlset provides implementations of set.Set that use SQL database as backends.
pgadapter
Package pgadapter provides an implementation of the Adapter interface in the sqlset package that works over a PostgreSQL database.
Package pgadapter provides an implementation of the Adapter interface in the sqlset package that works over a PostgreSQL database.
sqlite3adapter
Package sqlite3adapter provides an implementation of the Adapter interface in the sqlset package that works over a SQLite3 database.
Package sqlite3adapter provides an implementation of the Adapter interface in the sqlset package that works over a SQLite3 database.

Jump to

Keyboard shortcuts

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