mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-25 13:48:49 +08:00
Merge pull request #127 from cratonica/master
Fix breakage due to gonum/matrix mat64.ErrShape
This commit is contained in:
commit
07485b621d
@ -5,6 +5,7 @@ package knn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gonum/matrix"
|
||||
"github.com/gonum/matrix/mat64"
|
||||
"github.com/sjwhitworth/golearn/base"
|
||||
"github.com/sjwhitworth/golearn/metrics/pairwise"
|
||||
@ -235,7 +236,7 @@ func NewKnnRegressor(distfunc string) *KNNRegressor {
|
||||
|
||||
func (KNN *KNNRegressor) Fit(values []float64, numbers []float64, rows int, cols int) {
|
||||
if rows != len(values) {
|
||||
panic(mat64.ErrShape)
|
||||
panic(matrix.ErrShape)
|
||||
}
|
||||
|
||||
KNN.Data = mat64.NewDense(rows, cols, numbers)
|
||||
|
@ -3,6 +3,7 @@ package pairwise
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/gonum/matrix"
|
||||
"github.com/gonum/matrix/mat64"
|
||||
)
|
||||
|
||||
@ -16,7 +17,7 @@ func (c *Chebyshev) Distance(vectorX *mat64.Dense, vectorY *mat64.Dense) float64
|
||||
r1, c1 := vectorX.Dims()
|
||||
r2, c2 := vectorY.Dims()
|
||||
if r1 != r2 || c1 != c2 {
|
||||
panic(mat64.ErrShape)
|
||||
panic(matrix.ErrShape)
|
||||
}
|
||||
|
||||
max := float64(0)
|
||||
|
@ -3,6 +3,7 @@ package pairwise
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/gonum/matrix"
|
||||
"github.com/gonum/matrix/mat64"
|
||||
)
|
||||
|
||||
@ -23,7 +24,7 @@ func (c *Cranberra) Distance(vectorX *mat64.Dense, vectorY *mat64.Dense) float64
|
||||
r1, c1 := vectorX.Dims()
|
||||
r2, c2 := vectorY.Dims()
|
||||
if r1 != r2 || c1 != c2 {
|
||||
panic(mat64.ErrShape)
|
||||
panic(matrix.ErrShape)
|
||||
}
|
||||
|
||||
sum := .0
|
||||
|
@ -3,6 +3,7 @@ package pairwise
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/gonum/matrix"
|
||||
"github.com/gonum/matrix/mat64"
|
||||
)
|
||||
|
||||
@ -18,7 +19,7 @@ func (m *Manhattan) Distance(vectorX *mat64.Dense, vectorY *mat64.Dense) float64
|
||||
r1, c1 := vectorX.Dims()
|
||||
r2, c2 := vectorY.Dims()
|
||||
if r1 != r2 || c1 != c2 {
|
||||
panic(mat64.ErrShape)
|
||||
panic(matrix.ErrShape)
|
||||
}
|
||||
|
||||
result := .0
|
||||
|
Loading…
x
Reference in New Issue
Block a user