Adding functions
This commit is contained in:
parent
694ef200df
commit
3245044e4e
4 changed files with 63 additions and 19 deletions
15
main.c
15
main.c
|
@ -28,6 +28,21 @@ int main(int argc, char *argv[])
|
|||
Network *net = init_network(n_neurons, 6, activations);
|
||||
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");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
3
mydata.csv
Normal file
3
mydata.csv
Normal file
|
@ -0,0 +1,3 @@
|
|||
1,2,3.2,0
|
||||
4,1.1,2.1,1
|
||||
5,4,1,2
|
|
|
@ -41,29 +41,55 @@ Data *init_data()
|
|||
return data;
|
||||
}
|
||||
|
||||
void destroy_features_from_feature(Feature *feature)
|
||||
void destroy_sample(Sample *sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void destroy_hots_from_hot(OneHotLabel *first_hot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void destroy_samples_from_sample(Sample *sample)
|
||||
{
|
||||
|
||||
Feature *temp1;
|
||||
while (sample->first_feature != NULL)
|
||||
{
|
||||
temp1 = sample->first_feature;
|
||||
sample->first_feature = sample->first_feature->next_feature;
|
||||
free(temp1);
|
||||
}
|
||||
OneHotLabel *temp2;
|
||||
while (sample->first_hot != NULL)
|
||||
{
|
||||
temp2 = sample->first_hot;
|
||||
sample->first_hot = sample->first_hot->next;
|
||||
free(temp2);
|
||||
}
|
||||
free(sample);
|
||||
}
|
||||
|
||||
void destroy_data(Data *data)
|
||||
{
|
||||
|
||||
Sample *temp;
|
||||
while (data->first_sample != NULL)
|
||||
{
|
||||
temp = data->first_sample;
|
||||
data->first_sample = data->first_sample->next_sample;
|
||||
destroy_sample(temp);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
|
||||
Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent)
|
||||
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");
|
||||
if(file != NULL)
|
||||
{
|
||||
while(fgets(chaine, 30, file) != NULL)
|
||||
{
|
||||
printf("%s", chaine);
|
||||
}
|
||||
}*/
|
||||
//TODO : complete
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
void print_data(const Data *data)
|
||||
{
|
||||
printf("Hello");
|
||||
}
|
|
@ -42,10 +42,10 @@ Feature *init_feature(float value);
|
|||
OneHotLabel *init_onehotlabel(float value);
|
||||
Sample *init_sample();
|
||||
Data *init_data();
|
||||
void destroy_features_from_feature(Feature *feature);
|
||||
void destroy_hots_from_hot(OneHotLabel *first_hot);
|
||||
void destroy_samples_from_sample(Sample *sample);
|
||||
void destroy_sample(Sample *sample);
|
||||
void destroy_data(Data *data);
|
||||
Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent);
|
||||
Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent, char *apply_onthot_encode, int n_classes);
|
||||
//Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent);
|
||||
void print_data(const Data *data);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue