To learn more about the scikit-learn API click here.
The folder structure of c-scikit-learn is the following:
c-skl
│ skl_helper.h
│ skl_helper.c
│
└───linear_model
│ │
│ └───linear_regression
│ │ skl_linear_regression.h
│ │ skl_linear_regression.c
│ │
└───────svm
│
└────svr
│ skl_svr.h
│ skl_svc
...
Each folder in c-skl contains a distinct model from scikit-learn.
c-scikit-learn makes use of a double**
wrapper, which is used by every model in c-scikit-learn.
typedef struct array{
int r;
int c;
double** x;
} array;
A model has the following structure:
#ifndef SKL_<MODEL_NAME>
#define SKL_<MODEL_NAME>
#define NO_IMPORT_ARRAY
#include "../../skl_helper.h"
typedef struct skl_<model_name> skl_<model_name>;
// skl_<model_name> model struct
struct skl_<model_name> {
PyObject* self; // reference to a scikit-learn object
struct {
int parameter_1;
int parameter_2;
.
.
.
char* parameter_n;
} parameters;
struct {
int attribute_1;
int attribute_2;
.
.
.
array* attribute_3;
} attributes;
// methods associated to <model_name>
void (*fit)(skl_<model_name>* m, array* x, array* y);
void (*get_params)(skl_<model_name>* m);
array* (*predict)(skl_<model_name>* m, array* x);
float (*score)(skl_<model_name>* m, array* x, array* y);
void (*set_params)(skl_<model_name>* m);
void (*purge)(skl_<model_name>* m);
};
// fetches a <model_name> struct with default parameters
skl_<model_name>* skl_get_<model_name>();
#endif /* SKL_<MODEL_NAME> */
Other than that, the functionality is pretty much the same as in scikit-learn.
For an example, check out a toy linear regression example.