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

Muilti output regression #25

Closed
Shay-Yo opened this issue Feb 13, 2024 · 1 comment
Closed

Muilti output regression #25

Shay-Yo opened this issue Feb 13, 2024 · 1 comment

Comments

@Shay-Yo
Copy link

Shay-Yo commented Feb 13, 2024

Hello,
I am currently working on a regression task containing multiple label dimensions.
I saw that your code has an implemantation on the regression task, but only for y_dim=1 and not for multiple dimensions (y_dim=n where n>1).

I tried running my regression task by changing the y_dim variable and running the code but it does not work (apparently there is a mix up with the dimension, and I am not sure where is the right place to change the code).
I wanted to ask if there is a simple way to run the model for a regression task with several out dimensions?

Thank you

@Shay-Yo
Copy link
Author

Shay-Yo commented Feb 28, 2024

I believe I solved this issue. For anyone who is experiencing the same problem.
The main problem is with the shapes so you need to do several small changes to make it work.

First go to the script train.py and change the y_dim variable from 1 to the number of classes you have (notice that if the task is set to regression the code will force y_dim to be 1, you need to change it).

Second go to the data_openml.py and change the line:

'data': y[indices].reshape(-1, 1)

in the function data_split to

'data': y[indices].reshape(-1, y_dim)

where y_dim is the number of classes you have.

Third in the data_openml.py script in the __init__ method of the DataSetCatCon class you need to change the lines:

self.cls = np.zeros_like(self.y,dtype=int)
self.cls_mask = np.ones_like(self.y,dtype=int)

to

self.cls = np.zeros(shape=(len(self.y), 1), dtype=int)
self.cls_mask = np.ones(shape=(len(self.y), 1), dtype=int)

This was because we change the shape of y and we are adding a cls token column to the features, so those two lines need to create a cls token column in the length of the number of data points, but if we leave them as they are we will not get a column but a matrix with the size of the number of data points to the number of classes.

Notice that if you just change the numbers it might create a problem later if you wish to train the model on other tasks or different class numbers so you might need to change it back if you want to train the model on different tasks.

@Shay-Yo Shay-Yo closed this as completed Feb 28, 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

1 participant