Completed
Pull Request — master (#1)
by Andy
01:12
created

AnniesLasso.LassoCannonModel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %
Metric Value
wmc 4
dl 0
loc 62
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A predict() 0 3 1
A fit() 0 3 1
A __init__() 0 2 1
A train() 0 3 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
"""
5
A compressed sensing edition of The Cannon.
6
"""
7
8
from __future__ import (division, print_function, absolute_import,
9
                        unicode_literals)
10
11
__all__ = ["LassoCannonModel"]
12
13
import logging
14
import numpy as np
15
import scipy.optimize as op
16
17
from . import (model, utils)
18
19
logger = logging.getLogger(__name__)
20
21
22
class LassoCannonModel(model.BaseCannonModel):
23
    """
24
    A compressed sensing edition of The Cannon model for the estimation of 
25
    arbitrary stellar labels with regularized complexity.
26
27
    :param labels:
28
        A table with columns as labels, and stars as rows.
29
30
    :type labels:
31
        :class:`~astropy.table.Table` or numpy structured array
32
33
    :param fluxes:
34
        An array of fluxes for stars in the training set, given as shape
35
        `(num_stars, num_pixels)`. The `num_stars` should match the number of
36
        rows in `labels`.
37
38
    :type fluxes:
39
        :class:`np.ndarray`
40
41
    :param flux_uncertainties:
42
        An array of 1-sigma flux uncertainties for stars in the training set,
43
        The shape of the `flux_uncertainties` should match `fluxes`. 
44
45
    :type flux_uncertainties:
46
        :class:`np.ndarray`
47
48
    :param dispersion: [optional]
49
        The dispersion values corresponding to the given pixels. If provided, 
50
        this should have length `num_pixels`.
51
52
    :param live_dangerously: [optional]
53
        If enabled then no checks will be made on the label names, prohibiting
54
        the user to input human-readable forms of the label vector.
55
    """
56
57
    _descriptive_attributes = ["_label_vector"]
58
    _trained_attributes = ["_coefficients", "_scatter"]
59
    _data_attributes = \
60
        ["training_labels", "training_fluxes", "training_flux_uncertainties"]
61
    
62
    def __init__(self, *args, **kwargs):
63
        super(LassoCannonModel, self).__init__(*args, **kwargs)
64
65
66
    # This class has additional attributes.
67
    # label_complexity?
68
    # regularization_behaviour?
69
    # etc...
70
71
    @model.requires_label_vector
72
    def train(self, **kwargs):
73
        raise NotImplementedError
74
75
76
    @model.requires_training_wheels
77
    def predict(self, labels=None, **labels_as_kwargs):
78
        raise NotImplementedError
79
80
81
    @model.requires_training_wheels
82
    def fit(self, fluxes, flux_uncertainties, **kwargs):
83
        raise NotImplementedError
84
85
86