-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 #4198 from karlnapf/feature/factory
Feature/factory
- Loading branch information
Showing
58 changed files
with
945 additions
and
305 deletions.
There are no files selected for viewing
Submodule data
updated
4 files
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Machine lib_svm = machine("LibSVM") | ||
Machine lda = machine("LDA") | ||
Kernel kernel_gaussian = kernel("GaussianKernel") | ||
Kernel kernel_linear = kernel("LinearKernel") | ||
|
||
RealMatrix real_matrix(2,2) | ||
Features features_from_matrix = features(real_matrix) | ||
|
||
File features_file = csv_file("../../data/classifier_binary_2d_nonlinear_features_train.dat") | ||
Features features_from_file = features(features_file, enum EPrimitiveType.PT_FLOAT64) | ||
|
||
File labels_file = csv_file("../../data/classifier_binary_2d_nonlinear_labels_train.dat") | ||
Labels labels_from_file = labels(labels_file) |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
CSVFile f_feats_train("../../data/classifier_4class_2d_linear_features_train.dat") | ||
CSVFile f_feats_test("../../data/classifier_4class_2d_linear_features_test.dat") | ||
CSVFile f_labels_train("../../data/classifier_4class_2d_linear_labels_train.dat") | ||
File f_feats_train = csv_file("../../data/classifier_4class_2d_linear_features_train.dat") | ||
File f_feats_test = csv_file("../../data/classifier_4class_2d_linear_features_test.dat") | ||
File f_labels_train = csv_file("../../data/classifier_4class_2d_linear_labels_train.dat") | ||
|
||
#![create_features] | ||
RealFeatures features_train(f_feats_train) | ||
RealFeatures features_test(f_feats_test) | ||
MulticlassLabels labels_train(f_labels_train) | ||
Features features_train = features(f_feats_train) | ||
Features features_test = features(f_feats_test) | ||
Labels labels_train = labels(f_labels_train) | ||
#![create_features] | ||
|
||
|
||
#![create_instance] | ||
GaussianNaiveBayes gnb(features_train, labels_train) | ||
Machine gnb = machine("GaussianNaiveBayes", features=features_train, labels=labels_train) | ||
#![create_instance] | ||
|
||
#![train_and_apply] | ||
gnb.train() | ||
MulticlassLabels labels_predict = gnb.apply_multiclass(features_test) | ||
Labels labels_predict = gnb.apply(features_test) | ||
RealVector labels = labels_predict.get_real_vector("labels") | ||
#![train_and_apply] | ||
|
||
|
||
# integration testing variables | ||
RealVector output = labels_predict.get_labels() |
31 changes: 14 additions & 17 deletions
31
examples/meta/src/regression/support_vector_regression.sg
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,39 +1,36 @@ | ||
CSVFile f_feats_train("../../data/regression_1d_sinc_features_train.dat") | ||
CSVFile f_feats_test("../../data/regression_1d_sinc_features_test.dat") | ||
CSVFile f_labels_train("../../data/regression_1d_sinc_labels_train.dat") | ||
CSVFile f_labels_test("../../data/regression_1d_sinc_labels_test.dat") | ||
File f_feats_train=csv_file("../../data/regression_1d_sinc_features_train.dat") | ||
File f_feats_test=csv_file("../../data/regression_1d_sinc_features_test.dat") | ||
File f_labels_train=csv_file("../../data/regression_1d_sinc_labels_train.dat") | ||
File f_labels_test=csv_file("../../data/regression_1d_sinc_labels_test.dat") | ||
|
||
#![create_features] | ||
RealFeatures features_train(f_feats_train) | ||
RealFeatures features_test(f_feats_test) | ||
RegressionLabels labels_train(f_labels_train) | ||
RegressionLabels labels_test(f_labels_test) | ||
Features features_train=features(f_feats_train) | ||
Features features_test=features(f_feats_test) | ||
Labels labels_train=labels(f_labels_train) | ||
Labels labels_test=labels(f_labels_test) | ||
#![create_features] | ||
|
||
#![create_appropriate_kernel] | ||
real width = 1.0 | ||
GaussianKernel kernel(width) | ||
Kernel k=kernel("GaussianKernel", log_width=1.0) | ||
#![create_appropriate_kernel] | ||
|
||
#![create_instance] | ||
real svm_c = 1.0 | ||
real svr_param = 0.1 | ||
LibSVR svr(svm_c, svr_param, kernel, labels_train, enum LIBSVR_SOLVER_TYPE.LIBSVR_EPSILON_SVR) | ||
Machine svr=machine("LibSVR", C1=1.0, C2=1.0, tube_epsilon=0.1, kernel=k, labels=labels_train) | ||
# , solver_type=enum LIBSVR_SOLVER_TYPE.LIBSVR_EPSILON_SVR) | ||
#![create_instance] | ||
|
||
#![train_and_apply] | ||
svr.train(features_train) | ||
RegressionLabels labels_predict = svr.apply_regression(features_test) | ||
Labels labels_predict = svr.apply(features_test) | ||
RealVector output = labels_predict.get_real_vector("labels") | ||
#![train_and_apply] | ||
|
||
#![extract_alpha] | ||
RealVector alpha = svr.get_alphas() | ||
RealVector alpha = svr.get_real_vector("m_alpha") | ||
#![extract_alpha] | ||
|
||
#![evaluate_error] | ||
MeanSquaredError eval() | ||
real mse = eval.evaluate(labels_predict, labels_test) | ||
#![evaluate_error] | ||
|
||
# integration testing variables | ||
RealVector output = labels_test.get_labels() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%{ | ||
#include <shogun/util/factory.h> | ||
%} | ||
%include <shogun/util/factory.h> | ||
|
||
%template(features) shogun::features<float64_t>; |
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.