pyROGER.roger
- class pyROGER.roger.RogerModel(x_dataset, y_dataset, ml_models=[KNeighborsClassifier(n_neighbors=63), RandomForestClassifier(max_depth=2, random_state=0), SVC(probability=True)], train_indices=None, test_indices=None, train_percentage=0.75, labels=['CL', 'RIN', 'BS', 'IN', 'ITL'], split_seed=None, comments=None)[source]
Bases:
objectMain class of pyROGER. This object contains all the information of the classification.
- x_dataset
Numpy array containing the features used for the classification. Usually these will be the relative velocity normalized to the velocity dispersion and the normalized radii.
- Type:
np.array
- y_dataset
Numpy array containing the real classes of the galaxies. Usually these are cluster, recent infalling, backsplash, infalling and interloper galaxies.
- Type:
np.array
- ml_models
List with the machine learning methods that will be used. The default methods are KNN, random forest and SVM.
- Type:
list
- train_percentage
Float between 0 and 1 representing the percentage of observations that will be used for training.
- Type:
float
- split_seed
Random seed used for randomly splitting the data. Default = None
- Type:
Int.
- comments
String adding information for the trained model.
- Type:
str
- split()[source]
Split the data into training and testing set. It returns the indices of both sets. It will run when instantiating a RogerModel object.
- predict(data, n_model)
Predict the class of the observation contained in data using the model number n_model.
- confusion_matrix(real_class=None, pred_class=None, pred_prob=None, thresholds=array([0., 0., 0., 0., 0.]), norm=False, n_model=0)[source]
Function for computing the confusion matrix.
- Parameters:
n_model (int) – Number of the machine learning methods that will be used for the classification.
real_class (np.array) – Numpy array containing the real classes. If nothing is pass, the function will use the testset classes.
pred_class (np.array) – Numpy array containing the predicted classes. If nothing is pass, the function will use the classes predicted for the testset.
pred_prob (np.array) – Numpy array containing the predicted probabilities. If nothing is pass, the function will use the pred_class argument.
thresholds (np.array) – Numpy array containing the thresholds that will be use for classifing the galaxies. Default = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
norm (Bool.) – Boolean indicating if the return confusion matrix should be normalized or not. Default = False
- predict_class(data, n_model, verbose=1)[source]
Function for predicting the orbital class.
- Parameters:
data (np.array) – Numpy array containing the features that will be used for the classification.
n_model (int) – Number of the machine learning methods that will be used for the classification.
- Return type:
array- Returns:
Orbital class.
- predict_prob(data, n_model)[source]
Function for predicting the orbital class probability.
- Parameters:
data (np.array) – Numpy array containing the features that will be used for the classification.
n_model (int) – Number of the machine learning methods that will be used for the classification.
- Return type:
array- Returns:
Probability for each galaxy of belonging to each orbital class.