Skip to content

Commit

Permalink
Some java examples fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Aug 26, 2011
1 parent 63b5aec commit 9c4972b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
Expand Up @@ -13,8 +13,8 @@ public static void main(String argv[]) {
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 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");

Expand Down
Expand Up @@ -10,17 +10,11 @@ public class distribution_histogram_modular {
System.loadLibrary("modshogun");
}

public ArrayList parameter_list = new ArrayList(2);
public distribution_histogram_modular() {

parameter_list.add(Arrays.asList(new Integer(3), new Integer(0)));
parameter_list.add(Arrays.asList(new Integer(4), new Integer(0)));
}
static ArrayList run(List para) {
public static void main(String argv[]) {
boolean reverse = false;
modshogun.init_shogun_with_defaults();
int order = ((Integer)para.get(0)).intValue();
int gap = ((Integer)para.get(1)).intValue();
int order = 3;
int gap = 4;

String[] fm_train_dna = Load.load_dna("../data/fm_train_dna.dat");

Expand All @@ -31,23 +25,15 @@ static ArrayList run(List para) {
Histogram histo = new Histogram(feats);
histo.train();

histo.get_histogram();
DoubleMatrix histogram = histo.get_histogram();

int num_examples = feats.get_num_vectors();
int num_param = histo.get_num_model_parameters();
System.out.println(histogram);
//int num_examples = feats.get_num_vectors();
//int num_param = histo.get_num_model_parameters();

DoubleMatrix out_likelihood = histo.get_log_likelihood();
double out_sample = histo.get_log_likelihood_sample();
//DoubleMatrix out_likelihood = histo.get_log_likelihood();
//double out_sample = histo.get_log_likelihood_sample();

ArrayList result = new ArrayList();
result.add(histo);
result.add(out_sample);
result.add(out_likelihood);
modshogun.exit_shogun();
return result;
}
public static void main(String argv[]) {
distribution_histogram_modular x = new distribution_histogram_modular();
run((List)x.parameter_list.get(0));
}
}
Expand Up @@ -15,7 +15,7 @@ public static void main(String[] argv) {
ArrayList<DoubleMatrix> result = new ArrayList<DoubleMatrix>(4);

DoubleMatrix inputRealMatrix = Load.load_numbers("../data/fm_train_real.dat");
RealFeatures realFeatures = new RealFeatures(inputRealMatrix);
RealFeatures realFeatures = new RealFeatures(inputRealMatrix);
DoubleMatrix outputRealMatrix = realFeatures.get_feature_matrix();

result.add(inputRealMatrix);
Expand All @@ -28,13 +28,6 @@ public static void main(String[] argv) {
result.add(inputByteMatrix);
result.add(outputByteMatrix);

DoubleMatrix inputLongMatrix = Load.load_numbers("../data/fm_train_byte.dat");
LongFeatures byteFeatures = new LongFeatures(inputLongMatrix);
DoubleMatrix outputLongMatrix = longFeatures.get_feature_matrix();

result.add(inputByteMatrix);
result.add(outputByteMatrix);

System.out.println(result);

modshogun.exit_shogun();
Expand Down

0 comments on commit 9c4972b

Please sign in to comment.