forked from sjwhitworth/golearn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sjwhitworth#8 from sjwhitworth/organizing
Add package file, rewrite import.
- Loading branch information
Showing
7 changed files
with
77 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
mat "github.com/skelterjohn/go.matrix" | ||
base "golearn/base" | ||
util "golearn/utilities" | ||
knnclass "golearn/knn" | ||
"fmt" | ||
) | ||
"fmt" | ||
|
||
func main(){ | ||
base "github.com/sjwhitworth/golearn/base" | ||
knnclass "github.com/sjwhitworth/golearn/knn" | ||
util "github.com/sjwhitworth/golearn/utilities" | ||
mat "github.com/skelterjohn/go.matrix" | ||
) | ||
|
||
func main() { | ||
//Parses the infamous Iris data. | ||
cols, rows, _, labels, data := base.ParseCsv("datasets/iris.csv", 4, []int{0,1,2}) | ||
cols, rows, _, labels, data := base.ParseCsv("datasets/iris.csv", 4, []int{0, 1, 2}) | ||
|
||
//Initialises a new KNN classifier | ||
knn := knnclass.KNNClassifier{} | ||
knn.C | ||
// knn.C | ||
knn.New("Testing", labels, data, rows, cols) | ||
|
||
for { | ||
//Creates a random array of N float64s between 0 and 7 | ||
randArray := util.RandomArray(3, 7) | ||
|
||
//Initialises a vector with this array | ||
random := mat.MakeDenseMatrix(randArray,1,3) | ||
random := mat.MakeDenseMatrix(randArray, 1, 3) | ||
|
||
//Calculates the Euclidean distance and returns the most popular label | ||
labels, _ := knn.Predict(random, 3) | ||
fmt.Println(labels) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
mat "github.com/skelterjohn/go.matrix" | ||
base "golearn/base" | ||
util "golearn/utilities" | ||
knnclass "golearn/knn" | ||
"fmt" | ||
) | ||
"fmt" | ||
|
||
func main(){ | ||
base "github.com/sjwhitworth/golearn/base" | ||
knnclass "github.com/sjwhitworth/golearn/knn" | ||
util "github.com/sjwhitworth/golearn/utilities" | ||
mat "github.com/skelterjohn/go.matrix" | ||
) | ||
|
||
func main() { | ||
//Parses the infamous Iris data. | ||
cols, rows, _, labels, data := base.ParseCsv("datasets/randomdata.csv", 2, []int{0,1}) | ||
cols, rows, _, labels, data := base.ParseCsv("datasets/randomdata.csv", 2, []int{0, 1}) | ||
newlabels := util.ConvertLabelsToFloat(labels) | ||
|
||
//Initialises a new KNN classifier | ||
knn := knnclass.KNNRegressor{} | ||
knn.New("Testing", newlabels, data, rows, cols) | ||
|
||
for { | ||
//Creates a random array of N float64s between 0 and Y | ||
randArray := util.RandomArray(2, 100) | ||
|
||
//Initialises a vector with this array | ||
random := mat.MakeDenseMatrix(randArray,1,2) | ||
random := mat.MakeDenseMatrix(randArray, 1, 2) | ||
|
||
//Calculates the Euclidean distance and returns the most popular label | ||
outcome, _ := knn.Predict(random, 3) | ||
fmt.Println(outcome) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package golearn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters