Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <shogun/labels/BinaryLabels.h>
- #include <shogun/features/DenseFeatures.h>
- #include <shogun/features/DataGenerator.h>
- using namespace shogun;
- class DataGenerator: public ::testing::Environment
- {
- protected:
- virtual ~DataGenerator() {}
- virtual void SetUp()
- {
- CMath::init_random(5);
- SGMatrix<float64_t> data = CDataGenerator::generate_gaussians(100, 2, 2);
- CDenseFeatures<float64_t> features(data);
- SGVector<index_t> train_idx(100), test_idx(100);
- SGVector<float64_t> labels(100);
- for (index_t i = 0, j = 0; i < data.num_cols; ++i)
- {
- if (i % 2 == 0)
- train_idx[j] = i;
- else
- test_idx[j++] = i;
- labels[i/2] = (i < data.num_cols/2) ? 1.0 : -1.0;
- }
- features_train = (CDenseFeatures<float64_t>*)features.copy_subset(train_idx);
- features_test = (CDenseFeatures<float64_t>*)features.copy_subset(test_idx);
- CBinaryLabels temp_labels = CBinaryLabels(labels);
- labels_train = (CBinaryLabels*)temp_labels.clone();
- labels_test = (CBinaryLabels*)temp_labels.clone();
- }
- virtual void TearDown()
- {
- SG_UNREF(features_train);
- SG_UNREF(features_test);
- SG_UNREF(labels_train);
- SG_UNREF(labels_test);
- }
- // data for training
- CDenseFeatures<float64_t>* features_train;
- // data for testing
- CDenseFeatures<float64_t>* features_test;
- // traning label
- CBinaryLabels* labels_train;
- // testing label
- CBinaryLabels* labels_test;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement