Skip to content

Commit

Permalink
improve kNearestNeighbour imputation speed
Browse files Browse the repository at this point in the history
add spline reference
  • Loading branch information
bvenn committed Feb 13, 2020
1 parent 2c45f0a commit 4380084
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/FSharp.Stats/Fitting/Spline.fs
Expand Up @@ -23,7 +23,7 @@ module Spline =
if l < 0. then failwith "smoothing parameter should be positive"
/// Creates a smoothing spline through some data. Takes as spline points the x-values given by basispts
let smoothingSpline (data: (float*float) []) (basispts : float [])=

//https://robjhyndman.com/etc5410/splines.pdf
// Some preprocessing
let xdata,ydata = data |> preprocess |> Array.unzip
let ydata = vector ydata
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Stats/ML/Impute.fs
Expand Up @@ -73,9 +73,9 @@ module Impute =
|> Array.sortBy fst
|> Array.take k

let euclNan = DistanceMetrics.euclidean
let euclNanSq = DistanceMetrics.euclideanNaNSquared
let tmpArr =
kNearestFrom euclNan k (data |> Array.ofSeq) arr
kNearestFrom euclNanSq k (data |> Array.ofSeq) arr
|> Array.map snd
|> JaggedArray.transpose
|> Array.map Seq.mean
Expand Down

0 comments on commit 4380084

Please sign in to comment.