Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1089 from iglesias/feature/hmsvm_plifs
Support for continuous features with the HM-SVM using PLiFs
- Loading branch information
Showing
31 changed files
with
617 additions
and
110 deletions.
There are no files selected for viewing
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
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
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
25 changes: 25 additions & 0 deletions
25
examples/undocumented/python_modular/structure_plif_hmsvm_bmrm.py
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,25 @@ | ||
#!/usr/bin/env python | ||
|
||
parameter_list=[[100, 250, 10, 2]] | ||
|
||
def structure_plif_hmsvm_bmrm (num_examples, example_length, num_features, num_noise_features): | ||
from shogun.Features import RealMatrixFeatures | ||
from shogun.Loss import HingeLoss | ||
from shogun.Structure import TwoStateModel, DualLibQPBMSOSVM | ||
from shogun.Evaluation import StructuredAccuracy | ||
|
||
model = TwoStateModel.simulate_data(num_examples, example_length, num_features, num_noise_features) | ||
loss = HingeLoss() | ||
sosvm = DualLibQPBMSOSVM(model, loss, model.get_labels(), 5000.0) | ||
|
||
sosvm.train() | ||
#print sosvm.get_w() | ||
|
||
predicted = sosvm.apply(model.get_features()) | ||
evaluator = StructuredAccuracy() | ||
acc = evaluator.evaluate(predicted, model.get_labels()) | ||
#print('Accuracy = %.4f' % acc) | ||
|
||
if __name__ == '__main__': | ||
print("PLiF HMSVM BMRM") | ||
structure_plif_hmsvm_bmrm(*parameter_list[0]) |
31 changes: 31 additions & 0 deletions
31
examples/undocumented/python_modular/structure_plif_hmsvm_mosek.py
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,31 @@ | ||
#!/usr/bin/env python | ||
|
||
parameter_list=[[100, 250, 10, 2]] | ||
|
||
def structure_plif_hmsvm_mosek (num_examples, example_length, num_features, num_noise_features): | ||
from shogun.Features import RealMatrixFeatures | ||
from shogun.Loss import HingeLoss | ||
from shogun.Structure import TwoStateModel | ||
from shogun.Evaluation import StructuredAccuracy | ||
|
||
try: | ||
from shogun.Structure import PrimalMosekSOSVM | ||
except ImportError: | ||
print("Mosek not available") | ||
return | ||
|
||
model = TwoStateModel.simulate_data(num_examples, example_length, num_features, num_noise_features) | ||
loss = HingeLoss() | ||
sosvm = PrimalMosekSOSVM(model, loss, model.get_labels()) | ||
|
||
sosvm.train() | ||
#print(sosvm.get_w()) | ||
|
||
predicted = sosvm.apply(model.get_features()) | ||
evaluator = StructuredAccuracy() | ||
acc = evaluator.evaluate(predicted, model.get_labels()) | ||
#print('Accuracy = %.4f' % acc) | ||
|
||
if __name__ == '__main__': | ||
print("PLiF HMSVM Mosek") | ||
structure_plif_hmsvm_mosek(*parameter_list[0]) |
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
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.