alib
Universal C Library Collection for Machine Learning & Artificial Intelligence
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
data.h File Reference

A simple dataset management and manipulation library header. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for data.h:

Go to the source code of this file.

Data Structures

struct  data
 Structure to hold dataset information. More...
 

Typedefs

typedef struct data data
 Structure to hold dataset information.
 

Functions

int compare_ints (const void *a, const void *b)
 Compare two integers (for use with qsort).
 
void data_free (data *data)
 Free the memory allocated for the data structure.
 
void data_mix_training_indices (data *data)
 Randomly shuffle the training instance indices.
 
void data_print_features (data *data)
 Print the feature names of the dataset.
 
void data_print_instances (data *data)
 Print all instances in the dataset.
 
void data_print_scaled_instances (data *data)
 Print all scaled instances in the dataset.
 
void data_print_target_indices (data *data)
 Print the indices of instances for each target.
 
void data_print_targets (data *data)
 Print the target names of the dataset.
 
void data_print_test_indices (data *data)
 Print the test instance indices.
 
void data_print_train_indices (data *data)
 Print the training instance indices.
 
datadata_read_from_csv (const char *fname, double train_percentage)
 Read dataset from a CSV file and split into training and test sets.
 
void data_sort_training_indices (data *data)
 Sort the training instance indices.
 
void print_data_info (data *data)
 Print general information about the dataset.
 

Detailed Description

A simple dataset management and manipulation library header.

This file contains the declarations of functions and structures used for managing and manipulating datasets, including reading from CSV files, printing dataset information, and managing training and test data splits. The implementations of these functions are included in the compiled library lib/libdata.so.

Definition in file data.h.

Typedef Documentation

◆ data

typedef struct data data

Structure to hold dataset information.

This structure contains various fields to store dataset information such as feature names, target labels, instances, and their respective properties.

Function Documentation

◆ compare_ints()

int compare_ints ( const void * a,
const void * b )

Compare two integers (for use with qsort).

This function compares two integers and returns a value indicating their relative order.

Parameters
aPointer to the first integer.
bPointer to the second integer.
Returns
Negative if *a < *b, zero if *a == *b, positive if *a > *b.

◆ data_free()

void data_free ( data * data)

Free the memory allocated for the data structure.

This function frees all dynamically allocated memory associated with the data structure.

Parameters
dataThe data structure to be freed.

◆ data_mix_training_indices()

void data_mix_training_indices ( data * data)

Randomly shuffle the training instance indices.

This function randomly shuffles the indices of the training instances.

Parameters
dataThe data structure containing the dataset.

◆ data_print_features()

void data_print_features ( data * data)

Print the feature names of the dataset.

This function prints the names of the features in the dataset.

Parameters
dataThe data structure containing the dataset.

◆ data_print_instances()

void data_print_instances ( data * data)

Print all instances in the dataset.

This function prints all instances in the dataset.

Parameters
dataThe data structure containing the dataset.

◆ data_print_scaled_instances()

void data_print_scaled_instances ( data * data)

Print all scaled instances in the dataset.

This function prints all scaled instances in the dataset.

Parameters
dataThe data structure containing the dataset.

◆ data_print_target_indices()

void data_print_target_indices ( data * data)

Print the indices of instances for each target.

This function prints the indices of instances for each target class in the dataset.

Parameters
dataThe data structure containing the dataset.

◆ data_print_targets()

void data_print_targets ( data * data)

Print the target names of the dataset.

This function prints the names of the target classes in the dataset.

Parameters
dataThe data structure containing the dataset.

◆ data_print_test_indices()

void data_print_test_indices ( data * data)

Print the test instance indices.

This function prints the indices of the instances used for testing.

Parameters
dataThe data structure containing the dataset.

◆ data_print_train_indices()

void data_print_train_indices ( data * data)

Print the training instance indices.

This function prints the indices of the instances used for training.

Parameters
dataThe data structure containing the dataset.

◆ data_read_from_csv()

data * data_read_from_csv ( const char * fname,
double train_percentage )

Read dataset from a CSV file and split into training and test sets.

This function reads the dataset from the specified CSV file and splits it into training and test sets based on the given train_percentage.

Parameters
fnameThe filename of the CSV file.
train_percentageThe percentage of data to be used for training.
Returns
Pointer to the data structure containing the dataset.

◆ data_sort_training_indices()

void data_sort_training_indices ( data * data)

Sort the training instance indices.

This function sorts the indices of the training instances in ascending order.

Parameters
dataThe data structure containing the dataset.

◆ print_data_info()

void print_data_info ( data * data)

Print general information about the dataset.

This function prints general information about the dataset, such as the number of features, targets, and instances.

Parameters
dataThe data structure containing the dataset.