MetaClassifier (starclass.MetaClassifier
)
- class starclass.MetaClassifier(clfile='meta_classifier.pickle', *args, **kwargs)[source]
Bases:
BaseClassifier
The meta-classifier.
- clfile
Path to the file where the classifier is saved.
- Type:
str
- classifier
Actual classifier object.
- Type:
Classifier_obj
- features_used
List of features used for training.
- Type:
list
Code author: James S. Kuszlewicz <kuszlewicz@mps.mpg.de>
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- __init__(clfile='meta_classifier.pickle', *args, **kwargs)[source]
Initialize the classifier object.
- Parameters:
clfile (str) – Filepath to previously pickled Classifier_obj
- build_features_table(features, total=None)[source]
Build table of features.
- Parameters:
features (iterable) – Features to build table from.
total (int, optional) – Number of features in
features
. If not provided, the length offeatures
is found usinglen()
.
- Returns:
Two dimensional float32 ndarray with probabilities from all classifiers.
- Return type:
ndarray
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- 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]
Classify a single lightcurve.
- Parameters:
features (dict) – Dictionary of features.
- Returns:
Dictionary of stellar classifications.
- Return type:
dict
- Raises:
UntrainedClassifierError – If classifier has not been trained.
ValueError – If any features are NaN.
Code author: Rasmus Handberg <rasmush@phys.au.dk>
- 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_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>
- train(tset, savecl=True, overwrite=False)[source]
Train the Meta-classifier.
- Parameters:
tset (
TrainingSet
) – Training set to train classifier on.savecl (bool, optional) – Save the classifier to file?
overwrite (bool, optional) – Overwrite existing classifer save file.
Code author: James S. Kuszlewicz <kuszlewicz@mps.mpg.de>
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
.