XGBClassifier (starclass.XGBClassifier
)
- class starclass.XGBClassifier(clfile='xgb_classifier.json', *args, **kwargs)[source]
Bases:
BaseClassifier
General XGB Classification
Code author: Refilwe Kgoadi <refilwe.kgoadi1@my.jcu.edu.au>
- __init__(clfile='xgb_classifier.json', *args, **kwargs)[source]
Initialize the classifier object with optimised parameters.
- Parameters:
clfile (str) – saved classifier file.
n_estimators (int) – number of boosted trees in the ensemble.
max_depth (int) – maximum depth of each tree in the ensemble.
learning_rate – boosting learning rate.
reg_alpha – L1 regularization on the features.
objective – learning objective of the algorithm.
booster – booster used in the tree.
eval_metric – Evaluation metric.
Code author: Refilwe Kgoadi <refilwe.kgoadi1@my.jcu.edu.au>
- classify(task)
Classify a star from the lightcurve and other features.
Will run the
do_classify()
method and check some of the output and calculate various performance metrics.- Parameters:
features (dict) – Dictionary of features, including the lightcurve itself.
- Returns:
Dictionary of classifications
- Return type:
dict
See also
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- close()
Close the classifier.
- do_classify(features)[source]
My classification that will be run on each lightcurve
- Parameters:
features (dict) – Dictionary of other features.
- Returns:
Dictionary of stellar classifications.
- Return type:
dict
- feature_importance_complete(tset=None, features=None, probs=None, diagnostics=None)
Function which will be called when feature importance is finishing.
- Parameters:
tset
features
probs
diagnostics
See also
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- load(infile)[source]
Load the xgb clasifier.
- Parameters:
infile (str) – Path to file from which to load the trained XGB classifier model.
- load_star(task)
Receive a task from the TaskManager, loads the lightcurve and returns derived features.
- Parameters:
task (dict) – Task dictionary as returned by
TaskManager.get_task()
.- Returns:
Dictionary with features.
- Return type:
dict
See also
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- parse_labels(labels)
Convert iterator of labels into full numpy array, with only one label per star.
TODO: How do we handle multiple labels better?
- test(tset, save=None, feature_importance=False)
Test classifier using training-set, which has been created with a test-fraction.
- Parameters:
tset (
TrainingSet
) – Training-set to run testing on.save (callable, optional) – Function to call for saving test-predictions.
- test_complete(tset=None, features=None, probs=None, diagnostics=None)
Function which will be called when training is finishing.
- Parameters:
tset
features
probs
diagnostics
See also
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- property classifier_model
- property random_seed
Random seed used in derived classifiers.
- property random_state
Random state (
numpy.random.RandomState
) corresponding torandom_seed
.