Adding data preprocessing functions
This commit is contained in:
parent
13ca1e16ef
commit
694ef200df
4 changed files with 123 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ all : myprogram
|
|||
clean :
|
||||
rm -f *.o myprogram
|
||||
|
||||
myprogram : randomness.o activations.o neurons.o network.o training.o main.o
|
||||
myprogram : randomness.o activations.o neurons.o network.o training.o preprocessing.o main.o
|
||||
gcc -Wall $^ -o myprogram -lm
|
||||
|
||||
%.o : %.c
|
||||
|
|
4
main.c
4
main.c
|
@ -23,11 +23,11 @@ int main(int argc, char *argv[])
|
|||
float a=5.0;
|
||||
printf("%f\n", (float)exp((double)a));*/
|
||||
|
||||
int n_neurons[] = {15,120,220,120,200,25};
|
||||
/*int n_neurons[] = {15,120,220,120,200,25};
|
||||
char *activations[] = {"relu","relu","relu","relu","relu","relu"};
|
||||
Network *net = init_network(n_neurons, 6, activations);
|
||||
print_network(net);
|
||||
destroy_network(net);
|
||||
destroy_network(net);*/
|
||||
|
||||
return 0;
|
||||
}
|
69
preprocessing.c
Normal file
69
preprocessing.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "preprocessing.h"
|
||||
|
||||
Feature *init_feature(float value)
|
||||
{
|
||||
Feature *feature = (Feature*)malloc(sizeof(Feature));
|
||||
feature->value = value;
|
||||
feature->next_feature = NULL;
|
||||
|
||||
return feature;
|
||||
}
|
||||
|
||||
OneHotLabel *init_onehotlabel(float value)
|
||||
{
|
||||
OneHotLabel *hot = (OneHotLabel*)malloc(sizeof(OneHotLabel));
|
||||
hot->value = value;
|
||||
hot->next = NULL;
|
||||
|
||||
return hot;
|
||||
}
|
||||
|
||||
Sample *init_sample()
|
||||
{
|
||||
Sample *sample = (Sample*)malloc(sizeof(Sample));
|
||||
sample->first_feature = NULL;
|
||||
sample->first_hot = NULL;
|
||||
sample->next_sample = NULL;
|
||||
sample->t = TRAIN;
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
Data *init_data()
|
||||
{
|
||||
Data *data = (Data*)malloc(sizeof(Data));
|
||||
data->first_sample = NULL;
|
||||
data->last_sample = NULL;
|
||||
data->size = 0;
|
||||
|
||||
return 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_data(Data *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent)
|
||||
{
|
||||
Data *data = init_data();
|
||||
//TODO : complete
|
||||
return data;
|
||||
}
|
51
preprocessing.h
Normal file
51
preprocessing.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef PREPROCESSING_H
|
||||
#define PREPROCESSING_H
|
||||
|
||||
typedef struct feature Feature;
|
||||
struct feature
|
||||
{
|
||||
float value;
|
||||
Feature *next_feature;
|
||||
};
|
||||
|
||||
typedef struct onehotlabel OneHotLabel;
|
||||
struct onehotlabel
|
||||
{
|
||||
float value;
|
||||
OneHotLabel *next;
|
||||
};
|
||||
|
||||
typedef enum type Type;
|
||||
enum type
|
||||
{
|
||||
TRAIN = 0 , TEST = 1 , VALID = 2
|
||||
};
|
||||
|
||||
typedef struct sample Sample;
|
||||
struct sample
|
||||
{
|
||||
Feature *first_feature;
|
||||
OneHotLabel *first_hot;
|
||||
Sample *next_sample;
|
||||
Type t;
|
||||
};
|
||||
|
||||
typedef struct data Data;
|
||||
struct data
|
||||
{
|
||||
Sample *first_sample;
|
||||
Sample *last_sample;
|
||||
int size;
|
||||
};
|
||||
|
||||
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_data(Data *data);
|
||||
Data *csv_to_samples(char *path_to_csv, char *features_separator, float train_percent);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue