dmlfw (Daniyal Machine Learning Framework)
|
Matrix data scaling and normalization using double precision. More...
#include <dmlfw_matrix.h>
Go to the source code of this file.
dmlfw_mat_double * | dmlfw_scale_double (char *dataset_file_name, dmlfw_row_vec_string *columns_to_scale, char *parameters_file_name, char *algorithm, dmlfw_mat_double *matrix) |
Scales data from a dataset according to specified columns and algorithm. | |
dmlfw_mat_double * | dmlfw_scale_double_min_max (dmlfw_mat_double *matrix, index_t start_row_index, index_t start_column_index, index_t end_row_index, index_t end_column_index, dmlfw_mat_double **min_max_matrix, dmlfw_mat_double *scaled_matrix) |
Performs min-max scaling on a submatrix slice and optionally returns min-max matrix. | |
dmlfw_mat_double * | dmlfw_scale_double_with_given_min_max (dmlfw_mat_double *matrix, index_t start_row_index, index_t start_column_index, index_t end_row_index, index_t end_column_index, dmlfw_mat_double *min_max_matrix, dmlfw_mat_double *scaled_matrix) |
Scales matrix using given min-max matrix for normalization. | |
dmlfw_mat_double * | dmlfw_scale_double_with_given_parameters (char *dataset_file_name, char *parameters_file_name, char *algorithm, dmlfw_mat_double *matrix) |
Scales data using pre-computed parameters according to algorithm. | |
dmlfw_mat_double * | dmlfw_scale_double_z_score (dmlfw_mat_double *matrix, index_t start_row_index, index_t start_column_index, index_t end_row_index, index_t end_column_index, dmlfw_mat_double **mean_standard_deviation_matrix, dmlfw_mat_double *scaled_matrix) |
Performs z-score scaling on a submatrix slice, optionally returning mean/std matrix. | |
dmlfw_mat_double * | dmlfw_scale_double_z_score_with_given_mean_standard_deviation (dmlfw_mat_double *matrix, index_t start_row_index, index_t start_column_index, index_t end_row_index, index_t end_column_index, dmlfw_mat_double *mean_standard_deviation_matrix, dmlfw_mat_double *scaled_matrix) |
Scales matrix using given mean and standard deviation matrix. | |
#define | MLFW_MIN_MAX_SCALING_ALGORITHM "min-max" |
#define | MLFW_Z_SCORE_SCALING_ALGORITHM "z-score" |
Matrix data scaling and normalization using double precision.
This module provides scaling algorithms applied to double precision matrices, such as min-max normalization and z-score standardization.
Algorithms include:
Functions support loading scaling parameters from files and applying previously computed parameters to new data.
All functions validate input parameters and interoperability. Errors are reported via the centralized error API, using dmlfw_error()
, dmlfw_get_error_string()
, and dmlfw_get_debug_string()
.
Caller owns all input matrices. Output matrices are allocated if NULL
is passed, and ownership passes to the caller, who must free them.
#define MLFW_MIN_MAX_SCALING_ALGORITHM "min-max" |
Min-Max scaling algorithm identifier string.
#define MLFW_Z_SCORE_SCALING_ALGORITHM "z-score" |
Z-Score scaling algorithm identifier string.
dmlfw_mat_double * dmlfw_scale_double | ( | char * | dataset_file_name, |
dmlfw_row_vec_string * | columns_to_scale, | ||
char * | parameters_file_name, | ||
char * | algorithm, | ||
dmlfw_mat_double * | matrix | ||
) |
Scales data from a dataset according to specified columns and algorithm.
dataset_file_name | [in] File path of the dataset (CSV or supported format). |
columns_to_scale | [in] Row vector of column names/labels to scale. |
parameters_file_name | [in] Path to save or read scaling parameters. |
algorithm | [in] Scaling algorithm identifier: "min-max" or "z-score". |
matrix | [in,out] Optional pre-allocated matrix to store scaled data, or NULL to allocate a new one. |
Usage example:
dmlfw_mat_double * dmlfw_scale_double_min_max | ( | dmlfw_mat_double * | matrix, |
index_t | start_row_index, | ||
index_t | start_column_index, | ||
index_t | end_row_index, | ||
index_t | end_column_index, | ||
dmlfw_mat_double ** | min_max_matrix, | ||
dmlfw_mat_double * | scaled_matrix | ||
) |
Performs min-max scaling on a submatrix slice and optionally returns min-max matrix.
matrix | [in] Input matrix. |
start_row_index | [in] Start index for rows (inclusive). |
start_column_index | [in] Start index for columns (inclusive). |
end_row_index | [in] End index for rows (inclusive). |
end_column_index | [in] End index for columns (inclusive). |
min_max_matrix | [out] Optional pointer to store min and max values matrix, allocated if NULL. |
scaled_matrix | [in,out] Optional matrix to store the scaled data, or NULL to allocate a new matrix. |
dmlfw_mat_double * dmlfw_scale_double_with_given_min_max | ( | dmlfw_mat_double * | matrix, |
index_t | start_row_index, | ||
index_t | start_column_index, | ||
index_t | end_row_index, | ||
index_t | end_column_index, | ||
dmlfw_mat_double * | min_max_matrix, | ||
dmlfw_mat_double * | scaled_matrix | ||
) |
Scales matrix using given min-max matrix for normalization.
matrix | [in] Input matrix to scale. |
start_row_index | [in] Start row index for submatrix. |
start_column_index | [in] Start column index for submatrix. |
end_row_index | [in] End row index for submatrix. |
end_column_index | [in] End column index for submatrix. |
min_max_matrix | [in] Matrix containing min and max values per column. |
scaled_matrix | [in,out] Optional matrix to hold scaled result, or NULL for allocation. |
dmlfw_mat_double * dmlfw_scale_double_with_given_parameters | ( | char * | dataset_file_name, |
char * | parameters_file_name, | ||
char * | algorithm, | ||
dmlfw_mat_double * | matrix | ||
) |
Scales data using pre-computed parameters according to algorithm.
dataset_file_name | [in] Dataset source file path. |
parameters_file_name | [in] File for reading pre-computed scaling parameters. |
algorithm | [in] Scaling algorithm identifier. |
matrix | [in,out] Optional matrix to output scaled data, or NULL to allocate. |
dmlfw_mat_double * dmlfw_scale_double_z_score | ( | dmlfw_mat_double * | matrix, |
index_t | start_row_index, | ||
index_t | start_column_index, | ||
index_t | end_row_index, | ||
index_t | end_column_index, | ||
dmlfw_mat_double ** | mean_standard_deviation_matrix, | ||
dmlfw_mat_double * | scaled_matrix | ||
) |
Performs z-score scaling on a submatrix slice, optionally returning mean/std matrix.
matrix | [in] Input matrix. |
start_row_index | [in] Start row index (inclusive). |
start_column_index | [in] Start column index (inclusive). |
end_row_index | [in] End row index (inclusive). |
end_column_index | [in] End column index (inclusive). |
mean_standard_deviation_matrix | [out] Optional pointer for mean and std dev, allocated if NULL. |
scaled_matrix | [in,out] Matrix to store scaled data or NULL to allocate. |
dmlfw_mat_double * dmlfw_scale_double_z_score_with_given_mean_standard_deviation | ( | dmlfw_mat_double * | matrix, |
index_t | start_row_index, | ||
index_t | start_column_index, | ||
index_t | end_row_index, | ||
index_t | end_column_index, | ||
dmlfw_mat_double * | mean_standard_deviation_matrix, | ||
dmlfw_mat_double * | scaled_matrix | ||
) |
Scales matrix using given mean and standard deviation matrix.
matrix | [in] Input matrix. |
start_row_index | [in] Start row index for scaling. |
start_column_index | [in] Start column index for scaling. |
end_row_index | [in] End row index for scaling. |
end_column_index | [in] End column index for scaling. |
mean_standard_deviation_matrix | [in] Matrix with mean and std deviation. |
scaled_matrix | [in,out] Matrix for scaled output or NULL to allocate. |