Closed rn1hd closed 4 years ago
Good day! Suppose I have this code
package main import ( "fmt" "github.com/pa-m/sklearn/neighbors" "gonum.org/v1/gonum/mat" ) func main() { X := mat.NewDense(5, 4, []float64{0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1}) nbrs := neighbors.NewNearestNeighbors() nbrs.Fit(X, mat.Matrix(nil)) distances, indices := nbrs.KNeighbors(X, 5) fmt.Println(distances) fmt.Println() fmt.Println(indices) }
The result gives me this
&{{5 5 [0 1 1 1.4142135623730951 2 0 1.4142135623730951 1.7320508075688772 1.7320508075688772 2 0 1 1 1.4142135623730951 1.7320508075688772 0 1 1.4142135623730951 1.7320508075688772 1.7320508075688772 0 1 1.4142135623730951 1.4142135623730951 1.7320508075688772] 5} 5 5} &{{5 5 [0 2 3 4 1 1 4 2 3 0 2 0 4 3 1 3 0 2 1 4 4 2 0 1 3] 5} 5 5}
I'm expecting the result to be like this
[0 1 1 1.4142135623730951 2 0 1.4142135623730951 1.7320508075688772 1.7320508075688772 2 0 1 1 1.4142135623730951 1.7320508075688772 0 1 1.4142135623730951 1.7320508075688772 1.7320508075688772 0 1 1.4142135623730951 1.4142135623730951 1.7320508075688772] [0 2 3 4 1 1 4 2 3 0 2 0 4 3 1 3 0 2 1 4 4 2 0 1 3]
How can I get the array value from those results as a []float64? I'll appreciate the help.
============================ Update: I already solved my problem.
Good day! Suppose I have this code
The result gives me this
I'm expecting the result to be like this
How can I get the array value from those results as a []float64? I'll appreciate the help.
============================ Update: I already solved my problem.