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

Normalization of parameters and snapshots #251

Open
flabowski opened this issue Aug 14, 2024 · 1 comment
Open

Normalization of parameters and snapshots #251

flabowski opened this issue Aug 14, 2024 · 1 comment

Comments

@flabowski
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I would like to normalize / scale my snapshots and or the parameters using ezyrb.

Describe the solution you'd like

import numpy as np
from ezyrb import Database


points = np.array([[1,  2],
                   [5,  6],
                   [9, 10]])
values = np.array([[0.0, 0.1, 0.2],
                   [0.3, 0.4, 0.5],
                   [0.6, 0.7, 0.8]])

db_train = Database(points, values)
db_train.normalise_parameters()
print(db_train.parameters_n)
# [[0.   0.  ]
#  [0.5  0.5 ]
#  [1.   1.  ]]

db_test = Database(np.array([[2.5, 2.5]]),
                   np.array([[0.3, 0.3, 0.3]]))

db_test.scaler_parameters = db_train.scaler_parameters
db_test.scale_down_parameters()
print(db_test.parameters_n)
# [[0.1875 0.0625]]

Describe alternatives you've considered
I have looked into the optional keyword arguments scaler_parameters and scaler_snapshots, they are used by calling their method fit_transform. I did not find any definition of fit_transform or how the scalers are supposed to be used.

I am happy to contribute if you think that fits in your library and is not already possible in some other way.

@flabowski
Copy link
Contributor Author

I figured out that this must be for the StandardScaler from scikit-learn. I think this could be better documented.

  • In the database class documentation, the scaler_parameters and scaler_snapshots should be removed, since they are no longer used.
    (In older versions, fit_transform was called every time parameters or snapshots were referenced, meaning the scaler may change which can lead to unexpected behaviour...)
  • In the DatabaseScaler class, the StandardScaler should probably be referenced. It would be great to have an example how to use this plugin.

I wondered if the scalers (scaler_parameters and scaler_snapshots) from the database should be removed elsewhere (e.g. in the ROM) as well? I think it was a good idea to separate the scaling from the ROM.
Is database.parameters (and .snapshots) considered to be deprecated now in favour for database.parameters_matrix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant