Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ml/model_selection/model_selection.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package modelselection

import (
"math/rand"
"math/rand/v2"
)

func TrainTestSplit(dataset []interface{}, testSize float64) (train, test []interface{}) {
Expand Down
4 changes: 2 additions & 2 deletions rand/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"crypto/rand"
"errors"
"math/big"
crand "math/rand"
crand "math/rand/v2"
)

// IntN returns a uniform random value in [0, max). It errors if max <= 0.
Expand All @@ -14,7 +14,7 @@ func IntN(max int) (int, error) {
}
nBig, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return crand.Intn(max), nil
return crand.IntN(max), nil
}
return int(nBig.Int64()), nil
}
4 changes: 2 additions & 2 deletions slice/sliceutil.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sliceutil

import (
"math/rand"
"math/rand/v2"
"strconv"
"time"

Expand Down Expand Up @@ -61,7 +61,7 @@ func DedupeFunc[T any](inputSlice []T, keyFunc func(T) any) (result []T) {

// PickRandom item from a slice of elements
func PickRandom[T any](v []T) T {
return v[rand.Intn(len(v))]
return v[rand.IntN(len(v))]
}

// Contains if a slice contains an element
Expand Down
Loading