core
cbr_fox module
- class cbr_fox.core.cbr_fox.cbr_fox(metric: str = 'dtw', smoothness_factor: float = 0.2, kwargs: dict = {})[source]
Bases:
objectCore class to perform calculations and analysis at technique-level depth.
This class is used to preprocess the provided input data for performing correlation and find the best cases. Its} functionality follows classic AI library guidelines and standards such as scikit-learn and keras.
- Parameters:
metric (str or callable, optional) – The metric to use for correlation (default is “dtw”).
smoothness_factor (float, optional) – The smoothness factor for preprocessing (default is 0.2).
kwargs (dict, optional) – Additional keyword arguments for customization.
- __init__(self, metric, smoothness_factor, kwargs)[source]
Initializes the cbr_fox class with specified parameters.
- calculate_analysis(indexes, input_data_dictionary)[source]
Compute analysis results and store them in a record array for reporting and visualization.
This method processes data for the specified indices, extracting relevant information such as training windows, target windows, correlation values, and Mean Absolute Error (MAE). The results are stored in a structured record array.
- Parameters:
indexes (list of int) – A list of indices corresponding to valleys and peaks in the non-smoothed correlation array.
input_data_dictionary (dict) – A dictionary containing preprocessed input data, including training and target windows.
- Returns:
A structured record array containing the following fields: - Index: The index of the data point. - Training window: The array representing the training window. - Target window: The array representing the target window. - Correlation value: The correlation value from the non-smoothed correlation array. - MAE: The Mean Absolute Error (MAE) value comparing the target window and the prediction.
- Return type:
numpy.recarray
- fit(training_windows: ndarray, target_training_windows: ndarray, forecasted_window: ndarray)[source]
Perform correlation analysis and identify cases based on the provided data.
This method analyzes the provided training windows, calculates the correlation using the selected metric, and performs CBR analysis to identify cases based on the data.
- Parameters:
training_windows (numpy.ndarray) – A 3D array of training windows with shape (n_windows, window_len, components_len), where n_windows is the number of windows, window_len is the length of each window, and components_len is the number of features per timestep.
target_training_windows (list) – A list of target windows corresponding to each training window.
forecasted_window (list) – A window used for forecasting and making predictions.
- Returns:
This method performs calculations for correlation analysis and case-based reasoning.
- Return type:
None
- get_analysis_report()[source]
Access the analysis report containing the best cases based on the analysis.
- Returns:
A DataFrame containing the best cases and their respective information based on the analysis.
- Return type:
pandas.DataFrame
- get_analysis_report_combined()[source]
Access the combined analysis report containing the best cases based on the combined analysis.
- Returns:
A DataFrame containing the combined best cases and their respective information based on the analysis.
- Return type:
pandas.DataFrame
- predict(prediction, num_cases: int, mode)[source]
Perform analysis to identify the best cases based on the provided prediction.
This method computes the statistics to identify the best cases compared to the provided prediction and returns results that can be accessed through corresponding methods.
- Parameters:
prediction (numpy.ndarray) – The prediction generated by the AI model.
num_cases (int) – The maximum number of cases to identify.
mode (str, optional) – A string to specify the mode for the combined case option, which can be either ‘simple’ or ‘combined’. The default is “simple”.
- Returns:
This method performs the analysis, and results can be accessed via the corresponding methods.
- Return type:
None