Skip to content

Commit 5e3341f

Browse files
authored
Merge pull request #35 from alan-turing-institute/dev
For a 0.1.4 release
2 parents b303a8f + 11f13b1 commit 5e3341f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "NearestNeighborModels"
22
uuid = "636a865e-7cf4-491e-846c-de09b730eb36"
33
authors = ["Anthony D. Blaom <anthony.blaom@gmail.com>", "Sebastian Vollmer <s.vollmer.4@warwick.ac.uk>", "Thibaut Lienart <thibaut.lienart@gmail.com>", "Okon Samuel <okonsamuel50@gmail.com>"]
4-
version = "0.1.3"
4+
version = "0.1.4"
55

66
[deps]
77
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
@@ -15,8 +15,8 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1515
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1616

1717
[compat]
18-
Distances = "^0.9,^0.10"
19-
FillArrays = "^0.9"
18+
Distances = "^0.9, ^0.10"
19+
FillArrays = "^0.9, ^0.10, ^0.11 "
2020
MLJModelInterface = "^0.3.5, ^0.4"
2121
NearestNeighbors = "^0.4"
2222
StatsBase = "^0.33"

src/models.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,19 @@ end
229229

230230
function _predict_knnreg(weights, y, idxs_matrix)
231231
@inbounds labels = @view(y[idxs_matrix])
232-
preds = @view(_sum(labels .* weights, dims=2)[:]) ./ _sum(weights, dims=2)
232+
preds = @inbounds(
233+
@view(_sum(labels .* weights, dims=2)[:]) ./ @view(_sum(weights, dims=2)[:])
234+
)
233235
return preds
234236
end
237+
235238
function MMI.predict(m::KNNRegressor, fitresult, X)
236239
err_if_given_invalid_K(m.K)
237240
#Xmatrix = MMI.matrix(X, transpose=true) # NOTE: copies the data
238241
Xmatrix = transpose(MMI.matrix(X))
239242
check_onebased_indexing("prediction input", Xmatrix)
240243
predict_args = setup_predict_args(m, Xmatrix, fitresult)
241-
preds = _predict_knnreg(predict_args...) |> vec
244+
preds = _predict_knnreg(predict_args...)
242245
return preds
243246
end
244247

0 commit comments

Comments
 (0)