Skip to content

Commit 26b55ef

Browse files
committed
updated for gonum changes:
mat.IsZero=>mat.IsEmpty SVD.UTo,SVD.VTo updated .travis.yml for go1.13
1 parent f723ca0 commit 26b55ef

File tree

15 files changed

+35
-93
lines changed

15 files changed

+35
-93
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
language: go
33

44
go:
5-
- 1.12.x
5+
- 1.13.x
66

77
before_install:
88
- go get -t -v ./... && go build -v ./...

cluster/dbscan.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (m *DBSCAN) GetNOutputs() int { return 1 }
130130
func (m *DBSCAN) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
131131
Y := base.ToDense(Ymutable)
132132
nSamples, _ := X.Dims()
133-
if Y.IsZero() {
133+
if Y.IsEmpty() {
134134
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
135135
}
136136
// return m.Labels in Y

cluster/kmeans.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (m *KMeans) predict(Xscaled mat.Matrix, y, CentroidCount []int, changed *bo
148148
func (m *KMeans) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
149149
Y := base.ToDense(Ymutable)
150150
nSamples, _ := X.Dims()
151-
if Y.IsZero() {
151+
if Y.IsEmpty() {
152152
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
153153
}
154154
y := make([]int, nSamples)

go.mod

+4-9
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@ module github.com/pa-m/sklearn
33
require (
44
github.com/ajstarks/svgo v0.0.0-20190826172357-de52242f3d65 // indirect
55
github.com/chewxy/math32 v1.0.4
6+
github.com/davecgh/go-spew v1.1.1 // indirect
67
github.com/fogleman/gg v1.3.0 // indirect
78
github.com/jung-kurt/gofpdf v1.10.1 // indirect
8-
github.com/mgechev/revive v0.0.0-20190917153825-40564c5052ae // indirect
9+
github.com/kr/pretty v0.1.0 // indirect
910
github.com/pa-m/optimize v0.0.0-20190612075243-15ee852a6d9a
1011
github.com/pa-m/randomkit v0.0.0-20190612075210-f24d270692b4
1112
github.com/pkg/errors v0.8.1
12-
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237 // indirect
13-
github.com/stretchr/objx v0.2.0 // indirect
14-
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
1513
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979
1614
golang.org/x/image v0.0.0-20190902063713-cb417be4ba39 // indirect
17-
golang.org/x/mobile v0.0.0-20190830201351-c6da95954960 // indirect
18-
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
19-
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd // indirect
20-
golang.org/x/tools v0.0.0-20190905235650-93dcc2f048f5
21-
gonum.org/v1/gonum v0.0.0-20190904110519-2065cbd6b42a
15+
golang.org/x/tools v0.0.0-20190905235650-93dcc2f048f5 // indirect
16+
gonum.org/v1/gonum v0.0.0-20190929233944-b20cf7805fc4
2217
gonum.org/v1/plot v0.0.0-20190615073203-9aa86143727f
2318
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
2419
gorgonia.org/tensor v0.9.1

go.sum

+11-67
Large diffs are not rendered by default.

linear_model/Base.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (regr *RegularizedRegression) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter {
126126
func (regr *LinearRegression) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
127127
Y := base.ToDense(Ymutable)
128128
nSamples, _ := X.Dims()
129-
if Y.IsZero() {
129+
if Y.IsEmpty() {
130130
*Y = *mat.NewDense(nSamples, regr.GetNOutputs(), nil)
131131
}
132132
regr.DecisionFunction(X, Y)
@@ -279,7 +279,7 @@ func (regr *SGDRegressor) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter {
279279
func (regr *SGDRegressor) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
280280
Y := base.ToDense(Ymutable)
281281
nSamples, _ := X.Dims()
282-
if Y.IsZero() {
282+
if Y.IsEmpty() {
283283
*Y = *mat.NewDense(nSamples, regr.GetNOutputs(), nil)
284284
}
285285
regr.DecisionFunction(X, Y)

linear_model/bayes.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ func (regr *BayesianRidge) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter {
7575
if !svd.Factorize(X, mat.SVDThin) {
7676
panic("svd failed")
7777
}
78-
U, S, VhT := svd.UTo(nil), svd.Values(nil), svd.VTo(nil)
78+
U, VhT := &mat.Dense{}, &mat.Dense{}
79+
svd.UTo(U)
80+
S := svd.Values(nil)
81+
svd.VTo(VhT)
7982
unused(U)
8083

8184
eigenVals := make([]float, len(S))
@@ -223,7 +226,7 @@ func (regr *BayesianRidge) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dens
223226
// fmt.Println("Predict", d(X), d(regr.Coef))
224227
Y := base.ToDense(Ymutable)
225228
nSamples, _ := X.Dims()
226-
if Y.IsZero() {
229+
if Y.IsEmpty() {
227230
*Y = *mat.NewDense(nSamples, regr.GetNOutputs(), nil)
228231
}
229232
Y.Mul(X, regr.Coef)

linear_model/logistic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (m *LogisticRegression) fitLbfgs(X, y blas64.General, activations []blas64.
453453
// The returned estimates for all classes are ordered by the label of classes.
454454
func (m *LogisticRegression) PredictProbas(Xmatrix mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
455455
X, Y := base.ToDense(Xmatrix).RawMatrix(), base.ToDense(Ymutable)
456-
if Y.IsZero() {
456+
if Y.IsEmpty() {
457457
fanOut := 0
458458
if m.lb != nil {
459459
for _, classes := range m.lb.Classes {

naive_bayes/naivebayes.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (m *BaseNB) Predict(X mat.Matrix, Y mat.Mutable) *mat.Dense {
5151
func (m *BaseNB) PredictLogProbas(Xmatrix mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
5252
X, Y := base.ToDense(Xmatrix), base.ToDense(Ymutable)
5353
Xraw := X.RawMatrix()
54-
if Y.IsZero() {
54+
if Y.IsEmpty() {
5555
fanOut := len(m.Classes)
5656
Y = mat.NewDense(Xraw.Rows, fanOut, nil)
5757
}
@@ -74,7 +74,7 @@ func (m *BaseNB) PredictLogProbas(Xmatrix mat.Matrix, Ymutable mat.Mutable) *mat
7474
// PredictProbas return log-probability estimates.
7575
func (m *BaseNB) PredictProbas(Xmatrix mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
7676
X, Y := base.ToDense(Xmatrix), base.ToDense(Ymutable)
77-
if Y.IsZero() {
77+
if Y.IsEmpty() {
7878
fanOut := len(m.Classes)
7979
Y = mat.NewDense(X.RawMatrix().Rows, fanOut, nil)
8080
}

neighbors/classification.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (m *KNeighborsClassifier) GetNOutputs() int {
5858
func (m *KNeighborsClassifier) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
5959
Y := base.ToDense(Ymutable)
6060
nSamples, _ := X.Dims()
61-
if Y.IsZero() {
61+
if Y.IsEmpty() {
6262
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
6363
}
6464

neighbors/nearest_centroid.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (m *NearestCentroid) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter {
7373
func (m *NearestCentroid) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
7474
Y := base.ToDense(Ymutable)
7575
nSamples, _ := X.Dims()
76-
if Y.IsZero() {
76+
if Y.IsEmpty() {
7777
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
7878
}
7979

neighbors/regression.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (m *KNeighborsRegressor) GetNOutputs() int { return m.Y.RawMatrix().Cols }
6161
func (m *KNeighborsRegressor) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
6262
Y := base.ToDense(Ymutable)
6363
nSamples, _ := X.Dims()
64-
if Y.IsZero() {
64+
if Y.IsEmpty() {
6565
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
6666
}
6767

neural_network/multilayer_perceptron.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (mlp *MLPRegressor) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter {
5353
func (mlp *MLPRegressor) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
5454
Y := base.ToDense(Ymutable)
5555
nSamples, _ := X.Dims()
56-
if Y.IsZero() {
56+
if Y.IsEmpty() {
5757
*Y = *mat.NewDense(nSamples, mlp.GetNOutputs(), nil)
5858
}
5959

@@ -109,7 +109,7 @@ func (mlp *MLPClassifier) Fit(Xmatrix, Ymatrix mat.Matrix) base.Fiter {
109109
func (mlp *MLPClassifier) Predict(X mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
110110
Y := base.ToDense(Ymutable)
111111
nSamples, _ := X.Dims()
112-
if Y.IsZero() {
112+
if Y.IsEmpty() {
113113
*Y = *mat.NewDense(nSamples, mlp.GetNOutputs(), nil)
114114
}
115115

svm/svm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func (m *SVC) Predict(Xmatrix mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
312312
X, Y := base.ToDense(Xmatrix), base.ToDense(Ymutable)
313313
nSamples, _ := X.Dims()
314314

315-
if Y.IsZero() {
315+
if Y.IsEmpty() {
316316
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
317317
}
318318
binary := true

svm/svr.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func svrPredict(model *Model, X, Y *mat.Dense, output int) {
218218
func (m *SVR) Predict(Xmatrix mat.Matrix, Ymutable mat.Mutable) *mat.Dense {
219219
X, Y := base.ToDense(Xmatrix), base.ToDense(Ymutable)
220220
nSamples, _ := X.Dims()
221-
if Y.IsZero() {
221+
if Y.IsEmpty() {
222222
*Y = *mat.NewDense(nSamples, m.GetNOutputs(), nil)
223223
}
224224
base.Parallelize(-1, m.GetNOutputs(), func(th, start, end int) {

0 commit comments

Comments
 (0)