-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
[WIP] Tidy-up and improve ergonomics with new interface and dataset #45
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't have super much time atm, but any feedback is welcome |
NDarray has already a trait called `Data`, to avoid name collisions our `Data` is now called `Records`
* implement `Transformer` for `KernelParams` * move creation functions to `KernelParams` * use `Records` and `Float`
* make `Fit` more generic over return object * implement one-class classification for Labels = ()
The phantom type distinguishes between different kind of predictions, like boolean, probability or floating predictions
* add builder pattern to kernel methods * wrestle with type system
* split Targets into Targets and Labels * implement Fit and Predict traits for SVM regression
* create a dataset from records and targets * use kernel method as transformer * fit a model with hyperparameters and given dataset * create a second validation dataset and populate targets with predict * evaluate with confusion matrix
* remove labels array from dataset, because its elements are not enforced to be unique or ordered * introduce TargetsWithLabels, which wraps targets with additional labels * fix warnings
I've taken a short look tonight! This looks really awesome, thanks for this extensive amount of work! I'd like to spend a bit more time thinking about the names and visibility of some items. I'll write more comments tomorrow. Thanks for the work! |
Moved to #55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think the
linfa
crate has collected enough algorithms to move towards a unified interface. The intention of this PR is to tidy up the project and implement unified traits for transformers, fittable models and incremental models. Further aDataset
struct is introduced, which wraps records, targets, labels and weights in an unified way.The description is also WIP and will be updated over time
Traits for the learning process
This PR introduces traits for transformers, learnable models and incremental models. The trait implementation (see here) follows the convention:
Transformer
: a transformer is an algorithm, which does not expose its inner state. A common example are kernel methods, which are unique for every dataset given. Support Vector Machines, on the other hand, may implement this as well and callfit
andpredict
internally.Fit
: a fittable algorithm learns model from the training dataset. It can predict new targets from the same domain as the input data.IncrementalFit
: an incremental algorithm can make updates of its inner state, depending on a former model and new dataDataset
A dataset contains a records field and further may contains targets, weights and labels. The
Targets
trait corresponds to any kind of target (f32 as well as String), but theLabels
trait can be used to narrow down the implementation to comparable targets (atm implemented forbool
,usize
andString
)Tidying up the crate
Unresolved questions
ndarray
, where everything is implemented with concrete types. This creates on the one hand some boilercode (for exampleVec<T>
,&Vec<T>
and&[T]
have to be implemented separately), but I don't think that Rust is expressive enough atm to go another wayRecords
was chosen to distinguish it form theData
trait ofndarray
, but its not the most common name to describe the actual data in a datasetExample
Here is a simple example for a kernel transformation, followed by the training of a SVC model: