1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-26 13:49:14 +08:00

Fix breakage due to gonum/matrix mat64.ErrShape

This commit is contained in:
Clint Caywood 2015-10-24 22:44:24 -07:00
parent 51ca101d6c
commit d9d15fb735
4 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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