-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Currently we expose SVM to interfaces, but this is somewhat redundant as we expose Machine (and SVM is a Machine derived class). This was just a hack to make sure that only SVM types can be passed with put to objects expecting an SVM parameter. But now we can test at runtime if the object being put can be casted to the expected type:
shogun/src/shogun/kernel/string/HistogramWordStringKernel.cpp
Lines 428 to 429 in f143eaf
| SG_ADD((std::shared_ptr<Machine>*)&estimate, "estimate", "Plugin Estimate.", ParameterProperties::CONSTRAIN, | |
| SG_CONSTRAINT(castable<PluginEstimate>())); |
So all Machine which expect an SVM parameter (e.g. MKLClassification) should have this castable check and register the svm parameter as a Machine. This will avoid having to cast machine to svm when passing it to things like MKLClassifcation:
shogun/examples/undocumented/python/evaluation_cross_validation_mkl_weight_storage.py
Lines 41 to 42 in f143eaf
| svm = sg.create_machine("MKLClassification", svm=sg.as_svm(libsvm), | |
| interleaved_optimization=False, kernel=kernel) |
@karlnapf the only issue will be how does the user have access to compute_svm_primal_objective and compute_svm_dual_objective? Maybe SVM shouldn't be removed from swig, but classes like MKL should register SVM as Machine? That way we avoid having to cast the Machine object when it is just passed as an argument in put?