Skip to content

Commit

Permalink
Add average perceptron file
Browse files Browse the repository at this point in the history
Rough out logic flow for an average perceptron

Fleshed out example data. Working on FixedDataGrid
support.

Dont use Binary use Float

Update processData to use base helpers to read csv

Move class to end of feature list

Add test for processData

process data to instances

Create path fixed

Add test around Fit. First steps

Modified example, added tests, small fixes
  • Loading branch information
Ross Hendrickson authored and Sentimentron committed Jan 15, 2015
1 parent dbf1c9a commit 5c302a1
Show file tree
Hide file tree
Showing 4 changed files with 774 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/averageperceptron/averageperceptionexample.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"fmt"
base "github.com/sjwhitworth/golearn/base"
evaluation "github.com/sjwhitworth/golearn/evaluation"
perceptron "github.com/sjwhitworth/golearn/perceptron"
"math/rand"
)

func main() {

rand.Seed(4402201)

rawData, err := base.ParseCSVToInstances("../datasets/house-votes-84.csv", true)
if err != nil {
panic(err)
}

//Initialises a new AveragePerceptron classifier
cls := perceptron.NewAveragePerceptron(10, 1.2, 0.5, 0.3)

//Do a training-test split
trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50)
fmt.Println(trainData)
fmt.Println(testData)
cls.Fit(trainData)

predictions := cls.Predict(testData)

// Prints precision/recall metrics
confusionMat := evaluation.GetConfusionMatrix(testData, predictions)
fmt.Println(evaluation.GetSummary(confusionMat))
}
Loading

0 comments on commit 5c302a1

Please sign in to comment.