MLJ KNNRegressor BruteTree broken for predict-- load error brutetree has no field indices...?

Using MLJ’s NearestNeighbors KNNRegressor and attempted to use BruteTree algorithm. Get the following error when attempting to use predict: ERROR: LoadError: type BruteTree has no field indices followed by usual stack trace.

Simple code showcasing the problem (same code example works fine for kdtree or balltree):

using DataFrames
using MLJ

X_rand = rand(50,3)
coef = [1; 0; 1]
y_rand = X_rand*coef + rand(50,1)

#convert to dataframe for MLJ inputs
X_rand_df = DataFrames.DataFrame(X_rand, :auto)
y_rand_df = DataFrames.DataFrame(y_rand, :auto)

train_idx, test_idx = partition(eachindex(y_rand_df[:,1]), 0.7, shuffle=true)

Tree = @load KNNRegressor
tree =Tree(algorithm=:brutetree)

mach = machine(tree,  X_rand_df[train_idx, :], y_rand_df[train_idx, 1])

MLJ.fit!(mach)

MLJ.predict(mach, X_rand_df[test_idx,:])

I can provide the error stack I’m seeing if desired.

1 Like

@diadora77 Sorry, its due to a bug. This will get fixed soon.

@diadora77 Thanks for reporting! Issue tracked here.

Excellent! Thanks for taking a look!

@samuel_okon Thanks for the fix!

1 Like