cuvis_ai.distance.distance.GFC
- class cuvis_ai.distance.distance.GFC(ref_spectra: list = [])[source]
Bases:
AbstractDistance
Goodness-of-fit Coefficient (GFC)
Citation:
Hernández-Andrés, J., Romero, J., García-Beltrán, A., & Nieves, J. L. (1998). Testing linear models on spectral daylight measurements. Applied Optics, 37(6), 971-977.
- Parameters:
AbstractDistance (AbstractDistance) – Defines the node as AbstractDistance node type
- __init__(ref_spectra: list = [])[source]
Construct GFC distance node.
- Parameters:
ref_spectra (list, optional) – Reference spectra to compare against, by default []
Methods
__init__
([ref_spectra])Construct GFC distance node.
Check that the parameters for the input data data match user expectations
Check that the parameters for the output data data match user expectations
fit
(X)forward
(X[, ref_spectra])Pass the data through comparative function
load
(params[, filepath])Load dumped parameters to recreate the distance object
score
(data, ref_spectra)Score new datacubes against reference spectra.
serialize
(working_dir)Convert distance node to serializable format
set_fit_meta_request
(**kwargs)set_forward_meta_request
(**kwargs)spectra_to_array
(ref_spectra)Convert list of spectra to a numpy array
Attributes
Get required input dimension
Get required output dimension
- check_input_dim(X)
Check that the parameters for the input data data match user expectations
Parameters: X (array-like): Input data.
Returns: (Bool) Valid data
- check_output_dim(X)
Check that the parameters for the output data data match user expectations
Parameters: X (array-like): Input data.
Returns: (Bool) Valid data
- fit(X)
- forward(X: ndarray, ref_spectra: list | None = None) ndarray
Pass the data through comparative function
- Parameters:
X (np.ndarray) – Input data.
ref_spectra (list, optional) – List of spectra to compare against
- Returns:
Distance maps for each of the reference spectra.
- Return type:
np.ndarray
- Raises:
ValueError – Mismatch in input data and reference spectra provided on function call.
ValueError – Mismatch in input data and reference spectra provided on node initialization.
ValueError – No reference spectra provided in init or on forward function pass.
- get_fit_requested_meta()
- get_forward_requested_meta()
- property input_dim: list
Get required input dimension
- Returns:
List defining which input dimensions should be checked in graph.
- Return type:
- load(params: dict, filepath: str | None = None)
Load dumped parameters to recreate the distance object
- property output_dim
Get required output dimension
- Returns:
List defining which input dimensions should be checked in graph.
- Return type:
- score(data: ndarray, ref_spectra: ndarray) ndarray [source]
Score new datacubes against reference spectra.
- Parameters:
data (np.ndarray) – Input data.
ref_spectra (np.ndarray) – Reference spectra to compare against.
- Returns:
Distance scores
- Return type:
np.ndarray
- set_fit_meta_request(**kwargs)
- set_forward_meta_request(**kwargs)