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

#3555 add meta_example for classifier_perceptron undocumented-sample #4140

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion data
35 changes: 35 additions & 0 deletions examples/meta/src/neural_nets/classification_perceptron.sg
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")
Copy link
Member

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?

Copy link
Contributor Author

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another PR* xp

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]