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

Correct the samples formatting to get a good SVR #344

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

LouisAUTHIE
Copy link
Contributor

Just like the doc says :

In a document classification problem, say a spam checker, each line would represent a document. There would be two classes, -1 for spam, 1 for ham. Each feature would represent some word, and the value would represent that importance of that word to the document (perhaps the frequency count, with the total scaled to unit length). Features that were 0 (e.g. the word did not appear in the document at all) would simply not be included.

In array mode, the data must be passed as an array of arrays. Each sub-array must have the class as the first element, then key => value sets for the feature values pairs.

This data is passed to the SVM class's train function, which will return an SVM model is successful.

Once a model has been generated, it can be used to make predictions about previously unseen data. This can be passed as an array to the model's predict function, in the same format as before, but without the label. The response will be the class.

Models can be saved and restored as required, using the save and load functions, which both take a file location.

Example #1 Train from array

0.43, 3 => 0.12, 9284 => 0.2), array(1, 1 => 0.22, 5 => 0.01, 94 => 0.11), ); $svm = new SVM(); $model = $svm->train($data); $data = array(1 => 0.43, 3 => 0.12, 9284 => 0.2); $result = $model->predict($data); var_dump($result); $model->save('model.svm'); ?>

Copy link
Contributor

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@LouisAUTHIE
Copy link
Contributor Author

ping @andrewdalpino

@andrewdalpino andrewdalpino merged commit c1bede9 into RubixML:master Aug 30, 2024
0 of 13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants