classifiers

package
v0.0.0-...-7099e15 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_TRAINING_SHARE = .75
)
View Source
const (
	NO_PREDICTION = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DataSet

type DataSet struct {
	ClassNames     []string `json:"classes"`
	AttributeNames []string `json:"attributes"`
	Records        []Record `json:"data"`
}

func FromCSV

func FromCSV(dsCsv []byte) (*DataSet, error)

FromCSV builds a DataSet from CSV data. Returns nil and an error if the data cannot be processed correctly.

func FromCSVFile

func FromCSVFile(path string) (*DataSet, error)

FromCSVFile reads the CSV-formatted file and creates a DataSet from it.

func FromJSON

func FromJSON(dsJson []byte) (*DataSet, error)

func FromJSONFile

func FromJSONFile(path string) (*DataSet, error)

func NewDataSet

func NewDataSet(classes, attributes []string, data []Record) (*DataSet, error)

func (*DataSet) Attributes

func (ds *DataSet) Attributes() []string

func (*DataSet) Classes

func (ds *DataSet) Classes() []string

func (*DataSet) MarshalCSV

func (ds *DataSet) MarshalCSV() []byte

MarshalCSV converts the DataSet to a byte slice containing the CSV representation (including a header row listing the attributes and terminated by the column header for the class column).

func (*DataSet) Split

func (ds *DataSet) Split(cfg *DataSplitConfig) (*DataSet, *DataSet, error)

Split divides the dataset into separate datasets - the first is the training data, the second is the test data Passing nil for the config results in a random split with 75% of the records used for training. This does not modify the original DataSet.

type DataSplitConfig

type DataSplitConfig struct {
	TrainingShare float64
	Method        DataSplitMethod
}

type DataSplitMethod

type DataSplitMethod int
const (
	SplitRandom DataSplitMethod = iota
	SplitSequential
)

type Record

type Record struct {
	Class           int                    `json:"class"`
	AttributeValues wyvern.Vector[float64] `json:"values"`
}

type TestResult

type TestResult struct {
	Record
	Predicted int
}

type TestResults

type TestResults []TestResult

func (TestResults) Analyze

func (trs TestResults) Analyze() TestResultsAnalysis

type TestResultsAnalysis

type TestResultsAnalysis struct {
	ResultCount    int
	CorrectCount   int
	IncorrectCount int
	Accuracy       float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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