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 #304 from serialhex/master
a few additions to the ruby examples & some other stuff...
- Loading branch information
Showing
144 changed files
with
2,340 additions
and
1,206 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'modshogun'; | ||
require 'modshogun' | ||
require 'narray' | ||
require 'pp'; | ||
x = Modshogun::RealFeatures.new; | ||
y = [[1, 2], [3, 4], [5, 6]]; | ||
x.set_feature_matrix(y); | ||
z = x.get_feature_matrix(); | ||
require 'pp' | ||
x = Modshogun::RealFeatures.new | ||
y = [[1, 2], [3, 4], [5, 6]] | ||
x.set_feature_matrix(y) | ||
z = x.get_feature_matrix() | ||
pp(z) |
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
26 changes: 15 additions & 11 deletions
26
examples/undocumented/ruby_modular/classifier_custom_kernel_modular.rb
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 |
---|---|---|
@@ -1,32 +1,36 @@ | ||
# this was trancekoded by the awesome trancekoder | ||
require 'narray' | ||
# ...and fixifikated by the awesum fixifikator | ||
require 'modshogun' | ||
require 'load' | ||
require 'pp' | ||
parameter_list = [[1,7],[2,8]] | ||
|
||
def classifier_custom_kernel_modular(C=1,dim=7) | ||
parameter_list = [[1,7],[2,8]] | ||
|
||
def classifier_custom_kernel_modular(c=1,dim=7) | ||
|
||
seed((C,dim)) | ||
seed(c,dim) | ||
|
||
lab=sign(2*rand(dim) - 1) | ||
data=rand(dim, dim) | ||
symdata=data*data.T + diag(ones(dim)) | ||
|
||
kernel=CustomKernel() | ||
# *** kernel=CustomKernel() | ||
kernel=Modshogun::CustomKernel.new | ||
kernel.set_features() | ||
kernel.set_full_kernel_matrix_from_full(data) | ||
labels=Labels(lab) | ||
svm=LibSVM(C, kernel, labels) | ||
# *** labels=Labels(lab) | ||
labels=Modshogun::Labels.new | ||
labels.set_features(lab) | ||
# *** svm=LibSVM(c, kernel, labels) | ||
svm=Modshogun::LibSVM.new | ||
svm.set_features(c, kernel, labels) | ||
svm.train() | ||
predictions =svm.apply() | ||
out=svm.apply().get_labels() | ||
return svm,out | ||
|
||
|
||
end | ||
|
||
if __FILE__ == $0 | ||
print 'custom_kernel' | ||
puts 'custom_kernel' | ||
classifier_custom_kernel_modular(*parameter_list[0]) | ||
|
||
end |
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.