From 1a9d81025d56179425ef0f45487aea8225fefbd8 Mon Sep 17 00:00:00 2001 From: chabisik Date: Thu, 2 Dec 2021 00:25:10 +0100 Subject: [PATCH] Adding most important features' extraction function --- main.c | 27 +++------------------------ preprocessing.c | 29 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/main.c b/main.c index 4c5012a..09a12ef 100644 --- a/main.c +++ b/main.c @@ -6,22 +6,13 @@ #include "network.h" #include "activations.h" #include "training.h" +#include "preprocessing.h" int main(int argc, char *argv[]) { init_randomness(); printf("Bonjour et bienvenu ;)\n"); - /*int i; - for(i=1 ; i<= 30 ; i++) - { - printf("%dth generated fload = %f\n", i, random_float(0.0 , 1.0)); - } - printf("sigmoid(%f) = %f\n",0.5, sigmoid(0.5)); - printf("sigmoid_derivative(%f) = %f\n",0.8, sigmoid_derivative(0.8)); - - float a=5.0; - printf("%f\n", (float)exp((double)a));*/ /*int n_neurons[] = {15,120,220,120,200,25}; char *activations[] = {"relu","relu","relu","relu","relu","relu"}; @@ -29,20 +20,8 @@ int main(int argc, char *argv[]) print_network(net); destroy_network(net);*/ - FILE *file = fopen("mydata.csv", "r"); - char line[100]; - if(file != NULL) - { - while(fgets(line, 100, file) != NULL) - { - //line[strlen(line)-1] = (char)""; - printf("%s", line); - } - fclose(file); - }else - { - printf("Unable to open the file\n"); - } + /*Data *data = csv_to_samples("mydata.csv", ",", 70.0, "yes", 3); + destroy_data(data);*/ return 0; } \ No newline at end of file diff --git a/preprocessing.c b/preprocessing.c index 81cdc48..71a07fb 100644 --- a/preprocessing.c +++ b/preprocessing.c @@ -1,5 +1,6 @@ #include #include +#include #include "preprocessing.h" Feature *init_feature(float value) @@ -75,21 +76,33 @@ void destroy_data(Data *data) Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent, char *apply_onthot_encode, int n_classes) { Data *data = init_data(); - /*FILE *file; - char *chaine; - file = fopen(path_to_csv, "r"); + FILE *file = fopen(path_to_csv, "r"); + char line[100], *dup; + char *token; + //float val; if(file != NULL) { - while(fgets(chaine, 30, file) != NULL) + while(fgets(line, 100, file) != NULL) { - printf("%s", chaine); + dup = strtok(line, "\n"); //extracting line content without '\n' + token = strtok(dup, features_separator); + while(token != NULL) + { + printf("current token = %s\n", token); + token = strtok(NULL, features_separator); + } + printf("----------------\n"); } - }*/ - //TODO : complete + fclose(file); + }else + { + printf("Unable to open the file\n"); + exit(-1); + } return data; } void print_data(const Data *data) { - printf("Hello"); + printf("Hello\n"); } \ No newline at end of file