-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
#3555 add meta_example for classifier_perceptron undocumented-sample #4140
Merged
karlnapf
merged 2 commits into
shogun-toolbox:develop
from
spothound:feature/add_meta_example_perceptron_classification
Feb 3, 2018
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule data
updated
1 files
+18 −0 | testsuite/meta/neural_nets/classification_perceptron.dat |
35 changes: 35 additions & 0 deletions
35
examples/meta/src/neural_nets/classification_perceptron.sg
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
CSVFile f_feats_train("../../data/classifier_binary_2d_linear_features_train.dat") | ||
CSVFile f_feats_test("../../data/classifier_binary_2d_linear_features_test.dat") | ||
CSVFile f_labels_train("../../data/classifier_binary_2d_linear_labels_train.dat") | ||
CSVFile f_labels_test("../../data/classifier_binary_2d_linear_labels_test.dat") | ||
|
||
#![create_features] | ||
RealFeatures features_train(f_feats_train) | ||
RealFeatures features_test(f_feats_test) | ||
BinaryLabels labels_train(f_labels_train) | ||
BinaryLabels labels_test(f_labels_test) | ||
#![create_features] | ||
|
||
#![create_instance] | ||
real learn_rate=1.0 | ||
int max_iter=1000 | ||
Perceptron perceptron(features_train, labels_train) | ||
perceptron.set_learn_rate(learn_rate) | ||
perceptron.set_max_iter(max_iter) | ||
#![create_instance] | ||
|
||
#![train_and_apply] | ||
perceptron.train() | ||
perceptron.set_features(features_test) | ||
Labels labels_predict = perceptron.apply() | ||
#![train_and_apply] | ||
|
||
#![extract_weights] | ||
RealVector weights = perceptron.get_w() | ||
real bias = perceptron.get_bias() | ||
#![extract_weights] | ||
|
||
#![evaluate_accuracy] | ||
AccuracyMeasure eval() | ||
real accuracy = eval.evaluate(labels_predict, labels_test) | ||
#![evaluate_accuracy] |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I had overseen this.
Can you pls send another PR where you move the perceptron to the "binary" folder, it does not really follow the NN structure in Shogun. Same for the data file.
Also could you remove the python example in the same PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh ok, I thought it had to be with NN examples, I'll move it and remove the python example...
Also... I'm seeing that one check didn't pass which is weird because I just send the data file... don't know :/
Well, I'lll do that and send another commit!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another PR* xp