Created
August 25, 2015 11:27
-
-
Save lisitsyn/eeef976ba270da456e3f to your computer and use it in GitHub Desktop.
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
# Tag public | |
template <typename T> | |
class Tag | |
{ | |
public: | |
// registers tag in object | |
Tag(SGObject* object, const char* name); | |
}; | |
# public | |
class SVM : public SGObject | |
{ | |
public: | |
void train(); | |
Tag<int> max_iterations; | |
}; | |
# private | |
SVM::SVM() : max_iterations(this, "max_iterations") | |
{ | |
} | |
void SVM::train() | |
{ | |
for (auto i : xrange(get(max_iterations))) | |
{ | |
... do shit | |
} | |
} | |
# python code | |
svm = SVM() | |
svm.set(svm.max_iterations, 100) | |
assert svm.get(svm.max_iterations) is 100 | |
# java code | |
SVM svm = new SVM(); | |
svm.set(svm.max_iterations, 100); | |
int max_iterations = svm.get(svm.max_iterations); | |
# java with plugins | |
Machine svm = shogun.load_machine("libsvm"); | |
IntTag max_iterations = shogun.int_tag("max_iterations"); | |
svm.set(max_iterations, 100); | |
int actual_max_iterations = svm.get(max_iterations); | |
// i don't care about type | |
Parameter max_iterations_generic = svm.get("max_iterations"); | |
System.out.println("Using max iterations: " + max_iterations_generic + "\n"); | |
# model selection | |
svm.select() | |
.parameter(max_iterations, shogun.range(1, 200, 50)) | |
.parameter(threshold, shogun.exponential_range(0.1, 0.2, 0.5)) | |
.over(shogun.StratifiedSplit(data)) | |
.with(shogun.ROCEvaluation()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment