本文整理汇总了C#中RealFeatures.set_feature_matrix方法的典型用法代码示例。如果您正苦于以下问题:C# RealFeatures.set_feature_matrix方法的具体用法?C# RealFeatures.set_feature_matrix怎么用?C# RealFeatures.set_feature_matrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RealFeatures
的用法示例。
在下文中一共展示了RealFeatures.set_feature_matrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] argv)
{
modshogun.init_shogun_with_defaults();
double C = 0.9;
double epsilon = 1e-3;
org.shogun.Math.init_random(17);
DoubleMatrix traindata_real = Load.load_numbers(".../data/fm_train_real.dat");
DoubleMatrix testdata_real = Load.load_numbers("../data/toy/fm_test_real.dat");
DoubleMatrix trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
Labels labels = new Labels(trainlab);
LibLinear svm = new LibLinear(C, feats_train, labels);
svm.set_liblinear_solver_type(L2R_L2LOSS_SVC_DUAL);
svm.set_epsilon(epsilon);
svm.set_bias_enabled(true);
svm.train();
svm.set_features(feats_test);
DoubleMatrix out_labels = svm.apply().get_labels();
Console.WriteLine(out_labels.ToString());
modshogun.exit_shogun();
}
示例2: Main
public static void Main()
{
modshogun.init_shogun_with_defaults();
double learn_rate = 1.0;
int max_iter = 1000;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
// already tried double[][]
double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
Labels labels = new Labels(trainlab);
Perceptron perceptron = new Perceptron(feats_train, labels);
perceptron.set_learn_rate(learn_rate);
perceptron.set_max_iter(max_iter);
perceptron.train();
perceptron.set_features(feats_test);
// already tried double[][]
double[] out_labels = perceptron.apply().get_labels();
foreach (double item in out_labels)
Console.Write(item);
modshogun.exit_shogun();
}
示例3: run
public virtual Serializable run(IList para)
{
modshogun.init_shogun_with_defaults();
double learn_rate = (double)((double?)para[0]);
int max_iter = (int)((int?)para[1]);
DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");
DoubleMatrix trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
Labels labels = new Labels(trainlab);
AveragedPerceptron perceptron = new AveragedPerceptron(feats_train, labels);
perceptron.set_learn_rate(learn_rate);
perceptron.set_max_iter(max_iter);
perceptron.train();
perceptron.set_features(feats_test);
DoubleMatrix out_labels = perceptron.apply().get_labels();
ArrayList result = new ArrayList();
result.Add(perceptron);
result.Add(out_labels);
modshogun.exit_shogun();
return result;
}
示例4: Main
public static void Main() {
modshogun.init_shogun_with_defaults();
double width = 2.1;
double epsilon = 1e-5;
double C = 1.0;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
// already tried double[,]
double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
BinaryLabels labels = new BinaryLabels(trainlab);
MPDSVM svm = new MPDSVM(C, kernel, labels);
svm.set_epsilon(epsilon);
svm.train();
kernel.init(feats_train, feats_test);
// already tried double[,]
double[] out_labels = LabelsFactory.to_binary(svm.apply()).get_labels();
foreach (double item in out_labels)
Console.Write(item);
}
示例5: Main
static void Main(string[] argv)
{
modshogun.init_shogun_with_defaults();
double width = 2.1;
double epsilon = 1e-5;
double C = 1.0;
DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
LibSVMOneClass svm = new LibSVMOneClass(C, kernel);
svm.set_epsilon(epsilon);
svm.train();
kernel.init(feats_train, feats_test);
DoubleMatrix out_labels = svm.apply().get_labels();
Console.WriteLine(out_labels.ToString());
modshogun.exit_shogun();
}
示例6: Main
public static void Main() {
modshogun.init_shogun_with_defaults();
double width = 2.1;
double epsilon = 1e-5;
double C = 1.0;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
double[] trainlab = Load.load_labels("../data/label_train_multiclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
MulticlassLabels labels = new MulticlassLabels(trainlab);
LaRank svm = new LaRank(C, kernel, labels);
svm.set_batch_mode(false);
svm.set_epsilon(epsilon);
svm.train();
double[] out_labels = LabelsFactory.to_multiclass(svm.apply(feats_train)).get_labels();
foreach(double item in out_labels) {
Console.Write(item);
}
}
示例7: Main
static void Main(string[] argv)
{
modshogun.init_shogun_with_defaults();
double learn_rate = 1.0;
int max_iter = 1000;
DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");
DoubleMatrix trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
Labels labels = new Labels(trainlab);
Perceptron perceptron = new Perceptron(feats_train, labels);
perceptron.set_learn_rate(learn_rate);
perceptron.set_max_iter(max_iter);
perceptron.train();
perceptron.set_features(feats_test);
DoubleMatrix out_labels = perceptron.apply().get_labels();
Console.WriteLine(out_labels.ToString());
modshogun.exit_shogun();
}
示例8: Main
public static void Main()
{
modshogun.init_shogun_with_defaults();
double width = 2.1;
double epsilon = 1e-5;
double C = 1.0;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
double[] trainlab = Load.load_labels("../data/label_train_multiclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
MulticlassLabels labels = new MulticlassLabels(trainlab);
MulticlassLibSVM svm = new MulticlassLibSVM(C, kernel, labels);
svm.set_epsilon(epsilon);
svm.train();
kernel.init(feats_train, feats_test);
double[] out_labels = MulticlassLabels.obtain_from_generic(svm.apply()).get_labels();
foreach (double item in out_labels)
Console.Write(item);
modshogun.exit_shogun();
}
示例9: Main
public static void Main()
{
modshogun.init_shogun_with_defaults();
double C = 0.9;
double epsilon = 1e-3;
Math.init_random(17);
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
BinaryLabels labels = new BinaryLabels(trainlab);
LibLinear svm = new LibLinear(C, feats_train, labels);
svm.set_liblinear_solver_type(LIBLINEAR_SOLVER_TYPE.L2R_L2LOSS_SVC_DUAL);
svm.set_epsilon(epsilon);
svm.set_bias_enabled(true);
svm.train();
svm.set_features(feats_test);
double[] out_labels = BinaryLabels.obtain_from_generic(svm.apply()).get_labels();
foreach(double item in out_labels) {
Console.Write(item);
}
modshogun.exit_shogun();
}
示例10: Main
public static void Main() {
modshogun.init_shogun_with_defaults();
int gamma = 3;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
BinaryLabels labels = new BinaryLabels(trainlab);
LDA lda = new LDA(gamma, feats_train, labels);
lda.train();
Console.WriteLine(lda.get_bias());
//Console.WriteLine(lda.get_w().toString());
foreach(double item in lda.get_w()) {
Console.Write(item);
}
lda.set_features(feats_test);
double[] out_labels = LabelsFactory.to_binary(lda.apply()).get_labels();
foreach(double item in out_labels) {
Console.Write(item);
}
}
示例11: Main
static void Main(string[] argv)
{
modshogun.init_shogun_with_defaults();
double width = 2.1;
double epsilon = 1e-5;
double C = 1.0;
DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");
DoubleMatrix trainlab = Load.load_labels("../data/label_train_multiclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
Labels labels = new Labels(trainlab);
LaRank svm = new LaRank(C, kernel, labels);
svm.set_batch_mode(false);
svm.set_epsilon(epsilon);
svm.train();
DoubleMatrix out_labels = svm.apply(feats_train).get_labels();
Console.WriteLine(out_labels.ToString());
modshogun.exit_shogun();
}
示例12: Main
public static void Main() {
modshogun.init_shogun_with_defaults();
double width = 2.1;
double epsilon = 1e-5;
double C = 1.0;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
GaussianKernel kernel = new GaussianKernel(feats_train, feats_train, width);
LibSVMOneClass svm = new LibSVMOneClass(C, kernel);
svm.set_epsilon(epsilon);
svm.train();
kernel.init(feats_train, feats_test);
double[] out_labels = svm.apply().get_labels();
foreach (double item in out_labels)
Console.Write(item);
modshogun.exit_shogun();
}
示例13: Main
public static void Main()
{
modshogun.init_shogun_with_defaults();
double learn_rate = 1.0;
int max_iter = 1000;
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
double[] trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
BinaryLabels labels = new BinaryLabels(trainlab);
AveragedPerceptron perceptron = new AveragedPerceptron(feats_train, labels);
perceptron.set_learn_rate(learn_rate);
perceptron.set_max_iter(max_iter);
perceptron.train();
perceptron.set_features(feats_test);
double[] out_labels = BinaryLabels.obtain_from_generic(perceptron.apply()).get_labels();
foreach(double item in out_labels) {
Console.Write(item);
}
modshogun.exit_shogun();
}
示例14: Main
static void Main(string[] argv)
{
modshogun.init_shogun_with_defaults();
int gamma = 3;
DoubleMatrix traindata_real = Load.load_numbers("../data/fm_train_real.dat");
DoubleMatrix testdata_real = Load.load_numbers("../data/fm_test_real.dat");
DoubleMatrix trainlab = Load.load_labels("../data/label_train_twoclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
Labels labels = new Labels(trainlab);
LDA lda = new LDA(gamma, feats_train, labels);
lda.train();
Console.WriteLine(lda.get_bias());
Console.WriteLine(lda.get_w().ToString());
lda.set_features(feats_test);
DoubleMatrix out_labels = lda.apply().get_labels();
Console.WriteLine(out_labels.ToString());
modshogun.exit_shogun();
}
示例15: Main
public static void Main()
{
modshogun.init_shogun_with_defaults();
double[,] traindata_real = Load.load_numbers("../data/fm_train_real.dat");
double[,] testdata_real = Load.load_numbers("../data/fm_test_real.dat");
double[] trainlab = Load.load_labels("../data/label_train_multiclass.dat");
RealFeatures feats_train = new RealFeatures();
feats_train.set_feature_matrix(traindata_real);
RealFeatures feats_test = new RealFeatures();
feats_test.set_feature_matrix(testdata_real);
Labels labels = new Labels(trainlab);
GaussianNaiveBayes gnb = new GaussianNaiveBayes(feats_train, labels);
gnb.train();
double[] out_labels = gnb.apply(feats_test).get_labels();
foreach(double item in out_labels) {
Console.Write(item);
}
modshogun.exit_shogun();
}