diff --git a/docs/ExtendedKalmanFilter.md b/docs/ExtendedKalmanFilter.md new file mode 100644 index 0000000..cbd8721 --- /dev/null +++ b/docs/ExtendedKalmanFilter.md @@ -0,0 +1,37 @@ +# ExtendedKalmanFilter + + + + +## Methods + + +### __init__ + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +measurement_covariance | | +model_covariance | | + + + + + +### calculate + + + + +#### Parameters +name | description | default +--- | --- | --- +measurements | | + + + + diff --git a/docs/MassBalance.md b/docs/MassBalance.md new file mode 100644 index 0000000..065b9ef --- /dev/null +++ b/docs/MassBalance.md @@ -0,0 +1,40 @@ +# MassBalance + + + + +## Methods + + +### __init__ + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +microbial_kinetics | | +inlet | | +outlet | | + + + + + +### calculate + + +Calculates the mass balance for a given kinetic rate list. + +#### Parameters +name | description | default +--- | --- | --- +self | | +concentrations | | +time | | + + + + diff --git a/docs/PCAReport.md b/docs/PCAReport.md new file mode 100644 index 0000000..fdc2cd5 --- /dev/null +++ b/docs/PCAReport.md @@ -0,0 +1,150 @@ +# PCAReport + + + + +## Methods + + +### __init__ + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +model | | +X_train | | +y_train | | +X_test | | None +y_test | | None +wavenumbers | | None + + + + + +### plot_data + + +Plot spectra with optional color coding. +Parameters ---------- color_by : Optional[ArrayLike] Optional array for color coding the points. + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +title | | "Spectra" +x_label | | "Wavenumber" +y_label | | "Intensity" + + + + + +### plot_preprocessed_data + + +Plot preprocessed spectra with optional color coding. +Parameters ---------- color_by : Optional[ArrayLike] Optional array for color coding the points. + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +title | | "Spectra" +x_label | | "Wavenumber" +y_label | | "Intensity" + + + + + +### _get_ellipse + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +x | | +y | | +ax | | +n_std | | 3 +edgecolor | | "red" + + + + + +### plot_scores + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +title | | "PCA Scores" +x_axis | | 1 +y_axis | | 2 +n_std | | 3 + + + + + +### plot_loadings + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +title | | "PCA Loadings" + + + + + +### plot_scree + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +title | | "Cumulative Explained Variance" + + + + + +### plot_residuals + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +label_by | | None +title | | "Residuals" + + + + diff --git a/docs/PLSRegressionReport.md b/docs/PLSRegressionReport.md new file mode 100644 index 0000000..acd8b55 --- /dev/null +++ b/docs/PLSRegressionReport.md @@ -0,0 +1,118 @@ +# PLSRegressionReport + + + + +## Methods + + +### __init__ + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +model | | +X_train | | +y_train | | +X_test | | None +y_test | | None +wavenumbers | | None + + + + + +### plot_data + + +Plot spectra with optional color coding. +Parameters ---------- color_by : Optional[ArrayLike] Optional array for color coding the points. + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +title | | "Spectra" +x_label | | "Wavenumber" +y_label | | "Intensity" + + + + + +### plot_preprocessed_data + + +Plot preprocessed spectra with optional color coding. +Parameters ---------- color_by : Optional[ArrayLike] Optional array for color coding the points. + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +title | | "Spectra" +x_label | | "Wavenumber" +y_label | | "Intensity" + + + + + +### _get_ellipse + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +x | | +y | | +ax | | +n_std | | 3 +edgecolor | | "red" + + + + + +### plot_residuals + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None +label_by | | None +title | | "Residuals" + + + + + +### plot_prediction_results + + +Plot prediction results for the PLS regression model. +Parameters ---------- None +Returns ------- None + +#### Parameters +name | description | default +--- | --- | --- +self | | +color_by | | None + + + + diff --git a/docs/README.md b/docs/README.md index 0b2fca8..5bafc60 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,68 +2,92 @@ ## Classes -**[RangeCut](RangeCut.md)**: Cuts a dataframe selecting the wavenumbers between start and end. +**[PCAReport](PCAReport.md)**: -**[Derivative](Derivative.md)**: Calculates the derivative of a each row in a dataframe using the Savitzky-Golay filter. +**[PLSRegressionReport](PLSRegressionReport.md)**: +**[YeastModel](YeastModel.md)**: -## Functions +**[MassBalance](MassBalance.md)**: -### test_range_cut +**[RangeCut](RangeCut.md)**: Cuts a dataframe selecting the wavenumbers between start and end. +**[Derivative](Derivative.md)**: Calculates the derivative of a each row in a dataframe using the Savitzky-Golay filter. -Test the range cut. +**[ExtendedKalmanFilter](ExtendedKalmanFilter.md)**: +## Functions +### plot_pls_fermentation -### test_derivate +Plots the predicted concentration and the reference hplc measurements. +#### Parameters +name | description | default +--- | --- | --- +prediction | load the predictions. | +fermentation_hplc | load the reference hplc measurements. | -Test the derivative. -### test_train_loadings +### plot_pls_training -Test the loading of the training data. +Plots the PLS predictions and the reference hplc measurements for the training set. +#### Parameters +name | description | default +--- | --- | --- +predictions | predicted concentrations. | +reference | reference hplc measurements. | -### test_fermentation_loadings +### plot_spectra -Test the loading of the fermentation data. +Plots spectra. +#### Parameters +name | description | default +--- | --- | --- +spectra | dataframe containing the spectra with the wavenumbers as columns. | +title | title of plot | +xlabel | x-axis label | +ylabel | y-axis label | -### cross_validation -Performs cross-validation on the data. By default it performs a leave-one-out cross-validation. +### plot_mechanistic_fermentation + + +Plots the predicted concentration and the reference hplc measurements. #### Parameters name | description | default --- | --- | --- -X | spectra dataframe containing the spectra with the wavenumbers as columns. | -y | dataframe containing the reference hplc measurements. | +prediction | load the predictions. | +fermentation_hplc | load the reference hplc measurements. | +time | | +concentrations | | -### load_train_data +### load_training_data -Loads the train data. +Loads the training data. -### load_fermentation_data +### load_fermentation_spectra_data Loads the fermentation data. @@ -71,15 +95,62 @@ Loads the fermentation data. -### plot_fermentation +### load_fermentation_hplc_data -Plots the predicted concentration and the reference hplc measurements. +Loads the fermentation data. + + + + +### load_filtered_fluorescence_data + + +returns the emission - excitation matrix for the filtered data + + + + +### load_unfiltered_fluorescence_data + + +returns the emission - excitation matrix for the filtered data + + + + +### extract_and_validate_model + + +Validate and extract a PCA or PLS model, optionally from a pipeline. +This function checks whether the provided model or the final step in a pipeline is of the expected type (`PCA` or `PLSRegression`) and whether it has been fitted. It also separates any preceding pipeline steps (transformers) from the estimator. +Parameters ---------- model : BaseEstimator or Pipeline A fitted scikit-learn estimator or a Pipeline containing a PCA or PLSRegression model as the final step. +model_type : {'pca', 'pls'} The expected type of model. Must be one of 'pca' or 'pls'. +Returns ------- transformer : Pipeline or None A pipeline containing all steps before the final estimator if the input is a Pipeline. `None` if the input is not a pipeline. +estimator : PCA or PLSRegression The validated and fitted PCA or PLSRegression estimator. +Raises ------ ValueError If `model_type` is not 'pca' or 'pls'. +TypeError If the final model is not of the expected type. +NotFittedError If the estimator has not been fitted yet. #### Parameters name | description | default --- | --- | --- -prediction | load the predictions. | -fermentation_hplc | load the reference hplc measurements. | +model | | +model_type | | + + + + + +### get_cut_wavenumbers_from_pipeline + + +Retrieve the `cut_wavenumbers` attribute from a 'rangecut' step in a Pipeline, if present. +Parameters ---------- pipeline : Pipeline A scikit-learn Pipeline object. +Returns ------- cut_wavenumbers : Any or None The `cut_wavenumbers` attribute from the 'rangecut' step, or None if the step is absent. +#### Parameters +name | description | default +--- | --- | --- +pipeline | | @@ -88,29 +159,81 @@ fermentation_hplc | load the reference hplc measurements. | ### plot_spectra -Plots spectra. +Plot spectra with optional color coding based on a scalar array. +Parameters ---------- x : ArrayLike The x-axis data (e.g., wavenumbers), shape (n_features,) y : ArrayLike The y-axis data (e.g., intensity values), shape (n_samples, n_features) color_by : Optional[ArrayLike], optional Optional array of shape (n_samples,) for color coding the lines. title : str, optional Title of the plot (default is "Spectra"). x_label : str, optional Label for the x-axis (default is "Wavenumber"). y_label : str, optional Label for the y-axis (default is "Intensity"). +Returns ------- fig : matplotlib.figure.Figure The figure object. ax : matplotlib.axes._axes.Axes The axes object. #### Parameters name | description | default --- | --- | --- -spectra | dataframe containing the spectra with the wavenumbers as columns. | -title | title of plot | -xlabel | x-axis label | -ylabel | y-axis label | +x | | +y | | +color_by | | None +title | | "Spectra" +x_label | | "Wavenumber" +y_label | | "Intensity" -### plot_predictions +### cross_validation -Plots the PLS predictions and the reference hplc measurements for the training set. +Performs cross-validation on the data. By default it performs a leave-one-out cross-validation. #### Parameters name | description | default --- | --- | --- -predictions | predicted concentrations. | -reference | reference hplc measurements. | +X | spectra dataframe containing the spectra with the wavenumbers as columns. | +y | dataframe containing the reference hplc measurements. | + + + + + +### load_pls_glucose_model + + + + + + + +### test_range_cut + + +Test the range cut. + + + + +### test_derivate + + +Test the derivative. + + + + +### test_ir_train_loadings + + +Test the loading of the training data. + + + + +### test_ir_fermentation_loadings + + +Test the loading of the fermentation data. + + + + +### test_fluorescence_loadings + +Test the loading of the fluorescence data diff --git a/docs/YeastModel.md b/docs/YeastModel.md new file mode 100644 index 0000000..3aeea8d --- /dev/null +++ b/docs/YeastModel.md @@ -0,0 +1,40 @@ +# YeastModel + + + + +## Methods + + +### __init__ + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +model_type | | +substrate_biomass_yield | | +substrate_product_yield | | + + + + + +### calculate_rates + + + + +#### Parameters +name | description | default +--- | --- | --- +self | | +substrate_concentration | | +biomass_concentration | | + + + +