Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use column names instead of indices #282

Closed
tiemvanderdeure opened this issue Nov 1, 2024 · 3 comments
Closed

use column names instead of indices #282

tiemvanderdeure opened this issue Nov 1, 2024 · 3 comments

Comments

@tiemvanderdeure
Copy link
Contributor

This package currently uses indices throughout, which can lead to unexpected errors and confusing results. I think we should switch to use keys instead.

For instance

N = 1000
X = (x1 = rand(Float32, N), x2 = randn(Float32, N), x3 = categorical(rand('a':'c', N)))
y = categorical(bitrand(N))

model = MLJFlux.NeuralNetworkBinaryClassifier(epochs = 10, builder=MLJFlux.MLP(; hidden=(5,4)), batch_size = 100)
mach = machine(model, X, y)
fit!(mach)

# this errors
predict(mach, (x3 = X.x3, x1 = X.x1, x2 = X.x2))

# this is false!
all(predict(mach, (x2 = X.x2, x1 = X.x1, x3 = X.x3)) .≈ predict(mach, X))
@ablaom
Copy link
Collaborator

ablaom commented Nov 3, 2024

Mmm. I think this kind of implicit assumption - that the columns of tables are ordered, and that they be presented in a consistent order, is everywhere in MLJ, and probably elsewhere. [Transferring this issue to MLJ].

One could either try to allow tables to be presented in any column order, or throw a warning when the original order is violated. Personally, I think the latter would be sufficient. If MLJ had a generic data-front end for dealing with tables, apart from Tables.matrix which dumps the feature names, this could be an easy fix either way. But a lot of interfaces just don't save the feature names.

I'd support some kind of resolution, but it's a big ask to fix everywhere.

Thanks @tiemvanderdeure for flagging this issue.

@ablaom
Copy link
Collaborator

ablaom commented Nov 3, 2024

[Transferring this issue to MLJ].

Okay, can't do that in the usual way, this is a different org. Will create a new issue at MLJ and close here.

@ablaom
Copy link
Collaborator

ablaom commented Nov 3, 2024

Closing in favor of JuliaAI/MLJ.jl#1144

@ablaom ablaom closed this as completed Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants