mirapy.classifiers.models

Module Contents

class mirapy.classifiers.models.Classifier

Base class for classification models. It provides general abstract methods required for applying a machine learning techniques.

compile(self, optimizer, loss='mean_squared_error')

Compile model with given configuration.

Parameters
  • optimizer – Instance of optimizer.

  • loss – String (name of loss function) or custom function.

save_model(self, model_name, path='models/')

Saves a model into a H5py file.

Parameters
  • model_name – File name.

  • path – Path of directory.

load_model(self, model_name, path='models/')

Loads a model from a H5py file.

Parameters
  • model_name – File name.

  • path – Pa

train(self, x_train, y_train, epochs, batch_size, reset_weights, class_weight, validation_data, verbose)

Trains the model on the training data with given settings.

Parameters
  • x_train – Numpy array of training data.

  • y_train – Numpy array of target data.

  • epochs – Integer. Number of epochs during training.

  • batch_size – Number of samples per gradient update.

  • reset_weights – Boolean. Set true to reset the weights of model.

  • class_weight – Dictionary. Weights of classes in loss function.

  • validation_data – Numpy array of validation data.

  • verbose – Value is 0, 1, or 2.

predict(self, x)

Predicts the output of the model for the given data as input.

Parameters

x – Input data as Numpy arrays.

plot_history(self)

Plots loss vs epoch graph.

reset(self)

Resets all weights of the model.

class mirapy.classifiers.models.XRayBinaryClassifier(activation='relu')

Bases: mirapy.classifiers.models.Classifier

Classification model for X-Ray Binaries.

Parameters

activation – String (activation function name).

compile(self, optimizer=Adam(lr=0.0001, decay=1e-06), loss='mean_squared_error')

Compile model with given configuration.

Parameters
  • optimizer – Instance of optimizer.

  • loss – String (name of loss function) or custom function.

train(self, x_train, y_train, epochs=50, batch_size=100, reset_weights=True, class_weight=None, validation_data=None, verbose=1)

Trains the model on the training data with given settings.

Parameters
  • x_train – Numpy array of training data.

  • y_train – Numpy array of target data.

  • epochs – Integer. Number of epochs during training.

  • batch_size – Number of samples per gradient update.

  • reset_weights – Boolean. Set true to reset the weights of model.

  • class_weight – Dictionary. Weights of classes in loss function during training.

  • validation_data – Numpy array of validation data.

  • verbose – Value is 0, 1, or 2.

predict(self, x)

Predicts the output of the model for the given data as input.

Parameters

x – Input data as Numpy arrays.

Returns

Predicted class for Input data.

class mirapy.classifiers.models.AtlasVarStarClassifier(activation='relu', input_size=22, num_classes=9)

Bases: mirapy.classifiers.models.Classifier

Classification model for variable star features in ATLAS catalog.

Parameters
  • activation – String (activation function name).

  • input_size – Integer. Dimension of Feature Vector.

  • num_classes – Integer. Number of Classes.

compile(self, optimizer=Adam(lr=0.01, decay=0.01), loss='mean_squared_error')

Compile model with given configuration.

Parameters
  • optimizer – Instance of optimizer.

  • loss – String (name of loss function) or custom function.

train(self, x_train, y_train, epochs=50, batch_size=100, reset_weights=True, class_weight=None, validation_data=None, verbose=1)

Trains the model on the training data with given settings.

Parameters
  • x_train – Numpy array of training data.

  • y_train – Numpy array of target data.

  • epochs – Integer. Number of epochs during training.

  • batch_size – Number of samples per gradient update.

  • reset_weights – Boolean. Set true to reset the weights of model.

  • class_weight – Dictionary. Weights of classes in loss function during training.

  • validation_data – Numpy array of validation data.

  • verbose – Value is 0, 1, or 2.

predict(self, x)

Predicts the output of the model for the given data as input.

Parameters

x – Input data as Numpy arrays.

Returns

Predicted class for Input data.

class mirapy.classifiers.models.OGLEClassifier(activation='relu', input_size=50, num_classes=5)

Bases: mirapy.classifiers.models.Classifier

Feature classification model for OGLE variable star time-series dataset.

Parameters
  • activation – String (activation function name).

  • input_size – Integer. Dimension of Feature Vector.

  • num_classes – Integer. Number of Classes.

compile(self, optimizer='adam', loss='categorical_crossentropy')

Compile model with given configuration.

Parameters
  • optimizer – Instance of optimizer.

  • loss – String (name of loss function) or custom function.

train(self, x_train, y_train, epochs=50, batch_size=100, reset_weights=True, class_weight=None, validation_data=None, verbose=1)

Trains the model on the training data with given settings.

Parameters
  • x_train – Numpy array of training data.

  • y_train – Numpy array of target data.

  • epochs – Integer. Number of epochs during training.

  • batch_size – Number of samples per gradient update.

  • reset_weights – Boolean. Set true to reset the weights of model.

  • class_weight – Dictionary. Weights of classes in loss function.

  • validation_data – Numpy array of validation data.

  • verbose – Value is 0, 1, or 2.

predict(self, x)

Predicts the output of the model for the given data as input.

Parameters

x – Input data as Numpy arrays.

Returns

Predicted class for Input data.

class mirapy.classifiers.models.HTRU1Classifier(input_dim, activation='relu', padding='same', dropout=0.25, num_classes=2)

Bases: mirapy.classifiers.models.Classifier

CNN Classification of pulsars and non-pulsars data released by HTRU survey as Data Release 1. The dataset has same structure as CIFAR-10 dataset.

Parameters
  • input_dim – Set. Dimension of input data.

  • activation – String. Activation function name.

  • padding – Sting. Padding type.

  • dropout – Float between 0 and 1. Dropout value.

  • num_classes – Integer. Number of classes.

compile(self, optimizer, loss='categorical_crossentropy')

Compile model with given configuration.

Parameters
  • optimizer – Instance of optimizer.

  • loss – String (name of loss function) or custom function.

train(self, x_train, y_train, epochs=100, batch_size=32, reset_weights=True, class_weight=None, validation_data=None, verbose=1)
predict(self, x)

Predicts the output of the model for the given data as input.

Parameters

x – Input data as Numpy arrays.

Returns

Predicted class for Input data.