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

Add ability to define custom getter/setter methods for model data #8

Open
andreekeberg opened this issue Nov 26, 2021 · 0 comments
Open
Assignees
Labels
🥳 enhancement New feature or request ⚡️ performance Performance related issues or possible enhancements

Comments

@andreekeberg
Copy link
Owner

andreekeberg commented Nov 26, 2021

Add support for for passing custom methods to Classifier and Model for defining custom getter/setter methods that allows us to bypass the data object literal that is currently stored directly as a property in Model instances.

For example:

const { createClient } = require('redis')
const client = createClient()

const classifier = new Classifier({
    getData: async (label) => {
        return await client.get(label || '*')
    },
    setData: async (label, data) => {
        return await client.set(label, data)
    }
})

There will be default getData and setData methods which work like in the current version (but still with some performance improvements like being asynchronous by default and where we optimize the way the data object is stored in memory).

From there we can update the train and predict methods in Classifier to call those, instead of the current behaviour of directly accessing this._model.data.

When using the library in this way, the data that still remains in Model (and is accessible via the serialize method) simply serves as general model meta data, and one would need to use the same custom data store every time the model is used later on.

It should also be noted this needs to wait until the upcoming version where all methods have been rewritten to be asynchronous by default is has been released.

@andreekeberg andreekeberg added 🥳 enhancement New feature or request ⚡️ performance Performance related issues or possible enhancements labels Nov 26, 2021
@andreekeberg andreekeberg changed the title Add ability to define custom data read/write methods for models Add ability to define custom getter/setter methods for model data Nov 29, 2021
@andreekeberg andreekeberg self-assigned this Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🥳 enhancement New feature or request ⚡️ performance Performance related issues or possible enhancements
Projects
None yet
Development

No branches or pull requests

1 participant