Metrics Module
Metrics for data science
@author: Antony Vamvakeros
- nDTomo.methods.metrics.Rexp(y_obs, y_calc, weights=None)[source]
Function to compute the expected profile R-factor (Rexp) used in X-ray diffraction analysis.
Parameters: y_obs (numpy array): The observed (experimental) data points. y_calc (numpy array): The calculated (or model) data points. weights (numpy array, optional): The weights for each data point. Defaults to 1/y_obs.
Returns: float: The calculated Rexp value.
- nDTomo.methods.metrics.Rwp(y_obs, y_calc, weights=None)[source]
Function to compute the weighted profile R-factor (Rwp) used in X-ray diffraction analysis.
Parameters: y_obs (numpy array): The observed (experimental) data points. y_calc (numpy array): The calculated (or model) data points. weights (numpy array, optional): The weights for each data point. Defaults to 1/y_obs.
Returns: float: The calculated Rwp value.
- nDTomo.methods.metrics.calculate_rmse(data1, data2)[source]
Calculates the root mean squared error (RMSE) between two datasets.
- Parameters:
volume1 (numpy.ndarray) – First input volume as a NumPy array.
volume2 (numpy.ndarray) – Second input volume as a NumPy array.
- Returns:
Root mean squared error value.
- Return type:
- nDTomo.methods.metrics.chi_square(y_obs, y_calc, weights=None)[source]
Function to compute the chi-square value used in statistical analysis.
Parameters: y_obs (numpy array): The observed (experimental) data points. y_calc (numpy array): The calculated (or model) data points. weights (numpy array, optional): The weights for each data point. Defaults to 1/y_obs.
Returns: float: The calculated chi-square value.
- nDTomo.methods.metrics.compute_goodness_of_fit(y_obs, y_calc, weights=None)[source]
Function to compute the goodness of fit used in statistical analysis.
Parameters: y_obs (numpy array): The observed (experimental) data points. y_calc (numpy array): The calculated (or model) data points. weights (numpy array, optional): The weights for each data point. Defaults to 1/y_obs.
Returns: float: The calculated goodness of fit value.
- nDTomo.methods.metrics.mae(data1, data2)[source]
Computes the Mean Absolute Error (MAE) between two arrays.
- Parameters:
data1 (numpy.ndarray) – First input array.
data2 (numpy.ndarray) – Second input array.
- Returns:
The mean squared error value.
- Return type:
- nDTomo.methods.metrics.mse(data1, data2)[source]
Computes the Mean Squared Error (MSE) between two arrays.
- Parameters:
data1 (numpy.ndarray) – First input array.
data2 (numpy.ndarray) – Second input array.
- Returns:
The mean squared error value.
- Return type:
- nDTomo.methods.metrics.normalized_cross_correlation(data1, data2)[source]
Computes the Normalized Cross-Correlation (NCC) between two arrays.
- Parameters:
data1 (numpy.ndarray) – First input array.
data2 (numpy.ndarray) – Second input array.
- Returns:
The NCC value.
- Return type:
- nDTomo.methods.metrics.psnr(data1, data2)[source]
Computes the Peak Signal-to-Noise Ratio (PSNR) between two arrays.
- Parameters:
data1 (numpy.ndarray) – First input array.
data2 (numpy.ndarray) – Second input array.
- Returns:
The PSNR value.
- Return type:
- nDTomo.methods.metrics.ssim_data(data1, data2)[source]
Computes the Structural Similarity Index (SSIM) between two arrays.
- Parameters:
data1 (numpy.ndarray) – First input array.
data2 (numpy.ndarray) – Second input array.
- Returns:
The SSIM value.
- Return type:
- nDTomo.methods.metrics.total_variation_image(image, tv_type)[source]
Calculates the isotropic or anisotropic total variation of an image.