focal package

Fiber Cleave Processing Package

A machine learning package for fiber cleave quality classification and tension prediction using CNN and MLP models.

class focal.BuildHyperModel(image_shape: Tuple[int, int, int], param_shape: Tuple[int, ...], backbone: str | None = 'mobilenet')[source]

Bases: HyperModel

HyperModel for determining optimal hyperparameters for the combined CNN+MLP model.

This class builds a model architecture that combines image features from MobileNetV2 with numerical parameters for fiber cleave classification.

build(hp)[source]

Build hypermodel to perform hyperparameter search.

Parameters:

hp – keras_tuner.engine.hyperparameters.HyperParameters Hyperparameters to be tuned

Returns:

Compiled model with hyperparameters

Return type:

tf.keras.Model

class focal.BuildMLPHyperModel(model_path: str)[source]

Bases: HyperModel

HyperModel for MLP-based tension prediction.

This class builds a model that uses features extracted from a pre- trained CNN to predict optimal tension values.

build(hp)[source]

Build model with hyperparameters.

Parameters:

hp – keras_tuner.HyperParameters - Hyperparameters to be used for tuning

Returns:

Model to be trained

Return type:

tf.keras.Model

class focal.BuildMLPModel(cnn_model_path: str, train_ds: Any, test_ds: Any, num_classes: int)[source]

Bases: CustomModel

MLP model for tension prediction using features from pre-trained CNN.

This class builds regression models that use features extracted from a CNN to predict optimal tension values for fiber cleaving.

compile_model(dense1: int, dense2: int, dropout1: float, dropout2: float, dropout3: float, param_shape: Tuple[int, ...], learning_rate: float = 0.001, metrics: List[str] | None = None) Model[source]

Compile MLP model for regression.

Parameters:
  • dense1 – Number of neurons in first FC layer.

  • dense2 – Number of neurons in second FC layer.

  • dropout1 – Amount of dropout for CNN output

  • dropout2 – Amount of dropout for feature input.

  • dropout3 – Amount of dropout for concatenated image+features

  • param_shape – Dimensions of numerical parameters

  • learning_rate – Learning rate for optimization

  • metrics – List of metrics to monitor

Returns:

Compiled regression model

Return type:

tf.keras.Model

create_checkpoints(checkpoint_filepath: str = './checkpoints/mlp_model.keras', monitor: str = 'val_mae', mode: str = 'min', save_best_only: bool = True) ModelCheckpoint[source]

Create model checkpoints for MLP model.

Parameters:
  • checkpoint_filepath – Path to save model checkpoints

  • monitor – Metric to monitor during training

  • mode – Method to determine stopping point (min for regression)

  • save_best_only – Whether to save only the best model

Returns:

Checkpoint callback

Return type:

tf.keras.callbacks.ModelCheckpoint

create_early_stopping(patience: int = 3, mode: str = 'min', monitor: str = 'val_mae') EarlyStopping[source]

Create early stopping callback for regression model.

Parameters:
  • patience – Number of epochs to wait before stopping

  • mode – Method to track monitor (min for regression)

  • monitor – Metric to monitor during training

Returns:

Early stopping callback

Return type:

tf.keras.callbacks.EarlyStopping

static get_averages_from_kfold(kfold_histories: List[History], scaler: any) None[source]

Calculate and display average metrics from k-fold cross validation for MLP.

Parameters:
  • kfold_histories – List of training histories from k-fold training

  • scaler – Scaler used for tension values (for denormalization)

static train_kfold_mlp(datasets: List[Tuple], cnn_model_path: str, param_shape: Tuple[int, ...], learning_rate: float, num_classes: int, dense1: int, dense2: int, dropout1: float, dropout2: float, dropout3: float, checkpoints: ModelCheckpoint | None = None, epochs: int = 5, initial_epoch: int = 0, early_stopping: EarlyStopping | None = None, history_file: str | None = None, save_model_file: str | None = None) Tuple[List[Model], List[History]][source]

Train MLP model using k-fold cross validation.

Parameters:
  • datasets – List of (train_ds, test_ds) tuples for each fold

  • cnn_model_path – Path to the pre-trained CNN model

  • param_shape – Dimensions of numerical parameters

  • learning_rate – Learning rate for optimization

  • checkpoints – Checkpoint callback

  • epochs – Number of training epochs

  • initial_epoch – Starting epoch number

  • early_stopping – Early stopping callback

  • history_file – Base filename for saving training history

  • model_file – Base filename for saving models

Returns:

Tuple of (list of trained models, list of training histories)

class focal.CustomModel(train_ds: DatasetV2, test_ds: DatasetV2, num_classes: int, classification_type: str | None = 'binary')[source]

Bases: object

Class for defining custom models using pre-trained MobileNetV2.

This class provides functionality for building, compiling, and training CNN models for fiber cleave classification.

compile_custom_model(image_shape: Tuple[int, int, int], learning_rate: float = 0.001, metrics: List[str] | None = None, num_classes: int | None = 5) Model[source]

Compile custom model after calling build_custom_model function.

Parameters:
  • image_shape – Dimensions of input images

  • param_shape – Dimensions of numerical parameters

  • learning_rate – Learning rate for optimization

  • metrics – List of metrics to monitor

  • num_class – number of output classes

Returns:

Compiled model ready for training

Return type:

tf.keras.Model

compile_image_only_model(image_shape: Tuple[int, int, int], learning_rate: float = 0.001, metrics: List[str] | None = None, backbone: str | None = 'mobilenet', num_classes: int = 5, dropout1: float | None = 0.1, dense1: int | None = 32, dropout2: float | None = 0.2, l2_factor: float | None = None, unfreeze_from: int | None = None) Model[source]

Compile an image-only model.

Parameters:
  • image_shape – Dimensions of input images

  • learning_rate – Learning rate for optimization

  • metrics – List of metrics to monitor

Returns:

Compiled image-only model

Return type:

tf.keras.Model

compile_model(image_shape: Tuple[int, int, int], param_shape: Tuple[int, ...], dropout1: float, dense1: int, dropout2: float, dense2: int, dropout3: float, brightness: float, height: float, width: float, contrast: float, rotation: float, learning_rate: float = 0.001, metrics: List[str] | None = None, unfreeze_from: int | None = None, backbone: str | None = 'mobilenet') Model[source]

Compile the custom model head on top of pre-trained backbone.

Parameters:
  • image_shape (Tuple[int, int, int]) – Shape of each image.

  • param_shape (Tuple[int, ...]) – Shape of feature vector.

  • dropout1 (float) – Amount of dropout for image layer.

  • dense1 (int) – Amount of neurons for first FC layer.

  • dropout2 (float) – Amount of dropout for feature input.

  • dense2 (int) – Amount of neruons for second FC layer.

  • dropout3 (float) – Amount of dropout for concatenated images+features.

  • brightness (float) – Brightness amount for image.

  • height (float) – Height of augmented image.

  • width (float) – Width of augmented image.

  • contrast (float) – Contrast amount of augmented image.

  • rotation (float) – Rotation amount of augmented image.

  • learning_rate (float, optional) – Size of steps to take during optimization. Defaults to 0.001.

  • metrics (Optional[List[str]], optional) – Saved metrics. Defaults to None.

  • unfreeze_from (Optional[int], optional) – Layer to start training pre-trained backbone. Defaults to None.

  • backbone (Optional[str], optional) – Name of pre-trained backbone. Defaults to “mobilenet”.

Returns:

Compiled custom head on pre-trained model backbone.

Return type:

Model

create_checkpoints(checkpoint_filepath: str = './checkpoints/model.keras', monitor: str = 'val_accuracy', mode: str = 'max', save_best_only: bool = True) ModelCheckpoint[source]

Create model checkpoints to avoid losing data while training.

Parameters:
  • checkpoint_filepath – Path to save model checkpoints

  • monitor – Metric to monitor during training

  • mode – Method to determine stopping point of metric (max, min, auto)

  • save_best_only – Whether to save only the best model

Returns:

Checkpoint callback

Return type:

tf.keras.callbacks.ModelCheckpoint

create_early_stopping(patience: int = 3, mode: str = 'max', monitor: str = 'val_accuracy') EarlyStopping[source]

Create early stopping callback to monitor training success and prevent overfitting.

Parameters:
  • patience – Number of epochs to wait before stopping when monitor plateaus

  • mode – Method to track monitor (max, min, auto)

  • monitor – Metric to monitor during training

Returns:

Early stopping callback

Return type:

tf.keras.callbacks.EarlyStopping

create_tensorboard_callback(log_dir: str = './logs', histogram_freq: int = 1) TensorBoard[source]

Create TensorBoard callback for monitoring training.

Parameters:
  • log_dir – Directory for TensorBoard logs

  • histogram_freq – Frequency for computing weight histograms

Returns:

TensorBoard callback

Return type:

tf.keras.callbacks.TensorBoard

static get_averages_from_kfold(kfold_histories: List[History]) None[source]

Calculate and display average metrics from k-fold cross validation.

Parameters:

kfold_histories – List of training histories from k-fold training

get_data_augmentation(rotation: float, brightness: float, height: float, width: float, contrast: float)[source]

Get data augmentation parameters for training model.

Parameters:
  • rotation (float) – Rotation amount of image.

  • brightness (float) – Brightness amount of image.

  • height (float) – Height of image.

  • width (float) – Widht of image.

  • contrast (float) – Contrast amount of image.

Returns:

Data augmentation model.

Return type:

tf.keras.models.Model

plot_metric(title: str, metric_1: List[float], metric_2: List[float], metric_1_label: str, metric_2_label: str, x_label: str, y_label: str, model_path: str) None[source]

Plot training metrics for visualization.

Parameters:
  • title – Title for the plot

  • metric_1 – First metric values to plot

  • metric_2 – Second metric values to plot

  • metric_1_label – Label for first metric

  • metric_2_label – Label for second metric

  • x_label – Label for x-axis

  • y_label – Label for y-axis

reduce_on_plateau(patience: int = 3, mode: str = 'auto', factor: float = 2.0, monitor: str = 'val_accuracy') ReduceLROnPlateau[source]

Create reduced learning rate callback if monitored value stops improving.

Parameters:
  • patience – Number of epochs before reducing learning rate

  • mode – Method to monitor (min, max, auto)

  • factor – Factor by which to reduce learning rate

  • monitor – Value to monitor before reducing learning rate

Returns:

Reduce learning rate callback

Return type:

tf.keras.callbacks.ReduceLROnPlateau

static train_kfold(datasets: List[Tuple], image_shape: Tuple[int, int, int], param_shape: Tuple[int, ...], learning_rate: float, num_classes: int, dropout1: float, dense1: int, dropout2: float, dense2: int, dropout3: float, brightness: float, height: float, width: float, contrast: float, rotation: float, metrics: List[str] | None = None, epochs: int = 5, initial_epoch: int = 0, history_file: str | None = None, save_model_file: str | None = None, callbacks: List | None = None) Tuple[List[Model], List[History]][source]

Train model using k-fold cross validation.

Parameters:
  • datasets – List of (train_ds, test_ds) tuples for each fold

  • image_shape – Dimensions of input images

  • param_shape – Dimensions of numerical parameters

  • learning_rate – Learning rate for optimization

  • metrics – List of metrics to monitor

  • epochs – Number of training epochs

  • initial_epoch – Starting epoch number

  • history_file – Base filename for saving training history

  • model_file – Base filename for saving models

Returns:

Tuple of (list of trained models, list of training histories)

train_model(class_weights, model: Model, epochs: int = 5, initial_epoch: int = 0, callbacks: List | None = None, history_file: str | None = None, save_model_file: str | None = None) History[source]

Train model with possible callbacks to prevent overfitting.

Parameters:
  • model – Model to be trained

  • checkpoints – Checkpoints to save model

  • epochs – Number of training epochs

  • initial_epoch – Starting epoch number

  • early_stopping – Early stopping callback

  • reduce_lr – Reduce learning rate callback

  • tensorboard – TensorBoard callback

  • history_file – File to save training history

  • model_file – File to save trained model

Returns:

Training history

Return type:

tf.keras.callbacks.History

class focal.DataCollector(csv_path: str, img_folder: str, angle_threshold: float, diameter_threshold: float, classification_type: str | None = 'binary', backbone: str | None = 'mobilenet', set_mask: str | None = 'n', encoder_path: str | None = None)[source]

Bases: object

Class for collecting and preprocessing data from CSV files and image folders.

This class handles loading cleave metadata from CSV files, processing images, and creating TensorFlow datasets for training machine learning models.

create_custom_dataset(image_shape: Tuple[int, int, int], test_size: float = 0.2, buffer_size: int = 32, batch_size: int = 16) Tuple[DatasetV2, DatasetV2][source]

Create datasets using only grayscale images and labels with a custom image shape.

Parameters:
  • image_shape – Desired image shape (height, width, channels)

  • test_size – Fraction of data to use for testing

  • buffer_size – Buffer size for shuffling

  • batch_size – Batch size for training

Returns:

Tuple of (train_ds, test_ds)

create_datasets(images: ndarray, features: ndarray, labels: ndarray, test_size: float, buffer_size: int, batch_size: int, train_p: float, test_p: float, feature_scaler_path: str | None = None) Tuple[DatasetV2, DatasetV2, dict[int, float] | None][source]

Create train and test datasets with feature scaling.

Parameters:
  • images – Array of image paths

  • features – Array of numerical features

  • labels – Array of target labels

  • test_size – Fraction of data to use for testing

  • buffer_size – Buffer size for dataset shuffling

  • batch_size – Batch size for training

  • feature_scaler_path – Optional path to save feature scaler

  • train_p – Masking probability for training.

  • test_p – Masking probability for testing.

Returns:

Tuple of (train_ds, test_ds)

create_kfold_datasets(images: ndarray, features: ndarray, labels: ndarray, buffer_size: int, batch_size: int, train_p: float, test_p: float, n_splits: int = 5) List[Tuple[DatasetV2, DatasetV2]][source]

Create datasets based on stratified k-fold cross validation.

Parameters:
  • images – Array of image paths

  • features – Array of numerical features

  • labels – Array of target labels

  • buffer_size – Buffer size for dataset shuffling

  • batch_size – Batch size for training

  • n_splits – Number of k-fold splits

  • train_p – Masking probability for training

  • test_p – Masking probabilty for testing

Returns:

List of (train_ds, test_ds) tuples for each fold

property df: DataFrame | None

Lazy loading for memory efficiency.

extract_data() Tuple[ndarray, ndarray, ndarray][source]

Extract data from DataFrame into separate arrays for model training.

Returns:

Tuple of (images, features, labels) arrays

get_backbone_preprocessor(backbone: str)[source]

Return the preprocessing function for the specified backbone model.

Parameters:

backbone (str) – Name of the backbone to use. Must be one of: - “mobilenet” - “resnet” - “efficientnet”

Returns:

The preprocess_input function tied to the chosen backbone.

Return type:

Callable

Raises:

ValueError – If backbone is not one of the supported options.

image_only_dataset(original_dataset: DatasetV2) DatasetV2[source]

Convert dataset to image-only format (remove feature inputs).

Parameters:

original_dataset – Original dataset with (image, features) inputs

Returns:

Dataset with only image inputs

Return type:

tf.data.Dataset

load_process_images(filename: str) Tensor[source]

Load and preprocess image from file path.

Parameters:

filename – Image filename or path

Returns:

Preprocessed image tensor

Return type:

tf.Tensor

save_scaler_encoder(obj: object, filepath: str) None[source]

Save a scaler or encoder to disk for future use.

Parameters:
  • filepath – Path to save scaler or encoder

  • obj – Scaler or Encoder object

class focal.GradCAM(model_path: str, image_folder: str, class_index: int | None = 0, backbone: str | None = None, conv_layer_name: str | None = None)[source]

Bases: object

compute_all_heatmaps(save_path: str) None[source]

Computes heatmaps for a number of images.

Parameters:

save_path – path to save the computed heatmap plot

compute_heatmap(image_path: str, title: str, fig_size: List[int]) None[source]

Computes the heatmap for a given image and parameter vector.

Parameters:
  • image (str) – The input image path.

  • title – Title of the plot

  • fig_size – size of each plotted figure

plot_heatmap(title: str, gradcam: Any, img_array: ndarray, fig_size: List[int]) None[source]

Plotting logic for individual heatmap. :param title: Title of indivdual plot :param gradcam: gradcam object :param img_array: array of pixels :param fig_size: size of individual plot

class focal.HyperParameterTuning(image_shape: Tuple[int, int, int], feature_shape: Tuple[int, ...], max_epochs: int = 20, objective: str = 'val_accuracy', directory: str = './tuner_logs', project_name: str = 'Cleave_Tuner', backbone: str | None = 'mobilenet', class_weights: str | None = None)[source]

Bases: object

Class for tuning hyperparameters for the combined CNN+MLP model.

get_best_hyperparameters() object[source]

Get best hyperparameters from hyperparameter search.

Returns:

Best hyperparameters from hyperparameter search

Return type:

keras_tuner.engine.hyperparameters.HyperParameters

get_best_model() Model[source]

Get best model from hyperparameter search.

Returns:

Best model from hyperparameter search

Return type:

tf.keras.Model

Run hyperparameter search.

Parameters:
  • train_ds – tf.data.Dataset - Training dataset

  • test_ds – tf.data.Dataset - Testing dataset

  • max_epochs – maximum number of training epochs

save_best_model(pathname: str) None[source]

Save the best model from hyperparameter search.

Parameters:

pathname – Path where to save the model

tuner

self.tuner = Hyperband( hypermodel, objective=objective, max_epochs=max_epochs, directory=directory,

project_name=project_name )

class focal.ImageHyperparameterTuning(image_shape: Tuple[int, int, int], max_epochs: int = 20, objective: str = 'val_accuracy', directory: str = './tuner_logs', project_name: str = 'CNN_Image_Only', backbone: str | None = 'mobilenet', num_classes: int | None = 5, class_weights: str | None = None)[source]

Bases: HyperParameterTuning

Hyperparameter tuning specifically for image-only models.

tuner

self.tuner = Hyperband( hypermodel, objective=objective, max_epochs=max_epochs, directory=directory,

project_name=project_name )

class focal.ImageOnlyHyperModel(image_shape: Tuple[int, int, int], num_classes: int = 5, backbone: str | None = 'mobilenet', classification_type: str | None = 'binary')[source]

Bases: HyperModel

HyperModel for image-only classification (no numerical parameters).

build(hp)[source]

Build the image-only model with hyperparameters.

Parameters:

hp – Hyperparameters to tune

Returns:

Compiled model

Return type:

tf.keras.Model

class focal.MLPDataCollector(csv_path: str, img_folder: str, angle_threshold: float, diameter_threshold: float, backbone: str | None = None)[source]

Bases: DataCollector

Data collector specifically for MLP regression models.

This class handles data preparation for tension prediction models, including proper scaling of both features and labels.

create_datasets(images: ndarray, features: ndarray, labels: ndarray, test_size: float, buffer_size: int, batch_size: int, feature_scaler_path: str | None = None, tension_scaler_path: str | None = None) Tuple[DatasetV2, DatasetV2][source]

Create train and test datasets for MLP regression with proper scaling.

Parameters:
  • images – Array of image paths

  • features – Array of numerical features

  • labels – Array of tension values

  • test_size – Fraction of data to use for testing

  • buffer_size – Buffer size for dataset shuffling

  • batch_size – Batch size for training

  • feature_scaler_path – Optional path to save feature scaler

  • tension_scaler_path – Optional path to save tension scaler

Returns:

Tuple of (train_ds, test_ds)

create_kfold_datasets(images: ndarray, features: ndarray, labels: ndarray, buffer_size: int, batch_size: int, n_splits: int = 5) Tuple[List[Tuple[DatasetV2, DatasetV2]], MinMaxScaler][source]

Create k-fold datasets for MLP regression with proper scaling.

Parameters:
  • images – Array of image paths

  • features – Array of numerical features

  • labels – Array of tension values

  • buffer_size – Buffer size for dataset shuffling

  • batch_size – Batch size for training

  • n_splits – Number of k-fold splits

Returns:

Tuple of (datasets, label_scaler)

extract_data() Tuple[ndarray, ndarray, ndarray][source]

Extract data for MLP regression (tension prediction).

Returns:

Tuple of (images, features, labels) arrays

class focal.MLPHyperparameterTuning(cnn_path: str, max_epochs: int = 20, objective: str = 'val_mae', directory: str = './tuner_logs', project_name: str = 'MLPTuner', class_weights=None)[source]

Bases: HyperParameterTuning

Hyperparameter tuning specifically for MLP models.

class focal.TensionPredictor(model_path: str, image_folder: str, csv_path: str, angle_threshold: float, diameter_threshold: float, tension_scaler_path: str | None = None)[source]

Bases: object

Predicts tension values using a trained MLP model and preprocessed image/features.

load_and_preprocess_image(file_path: str, img_folder: str) Tensor[source]

Load and preprocess image from file path.

Parameters:
  • file_path (str) – Path to image file.

  • img_folder (str) – Path to image folder.

Returns:

Preprocessed image tensor.

Return type:

tf.Tensor

plot_metric(title: str, X: list[float], y: list[float], x_label: str, y_label: str, x_legend: str, y_legend: str) None[source]

Plot a metric for model evaluation.

Parameters:
  • title (str) – Title of plot.

  • X (list[float]) – List of x values.

  • y (list[float]) – List of y values.

  • x_label (str) – Label for x axis.

  • y_label (str) – Label for y axis.

  • x_legend (str) – Legend for x axis.

  • y_legend (str) – Legend for y axis.

predict()[source]

Run tension predictions on filtered cleave data.

class focal.TestPredictions(model_path: str, csv_path: str, scalar_path: str, img_folder: str, angle_threshold: float, diameter_threshold: float, encoder_path: str | None = None, image_only: bool = False, backbone: str = 'efficientnet', classification_type: str = 'binary', threshold: float | None = 0.5)[source]

Bases: DataCollector

This class is used to test model performance on unseen data using metrics such as accuracy, precision, recall, and confusion matrix.

Supports both image+feature and image-only CNNs.

display_classification_report(true_labels: ndarray, pred_labels: List[int], classification_path: str | None = None) None[source]

Display classification report comparing true labels to predicted labels.

Parameters:
  • true_labels (np.ndarray) – Array of true labels.

  • pred_labels (list[int]) – List of predicted labels.

  • classification_path (str, optional) – Optional path to save classification report.

display_confusion_matrix(true_labels: ndarray, pred_labels: list[int], model_path: str) None[source]

Display confusion matrix comparing true labels to predicted labels.

Parameters:
  • true_labels (np.ndarray) – Array of true labels.

  • pred_labels (list[int]) – List of predicted labels.

gather_predictions() Tuple[ndarray, list, list] | Tuple[None, None, None][source]

Gather multiple predictions from test data.

Returns:

(true_labels, pred_labels, predictions) or (None, None, None) if no data.

Return type:

tuple

plot_roc(title: str, true_labels: ndarray, pred_probabilites: ndarray) None[source]

Plot ROC curve for predictions.

Parameters:
  • title (str) – Title for the plot.

  • true_labels (np.ndarray) – Array of true labels.

  • pred_probabilites (np.ndarray) – Array of predicted probabilities.

test_prediction(image_path: str, feature_vector: ndarray | None = None) ndarray[source]

Generate prediction for a single image (and features if not image_only).

Parameters:
  • image_path (str) – Path to image to predict.

  • feature_vector (np.ndarray | None) – Numerical features (ignored if image_only).

Returns:

Model prediction.

Return type:

np.ndarray

class focal.XGBoostModel(csv_path: str, cnn_model_path: str, train_ds: Any, test_ds: Any)[source]

Bases: object

This class provides basic logic for training the XGBoost regressor.

get_model()[source]
load(model_path: str)[source]

Load model from path.

plot_metrics(title: str, metric1, metric2, metric1_label: str, metric2_label: str, x_label: str, y_label: str) None[source]

Basic plotting function for viewing metrics.

Parameters:
  • title – Title of metric plot

  • metric1 – First metric to plot

  • metric2 – Second metric to plot

  • metric1_label – Metric 1 identifying label

  • metric2_labe – Metric 2 identifying label

  • x_label – X-axis label

  • y-Label – Y_axis label

save(save_path: str) None[source]

Saves xgboost model.

Parameters:

save_path – Path to save model.

Raises:

ValueError – If trained model is None.

train(error_type='reg:squarederror', n_estimators: int | None = 200, learning_rate: float | None = 0.05, max_depth: int | None = 4, random_state: int | None = 42, gamma: float | None = 0.0, subsample: float | None = 1.0, reg_lambda: float | None = 1.0)[source]

Training logic for the xgboost regression model.

Parameters:
  • n_estimators – Maximum number of trees to use during training

  • learning_rate – Learning rate to update weights during training

  • max_depth – Maximum tree depth during training

  • random_state – Controls random state of model to ensure consitency across models

  • gamma – Minimum loss reduction.

  • subsample – Fraction of observations used for each tree.

  • reg_lambda – L2 regularization of leaf nodes.

Returns:

Trained xgboost model

class focal.XGBoostPredictor(csv_path: str, cnn_model_path: str, angle_threshold: float, diameter_threshold: float, xgb_path: str | None = None, scaler_path: str | None = None)[source]

Bases: object

This class implements basic logic for predicting and testing the change in tensions.

load()[source]

Load trained model and scaler.

predict()[source]

Run tension predictions on filtered cleave data.

Subpackages

Submodules