Code Monkey home page Code Monkey logo

Comments (3)

joshfp avatar joshfp commented on August 29, 2024

On the one hand, I think it is a nice feature to provide reasonable default values for each field type, for the following reasons:

  • When using the library, it is a common scenario to instantiate these classes many times (once for each feature), requiring to specifying these parameters several times (and probably with the same values). Providing default values avoids that need, making the code less verbose and more clear.
  • It makes the library very friendly to beginner users, who won't need to worry about many settings.

On the other hand, I fully agree with you that the UX is confusing and can be improved.
Probably, one of the reasons of such confusing behavior is the overuse of a single parameter to do many things. What if it uses two separate parameters instead? Following your example with "scaler"...

  • scaler: the scaler strategy to be used.
    • 'standard_scaler' (default): uses StandardScaler with default arguments.
    • 'custom': uses the scaler transform provided in custom_scaler parameter.
    • None (False, 0): uses no scaler.
  • custom_scaler: when scaler=='custom', this parameter specify the scaler transform to be used.

It is a similar to the pattern followed by sklearn, for instance in SimpleImputer (strategy/fill_value parameters)

Does it make sense to you?

from pytorch-onfire.

jmansilla avatar jmansilla commented on August 29, 2024

I like your idea, enables the simplicity of use together with the flexibility for power users.
And I really like that matches the pattern of some pieces of sklearn.

But... it feels a bit of too-much-paperwork filling 2 params for single purpose.
Re-reading my initial comment I realize that what it hurts the most, is the issue with None interpreted as "standard_scaler".

Maybe an option in the middle is a good choice as well.

Signature:

class ContinuousFeature(BaseFeature):
    def __init__(self, key=None, preprocessor=None, imputer=None, scaler='standard_scaler', log=False,
                 log_auto_scale=True):
    ...

and then:

  • scaler:
    • 'standard_scaler' (default): uses StandardScaler with default arguments.
    • None (False, 0): uses no scaler.
    • <custom-scaler-object>: user defined scaler transformer to be used.

from pytorch-onfire.

juancgvazquez avatar juancgvazquez commented on August 29, 2024

I'm sorry for reviving this issue... but we have been using this and I thought that maybe it would make sense to do it like this, from a user perspective:

image

Thus, it would be something like:

class ContinuousFeature(BaseFeature):
def init(self, key=None, preprocessor=None, imputer=None, scaler=StandardScaler(), log=False,
log_auto_scale=True):
...

and then:

  • default is StandardScaler()
  • None would be no scaler
  • Pass other scaler object, uses the custom scaler.

and, therefore:

  • self.scaler = scaler

which is much more readable, in my opinion.

from pytorch-onfire.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.