-
-
Save frx/511ebb332a6f18d02c62 to your computer and use it in GitHub Desktop.
Usage of StreamingFile and StreamingFeatures
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
#include <shogun/features/StreamingFeatures.h> | |
#include <shogun/lib/StreamingFile.h> | |
#include <shogun/lib/common.h> | |
#include <shogun/base/init.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
using namespace shogun; | |
int main() | |
{ | |
init_shogun(); | |
FILE* infile=fopen("sample.dat", "r"); | |
CStreamingFile* f = new CStreamingFile(infile); | |
CStreamingFeatures* features = new CStreamingFeatures(f, false); | |
SG_REF(features); | |
float64_t* fv; | |
int32_t length, vector_number = 0; | |
float64_t label; | |
features->start_parser(); | |
while (features->get_next_feature_vector(fv, length, label)) | |
{ | |
vector_number++; | |
printf("Vector %d\n--------------", vector_number); | |
for (int i=0; i<length; i++) | |
{ | |
printf("Fv[%d] = %f\t", i, fv[i]); | |
} | |
printf("\n"); | |
features->free_feature_vector(); | |
} | |
printf("Done. Vectors parsed=%d.\n", vector_number); | |
SG_UNREF(features); | |
exit_shogun(); | |
return 0; | |
} | |
/* sample.dat is something like this: | |
1 -1.991488249375454 -4.10515592045831 | |
1 -4.638179746904141 -0.7680036306633036 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment