spacekit.skopes.hst.svm.predict

This module generates predictions using a pre-trained ensemble neural network for unlabeled SVM regression test data and alignment images. The ensemble model is a combination of two neural networks: a MultiLayerPerceptron (for regression test data) and a 3D Image Convolutional Neural Network (CNN). The script includes functions for the following steps:

  1. load and prep the data and images for ML

  2. load the saved model and generate predictions

  3. save predictions and summary statistics to disk

This script (and/or its functions) should be used in conjunction with spacekit.skopes.hst.svm.prep if using raw data (since both the regression test dataframe for MLP and the png images for the CNN need to be created first). Once a model has been trained using the spacekit.skopes.hst.svm.train script, it is saved to disk and can be loaded for use here to generate predictions on unlabeled data.

spacekit.skopes.hst.svm.predict.classification_report(df, output_path, group=None)[source]

Generates a scikit learn classification report with model evaluation metrics and saves to disk.

Parameters:
  • df (Pandas dataframe) – Feature inputs for which the model will generate predictions.

  • output_path (str) – location to store prediction output files

  • group (str, optional) – Name for this group of data (for classification report), e.g. SVM-2021-11-02

spacekit.skopes.hst.svm.predict.classify_alignments(X, model, output_path=None, group=None)[source]

Returns classifier predictions and probability scores

Parameters:
  • X (numpy array) – input features

  • model_path (str, optional) – saved model directory path, by default None

  • output_path (str) – location to store prediction output files

  • group (str, optional) – Name for this group of data (for classification report), e.g. SVM-2021-11-02

Returns:

prediction values, probability scores for target, merged with original input features

Return type:

Pandas dataframe

spacekit.skopes.hst.svm.predict.load_mixed_inputs(data_file, img_path, tx=None, size=128, norm=0)[source]

Load the regression test data and image input data, then stacks the arrays into a single combined input (list) for the ensemble model.

Parameters:
  • data_file (str) – path to preprocessed mosaic data csv file

  • img_path (str) – path to png images parent directory

  • size (int, optional) – image size (width and height), by default 128

Returns:

regression test data (MLP inputs) and image data (CNN inputs) joined as a list

Return type:

list

spacekit.skopes.hst.svm.predict.predict_alignment(data_file, img_path, model_path=None, output_path=None, size=128, norm=0, group=None, extract_to='models')[source]

Main calling function to load the data and model, generate predictions, and save results to disk.

Parameters:
  • data_file (str) – path to preprocessed mosaic data csv file

  • img_path (str) – path to png images parent directory

  • model_path (str, optional) – saved model directory path, by default None

  • output_path (str, optional) – location to store prediction output files, by default None

  • size (int, optional) – image size (width and height), by default None (128)

  • group (str, optional) – Name for this group of data (for classification report), e.g. SVM-2021-11-02