LR Distance Cross-identification

In this notebook we take a logistic regression classifier and swap its distance feature out, comparing the result to multiplying probabilities by a Gaussian.

We'll then try optimising over $\sigma$.


In [5]:
import sys
sys.path.insert(1, '/Users/alger/repos/crowdastro-projects/ATLAS-CDFS/scripts')
import pipeline
import h5py, astropy.io.ascii as asc
import numpy
import scipy.stats

import matplotlib.pyplot as plt
%matplotlib inline

swire_names_cdfs, swire_coords_cdfs, swire_features_cdfs = pipeline.generate_swire_features(field='cdfs')
swire_names_elais, swire_coords_elais, swire_features_elais = pipeline.generate_swire_features(field='elais')
swire_labels_cdfs = pipeline.generate_swire_labels(swire_names_cdfs, swire_coords_cdfs, field='cdfs')
swire_labels_elais = pipeline.generate_swire_labels(swire_names_elais, swire_coords_elais, field='elais')
(atlas_train_sets_cdfs, atlas_test_sets_cdfs), (swire_train_sets_cdfs, swire_test_sets_cdfs) = pipeline.generate_data_sets(swire_coords_cdfs, swire_labels_cdfs, field='cdfs')
(atlas_train_sets_elais, atlas_test_sets_elais), (swire_train_sets_elais, swire_test_sets_elais) = pipeline.generate_data_sets(swire_coords_elais, swire_labels_elais, field='elais')
table = asc.read('/Users/alger/data/Crowdastro/one-table-to-rule-them-all.tbl')

In [2]:
import scipy.spatial

swire_tree = scipy.spatial.KDTree(swire_coords_cdfs)

In [3]:
swire_name_to_index = {j:i for i, j in enumerate(swire_names_cdfs)}

In [29]:
# Distances are normalised and centred. We need to figure out what by.
n_swire = len(swire_features_cdfs)
with h5py.File('/Users/alger/data/Crowdastro/crowdastro-swire.h5', 'r') as crowdastro_f:
    distances = crowdastro_f['/atlas/cdfs/numeric'][:, -n_swire:].min(axis=0)
mean_dist = distances.mean()
distances -= distances.mean()
stdev_dist = distances.std()

In [30]:
import sklearn.ensemble, random, crowdastro.crowd.util, numpy, sklearn.metrics, astropy.coordinates

for quadrant in range(4):
    lr = sklearn.linear_model.LogisticRegression(class_weight='balanced',
                                                 C=100000.0)
    # Train a classifier.
    train = swire_train_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant].nonzero()[0]
    train_features = swire_features_cdfs[train]
    train_labels = swire_labels_cdfs[train, 0]
    test_features = swire_features_cdfs[swire_test_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant]]
    test_labels = swire_labels_cdfs[swire_test_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant], 0]
    lr.fit(train_features, train_labels)

    # Test on the cross-identification task.
    n_total = 0
    n_correct_regular = 0
    n_correct_dist = 0
    n_correct_gaussian = 0
    for atlas in atlas_test_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant].nonzero()[0]:
        row = table[table['Key'] == atlas][0]
        ra = row['Component RA (Franzen)']
        dec = row['Component DEC (Franzen)']
        swire = row['Source SWIRE (Norris)']
        if not swire.startswith('SWIRE'):
            continue
        nearby = swire_tree.query_ball_point(numpy.array([ra, dec]), 1 / 60)
        nearby_features = swire_features_cdfs[nearby]
        if not nearby:
            continue
        atpreds = lr.predict_proba(nearby_features)[:, 1]
        names = [swire_names_cdfs[n] for n in nearby]
        
        # Coordinate setup
        coord_atlas = astropy.coordinates.SkyCoord(ra=ra, dec=dec, unit='deg')
        coords_swire = astropy.coordinates.SkyCoord(ra=swire_coords_cdfs[nearby, 0],
                                                    dec=swire_coords_cdfs[nearby, 1],
                                                    unit='deg')
        separations = numpy.array(coord_atlas.separation(coords_swire).deg)
        
        # Regular
        name = names[numpy.argmax(atpreds)]
        n_correct_regular += name == swire
        
        # Gaussian multiplier
        gaussians = scipy.stats.norm.pdf(separations, scale=1 / 120)
        gaussian_preds = atpreds * gaussians
        name = names[numpy.argmax(gaussian_preds)]
        n_correct_gaussian += name == swire
        
        # Distance substitute
        # We actually need to recompute the predictions for this.
        modified_features = nearby_features.copy()
        # The 10th feature is distance. Replace this by the normalised and centred separations.
        normalised_separations = separations - mean_dist
        normalised_separations /= stdev_dist
        modified_features[:, 9] = normalised_separations
        dist_preds = lr.predict_proba(modified_features)[:, 1]
        name = names[numpy.argmax(dist_preds)]
        n_correct_dist += name == swire
        
        n_total += 1
    print('Regular:', n_correct_regular / n_total)
    print('Gaussian:', n_correct_gaussian / n_total)
    print('Distance:', n_correct_dist / n_total)


Regular: 0.8120805369127517
Gaussian: 0.9328859060402684
Distance: 0.8993288590604027
Regular: 0.825
Gaussian: 0.9416666666666667
Distance: 0.9166666666666666
Regular: 0.8470588235294118
Gaussian: 0.9294117647058824
Distance: 0.9176470588235294
Regular: 0.831858407079646
Gaussian: 0.9380530973451328
Distance: 0.911504424778761

It seems that Gaussian does very well. Now, let's optimise over $\sigma$. We'll do this four times, once for each quadrant, to avoid biasing our tests.


In [ ]:
# Cache the parts of the calculation that never change.
_lrs = {}
_atres = {i:{} for i in range(4)}

In [99]:
def xid_acc(sigma, quadrant):
    if quadrant in _lrs:
        lr = _lrs[quadrant]
    else:
        lr = sklearn.linear_model.LogisticRegression(class_weight='balanced',
                                                     C=100000.0)
        # Train a classifier.
        train = swire_train_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant].nonzero()[0]
        train_features = swire_features_cdfs[train]
        train_labels = swire_labels_cdfs[train, 0]
        test_features = swire_features_cdfs[swire_test_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant]]
        test_labels = swire_labels_cdfs[swire_test_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant], 0]
        lr.fit(train_features, train_labels)
        
        _lrs[quadrant] = lr

    # Test on the cross-identification task
    # Note that we want to test on the *training* set
    # so our parameters aren't influenced by the test data.
    n_total = 0
    n_correct_gaussian = 0
    for atlas in atlas_train_sets_cdfs[:, pipeline.SET_NAMES['RGZ & Norris'], quadrant].nonzero()[0]:
        if atlas in _atres[quadrant]:
            atpreds, names, separations, swire = _atres[quadrant][atlas]
        else:
            row = table[table['Key'] == atlas][0]
            ra = row['Component RA (Franzen)']
            dec = row['Component DEC (Franzen)']
            swire = row['Source SWIRE (Norris)']
            if not swire.startswith('SWIRE'):
                continue
            nearby = swire_tree.query_ball_point(numpy.array([ra, dec]), 1 / 60)
            nearby_features = swire_features_cdfs[nearby]
            if not nearby:
                continue
            atpreds = lr.predict_proba(nearby_features)[:, 1]
            names = [swire_names_cdfs[n] for n in nearby]

            # Coordinate setup
            coord_atlas = astropy.coordinates.SkyCoord(ra=ra, dec=dec, unit='deg')
            coords_swire = astropy.coordinates.SkyCoord(ra=swire_coords_cdfs[nearby, 0],
                                                        dec=swire_coords_cdfs[nearby, 1],
                                                        unit='deg')
            separations = numpy.array(coord_atlas.separation(coords_swire).deg)
            _atres[quadrant][atlas] = (atpreds, names, separations, swire)
        
        # Gaussian multiplier
        gaussians = scipy.stats.norm.pdf(separations, scale=sigma)
        gaussian_preds = atpreds * gaussians
        name = names[numpy.argmax(gaussian_preds)]
        n_correct_gaussian += name == swire
        n_total += 1

    print(sigma, n_correct_gaussian / n_total)
    return n_correct_gaussian / n_total

Let's use hyperopt to optimise $\sigma$. For our prior we'll assume a normal distribution around $\sigma = 1 / 120$.


In [95]:
import hyperopt

In [151]:
trials = {}
for q in range(4):
    trials[q] = hyperopt.Trials()

In [152]:
space = hyperopt.hp.uniform('sigma', 1 / 1000, 1 / 50)

In [153]:
bests = {}
for q in range(4):
    bests[q] = hyperopt.fmin(lambda s: -xid_acc(s, q),
        space=space,
        algo=hyperopt.tpe.suggest,
        max_evals=200,
        trials=trials[q])


0.0032560455353812133 0.9465408805031447
0.00802427395284987 0.9528301886792453
0.011449169234809549 0.9528301886792453
0.013572476092415141 0.9528301886792453
0.013320256747748473 0.9528301886792453
0.009080952833436493 0.949685534591195
0.012932613501220887 0.9528301886792453
0.007021578154404058 0.9528301886792453
0.01832359263706058 0.949685534591195
0.01145002976294927 0.9528301886792453
0.014691091845114555 0.9528301886792453
0.018973971948165514 0.9465408805031447
0.016561639532630786 0.9528301886792453
0.0155058970415024 0.9528301886792453
0.017477301130701027 0.949685534591195
0.01048002656199359 0.949685534591195
0.018609612458078285 0.949685534591195
0.019158751608702302 0.9465408805031447
0.001888829553586474 0.9465408805031447
0.0177755490030734 0.949685534591195
0.00605119663103571 0.9528301886792453
0.015599377307338411 0.9528301886792453
0.015881406498872652 0.9528301886792453
0.014780978888760949 0.9528301886792453
0.019826781913630166 0.9465408805031447
0.016759096576284944 0.9528301886792453
0.013745615171725987 0.9528301886792453
0.015059928348455784 0.9528301886792453
0.005120545124532043 0.949685534591195
0.011243279075758523 0.949685534591195
0.009629571073622344 0.949685534591195
0.012032939944585975 0.9528301886792453
0.007890784521551796 0.9528301886792453
0.0037137181289357566 0.9528301886792453
0.004085391510362446 0.9528301886792453
0.001418933352861371 0.9465408805031447
0.00607128861140242 0.9528301886792453
0.006387189694631256 0.9528301886792453
0.00801260510992267 0.9528301886792453
0.008632720816112053 0.9528301886792453
0.009452699020966846 0.949685534591195
0.004795477520900538 0.9465408805031447
0.002050159842922841 0.9465408805031447
0.012755170806196647 0.9528301886792453
0.01377809873257907 0.9528301886792453
0.008785300837972807 0.9528301886792453
0.016319224105872172 0.9528301886792453
0.014340439997469872 0.9528301886792453
0.017270152570071005 0.949685534591195
0.010357380605858725 0.949685534591195
0.0029252628774746776 0.9465408805031447
0.01658012076959122 0.9528301886792453
0.019823712027907597 0.9465408805031447
0.012069656716894825 0.9528301886792453
0.013421334330603583 0.9528301886792453
0.014784430740700464 0.9528301886792453
0.019257248759392033 0.9465408805031447
0.018021412882544656 0.949685534591195
0.007134315304389311 0.9528301886792453
0.007168912517966437 0.9528301886792453
0.005012075811083901 0.949685534591195
0.014317446393190433 0.9528301886792453
0.016091458901966935 0.9528301886792453
0.011450491123910765 0.9528301886792453
0.012754921089039467 0.9528301886792453
0.007876297556885613 0.9528301886792453
0.012493557422354999 0.9528301886792453
0.004253729545279154 0.949685534591195
0.017031615989347743 0.9528301886792453
0.003115625458610897 0.9465408805031447
0.011072519479154674 0.949685534591195
0.00696441477982273 0.9528301886792453
0.009828945588288993 0.949685534591195
0.014195184932158465 0.9528301886792453
0.005632901123144251 0.9528301886792453
0.0042580252081377 0.949685534591195
0.015417483937317528 0.9528301886792453
0.002342862414191075 0.9465408805031447
0.008101860669660566 0.9528301886792453
0.0012018371218037649 0.9465408805031447
0.008964130011038502 0.949685534591195
0.011715614081881768 0.9528301886792453
0.011942251702345854 0.9528301886792453
0.010188040436172722 0.949685534591195
0.0070328851505467305 0.9528301886792453
0.0038704041001831873 0.9528301886792453
0.0038322102285213732 0.9528301886792453
0.010943299752142761 0.949685534591195
0.013054598812787246 0.9528301886792453
0.006581006233351881 0.9528301886792453
0.005449864493854918 0.9528301886792453
0.00874354506818903 0.9528301886792453
0.010646431782409874 0.949685534591195
0.0024418618693477162 0.9465408805031447
0.006451453124097807 0.9528301886792453
0.01614799630870899 0.9528301886792453
0.018670141486478598 0.949685534591195
0.001682867334391251 0.9465408805031447
0.013452646190141929 0.9528301886792453
0.009306915428528028 0.949685534591195
0.006022410055127546 0.9528301886792453
0.005601851622448618 0.9528301886792453
0.008368376041806784 0.9528301886792453
0.007661518338523859 0.9528301886792453
0.012306222357476268 0.9528301886792453
0.007410553552974217 0.9528301886792453
0.00456713557950176 0.9465408805031447
0.014114010093324239 0.9528301886792453
0.015245541906753335 0.9528301886792453
0.017717351242572392 0.949685534591195
0.016687617417880617 0.9528301886792453
0.015738934837689515 0.9528301886792453
0.015051530905568213 0.9528301886792453
0.019203957455112514 0.9465408805031447
0.010064292852744279 0.949685534591195
0.013118778514273436 0.9528301886792453
0.014671201647918894 0.9528301886792453
0.009224684765824488 0.949685534591195
0.0053718860611443285 0.9528301886792453
0.011616744359920085 0.9528301886792453
0.008446587923347354 0.9528301886792453
0.003354400568611079 0.949685534591195
0.0068888829645110386 0.9528301886792453
0.003314320821269104 0.949685534591195
0.007312663507467129 0.9528301886792453
0.019906618564936564 0.9465408805031447
0.018454819335252417 0.949685534591195
0.009666808296449796 0.949685534591195
0.010809779114116258 0.949685534591195
0.004717110088716864 0.9465408805031447
0.017350686808099012 0.949685534591195
0.008448832093829203 0.9528301886792453
0.0010661910188294551 0.9465408805031447
0.012333961309156248 0.9528301886792453
0.012655172158341143 0.9528301886792453
0.012707014018551207 0.9528301886792453
0.010290876645940937 0.949685534591195
0.013815028227799082 0.9528301886792453
0.006496410028235307 0.9528301886792453
0.011963291463626645 0.9528301886792453
0.011393478466152334 0.9528301886792453
0.01707386976131365 0.9528301886792453
0.01957625602695812 0.9465408805031447
0.009036067781097211 0.949685534591195
0.01558672358087674 0.9528301886792453
0.01497551166931057 0.9528301886792453
0.018007461065780512 0.949685534591195
0.013222426880852397 0.9528301886792453
0.016259380914075732 0.9528301886792453
0.005818469345452427 0.9528301886792453
0.0062420748060827685 0.9528301886792453
0.005756520951874199 0.9528301886792453
0.002254471381838846 0.9465408805031447
0.003599822678687297 0.949685534591195
0.014012279478451281 0.9528301886792453
0.004338752072064007 0.949685534591195
0.01469230362765667 0.9528301886792453
0.007963218263130538 0.9528301886792453
0.007526673075860024 0.9528301886792453
0.005160825727853071 0.9528301886792453
0.005385536123092025 0.9528301886792453
0.0029573562251797103 0.9465408805031447
0.006744904927136619 0.9528301886792453
0.0154030993073166 0.9528301886792453
0.014283632779639524 0.9528301886792453
0.017546222739166045 0.949685534591195
0.011813379170239894 0.9528301886792453
0.009821496642590792 0.949685534591195
0.00873494273690317 0.9528301886792453
0.015893003163598967 0.9528301886792453
0.01651496366190539 0.9528301886792453
0.013399752115465631 0.9528301886792453
0.017971563127438184 0.949685534591195
0.010383516331529489 0.949685534591195
0.013724023448279275 0.9528301886792453
0.013783497533873711 0.9528301886792453
0.002561710313360001 0.9465408805031447
0.01097615551947393 0.949685534591195
0.0017625458226230711 0.9465408805031447
0.007729998002617246 0.9528301886792453
0.00494330400982263 0.9465408805031447
0.016810829324362293 0.9528301886792453
0.008318220936016776 0.9528301886792453
0.011451879490630472 0.9528301886792453
0.009397327563575144 0.949685534591195
0.012258181821336735 0.9528301886792453
0.0065653578631746645 0.9528301886792453
0.018432633321309264 0.949685534591195
0.01886639525103127 0.9465408805031447
0.01940967411719774 0.9465408805031447
0.01684683148520921 0.9528301886792453
0.014372758428627317 0.9528301886792453
0.014995503551962731 0.9528301886792453
0.0058501076297480855 0.9528301886792453
0.006250487295477985 0.9528301886792453
0.014585797493938554 0.9528301886792453
0.01579218996432738 0.9528301886792453
0.015383205293015961 0.9528301886792453
0.016283068687297717 0.9528301886792453
0.016186418487910876 0.9528301886792453
0.018813457817031025 0.9452449567723343
0.003825591570501169 0.9567723342939481
0.012956803911895132 0.9567723342939481
0.00964682281469222 0.9596541786743515
0.00773656695956697 0.9596541786743515
0.002893430848954727 0.9510086455331412
0.012203254653967696 0.9567723342939481
0.006300711309287365 0.9596541786743515
0.01141918447580128 0.9567723342939481
0.016331438616910943 0.9538904899135446
0.003396351587790316 0.9538904899135446
0.01289734402989411 0.9567723342939481
0.0037036432909113314 0.9567723342939481
0.005853329398137479 0.9596541786743515
0.013379688629018272 0.9567723342939481
0.018828687484159112 0.9452449567723343
0.014317793640197488 0.9538904899135446
0.013094153215735607 0.9567723342939481
0.013129704125948799 0.9567723342939481
0.017056398276983045 0.9538904899135446
0.009053517856104736 0.9596541786743515
0.009458349451172417 0.9596541786743515
0.009930104057810677 0.9596541786743515
0.008020468556045407 0.9596541786743515
0.00794380998715074 0.9596541786743515
0.0011578661945193603 0.9423631123919308
0.010555671557212664 0.9567723342939481
0.005801794322205288 0.9596541786743515
0.005512797057199179 0.9567723342939481
0.007708729683292642 0.9596541786743515
0.004827404260683952 0.9567723342939481
0.002085433967768841 0.9481268011527377
0.015026347210387864 0.9538904899135446
0.007096390971120803 0.9596541786743515
0.011295411971423154 0.9567723342939481
0.008557984251306949 0.9596541786743515
0.009039843910394647 0.9596541786743515
0.010926623062900587 0.9567723342939481
0.004569368872970126 0.9567723342939481
0.007140159091946161 0.9596541786743515
0.0019601476050575264 0.9452449567723343
0.004370611950909523 0.9596541786743515
0.006609481026323697 0.9596541786743515
0.012209752731619783 0.9567723342939481
0.009361048590539028 0.9596541786743515
0.019676777678270363 0.9394812680115274
0.01670490902290048 0.9538904899135446
0.012056790470991325 0.9567723342939481
0.009951256130879039 0.9596541786743515
0.014953418914862024 0.9538904899135446
0.0065426434647937355 0.9596541786743515
0.002688527222751858 0.9510086455331412
0.008198221546539907 0.9596541786743515
0.013879739515649223 0.9567723342939481
0.00562883767835402 0.9596541786743515
0.003183780801454148 0.9538904899135446
0.0040232311646019765 0.9567723342939481
0.0012712901986705774 0.9452449567723343
0.005103369213533405 0.9567723342939481
0.007172319059001353 0.9596541786743515
0.010104822020197912 0.9596541786743515
0.012085195174860557 0.9567723342939481
0.015944255807673308 0.9538904899135446
0.017740256250734714 0.9510086455331412
0.002433007390172197 0.9481268011527377
0.004071382313488959 0.9567723342939481
0.00784063780577846 0.9596541786743515
0.008619373047151341 0.9596541786743515
0.010601078092886943 0.9567723342939481
0.008615685855762048 0.9596541786743515
0.006868922509935293 0.9596541786743515
0.006030695330086808 0.9596541786743515
0.003564477356317773 0.9567723342939481
0.009312169029016791 0.9596541786743515
0.005227673110334046 0.9567723342939481
0.00732458486540667 0.9596541786743515
0.012638672047707356 0.9567723342939481
0.011044430514483576 0.9567723342939481
0.011619924447214961 0.9567723342939481
0.006319372834730119 0.9596541786743515
0.007058729695096982 0.9596541786743515
0.004365192404330236 0.9596541786743515
0.0013413828288404376 0.9423631123919308
0.0031392352427201614 0.9538904899135446
0.013702964043848034 0.9567723342939481
0.007533467417924027 0.9596541786743515
0.00855853675238698 0.9596541786743515
0.006497925232010942 0.9596541786743515
0.006459083005152577 0.9596541786743515
0.009032391970230973 0.9596541786743515
0.010209376257736685 0.9596541786743515
0.012657535391712433 0.9567723342939481
0.008165593270544516 0.9596541786743515
0.00438598828064166 0.9596541786743515
0.0017868724776106439 0.9423631123919308
0.005643030603892793 0.9596541786743515
0.005892853911680784 0.9596541786743515
0.014712353509113044 0.9538904899135446
0.011562273295278694 0.9567723342939481
0.002517194271867828 0.9510086455331412
0.0097683595314961 0.9596541786743515
0.0103522995423301 0.9567723342939481
0.0037853107673195144 0.9567723342939481
0.009157819096989803 0.9596541786743515
0.0047908865349754436 0.9567723342939481
0.008286188762293287 0.9596541786743515
0.0029605475755581047 0.9510086455331412
0.007722845185344947 0.9596541786743515
0.005261803103567631 0.9567723342939481
0.0073921909020930555 0.9596541786743515
0.01091498283864207 0.9567723342939481
0.018274001480171616 0.9481268011527377
0.0017942129484407703 0.9423631123919308
0.008910017367381689 0.9596541786743515
0.006804516335531368 0.9596541786743515
0.01570439238560474 0.9538904899135446
0.006198026645845722 0.9596541786743515
0.011826990577662838 0.9567723342939481
0.009469817460098666 0.9596541786743515
0.004789367477665691 0.9567723342939481
0.013484657294554028 0.9567723342939481
0.014153170875718218 0.9538904899135446
0.00995277409468421 0.9596541786743515
0.012475936188047675 0.9567723342939481
0.008655065328042572 0.9596541786743515
0.011159186036933243 0.9567723342939481
0.010731055331754556 0.9567723342939481
0.005918453365114684 0.9596541786743515
0.005183899340995498 0.9567723342939481
0.0034948299401316115 0.9538904899135446
0.013092081431848562 0.9567723342939481
0.007294683557317456 0.9596541786743515
0.01978296578997482 0.9394812680115274
0.007916680882377538 0.9596541786743515
0.009622476618953444 0.9596541786743515
0.004236692926221973 0.9567723342939481
0.006780658588242046 0.9596541786743515
0.005501238339662158 0.9567723342939481
0.003955593970281708 0.9567723342939481
0.0022388780631607402 0.9481268011527377
0.008266777784053797 0.9596541786743515
0.00679790480422424 0.9596541786743515
0.006371804656900226 0.9596541786743515
0.0011561124406505186 0.9423631123919308
0.007478534442356492 0.9596541786743515
0.009810590271425675 0.9596541786743515
0.009947138777139163 0.9596541786743515
0.00909655989509866 0.9596541786743515
0.010505913495963248 0.9567723342939481
0.011311349950455248 0.9567723342939481
0.008388053803007913 0.9596541786743515
0.0045689389749767025 0.9567723342939481
0.007863871780285917 0.9596541786743515
0.010243185005339592 0.9596541786743515
0.012175401377637519 0.9567723342939481
0.011807545912003857 0.9567723342939481
0.005932857762409675 0.9596541786743515
0.007634821282129461 0.9596541786743515
0.007654715947425922 0.9596541786743515
0.002767635501618136 0.9510086455331412
0.008870917614373827 0.9596541786743515
0.009455654691348335 0.9596541786743515
0.01568389744096492 0.9538904899135446
0.003463637126959686 0.9538904899135446
0.005082299011839403 0.9567723342939481
0.010356189179639383 0.9567723342939481
0.00872960345979514 0.9596541786743515
0.008694109635983223 0.9596541786743515
0.007091748575356475 0.9596541786743515
0.006010862823677115 0.9596541786743515
0.006227665466760325 0.9596541786743515
0.00813048252673469 0.9596541786743515
0.007088897908347043 0.9596541786743515
0.01076437024706693 0.9567723342939481
0.013283100891023837 0.9567723342939481
0.00488000747415705 0.9567723342939481
0.005539952789092315 0.9567723342939481
0.0065698947998495405 0.9596541786743515
0.005428605442779299 0.9567723342939481
0.001520053202300583 0.9423631123919308
0.009201282039525012 0.9596541786743515
0.012810846022150253 0.9567723342939481
0.012447779129763376 0.9567723342939481
0.0039951870669956945 0.9567723342939481
0.007288325063019931 0.9596541786743515
0.00939298836299095 0.9596541786743515
0.008038978805073474 0.9596541786743515
0.0029681345538517595 0.9510086455331412
0.011510418589241522 0.9567723342939481
0.017233645695867314 0.9538904899135446
0.006319910193976787 0.9596541786743515
0.014990808200415075 0.9538904899135446
0.004373235768465005 0.9596541786743515
0.014303998323877246 0.9538904899135446
0.009315505392932555 0.9596541786743515
0.011023967149289804 0.9567723342939481
0.012008782425523033 0.9567723342939481
0.009746260851377635 0.9596541786743515
0.0066071578997536975 0.9596541786743515
0.0067242443114010385 0.9596541786743515
0.01645298822998224 0.9502617801047121
0.0084289582095835 0.9607329842931938
0.005471266874018167 0.9581151832460733
0.0118535410922356 0.9581151832460733
0.001159246651860982 0.9450261780104712
0.012099830030707075 0.9581151832460733
0.006380747561706153 0.9607329842931938
0.017222756840673942 0.9502617801047121
0.008931786681900877 0.9607329842931938
0.004245812841891827 0.9554973821989529
0.008370841050898515 0.9607329842931938
0.009312997749822437 0.9607329842931938
0.014788141205565118 0.9554973821989529
0.012183121484951938 0.9581151832460733
0.006896436212720844 0.9607329842931938
0.01558835202380823 0.9554973821989529
0.014477249158986207 0.9554973821989529
0.0023552501416366275 0.9502617801047121
0.01047729855615058 0.9607329842931938
0.013486102566141741 0.9554973821989529
0.019743666909279443 0.9476439790575916
0.007037410239448137 0.9581151832460733
0.0036050140464785963 0.9528795811518325
0.010089382139696432 0.9607329842931938
0.010467661453546303 0.9607329842931938
0.019010318826910493 0.9476439790575916
0.008332023166229555 0.9607329842931938
0.007861080479831917 0.9581151832460733
0.0174642480651992 0.9502617801047121
0.005334883304645082 0.9581151832460733
0.003062358987696627 0.9528795811518325
0.005142397252714126 0.9581151832460733
0.009556269913953601 0.9607329842931938
0.01124606652118756 0.9607329842931938
0.011788536578410527 0.9607329842931938
0.013742809604874947 0.9554973821989529
0.001114119056342188 0.9450261780104712
0.012694693972362366 0.9554973821989529
0.010583685824847864 0.9607329842931938
0.010989061366087712 0.9607329842931938
0.007670323596886835 0.9581151832460733
0.006536509106449904 0.9607329842931938
0.016441257768296448 0.9502617801047121
0.009784282849876452 0.9607329842931938
0.013128969316343837 0.9554973821989529
0.014635431212856067 0.9554973821989529
0.011837295624820547 0.9581151832460733
0.005803639908919651 0.9581151832460733
0.008469661576566511 0.9607329842931938
0.009396739302068092 0.9607329842931938
0.004379107386693645 0.9554973821989529
0.00651420517582241 0.9607329842931938
0.0024954650720049303 0.9502617801047121
0.01587707898622976 0.9554973821989529
0.007508495718827569 0.9581151832460733
0.004462771313283908 0.9554973821989529
0.017172252824681458 0.9502617801047121
0.001939691768013751 0.9502617801047121
0.008602496316199835 0.9607329842931938
0.013817130800828534 0.9554973821989529
0.018642864427933708 0.9476439790575916
0.009763661755092622 0.9607329842931938
0.009676397652579367 0.9607329842931938
0.012447525038334954 0.9581151832460733
0.01529208573535706 0.9554973821989529
0.01105194233105845 0.9607329842931938
0.008930892887216647 0.9607329842931938
0.011149555884668687 0.9607329842931938
0.00578766639466898 0.9581151832460733
0.014178177026043086 0.9554973821989529
0.007885209740665733 0.9581151832460733
0.00697746918541279 0.9607329842931938
0.007152846802690185 0.9581151832460733
0.011799637915353043 0.9607329842931938
0.011606748268836092 0.9607329842931938
0.010408567034467579 0.9607329842931938
0.010512427504216838 0.9607329842931938
0.009085789660860254 0.9607329842931938
0.013207200896733237 0.9554973821989529
0.012775052299093103 0.9554973821989529
0.0064511737378903184 0.9607329842931938
0.004665950549222205 0.9554973821989529
0.0037016722461721144 0.9554973821989529
0.0057856972563130795 0.9581151832460733
0.008085815146033742 0.9581151832460733
0.003118511789300469 0.9528795811518325
0.007321130518588476 0.9581151832460733
0.010033619120609266 0.9607329842931938
0.016596148563845083 0.9502617801047121
0.015063971862108262 0.9554973821989529
0.009013015842836265 0.9607329842931938
0.008292320947705255 0.9607329842931938
0.005254799236907781 0.9581151832460733
0.00489828917244104 0.9581151832460733
0.006130840338654354 0.9581151832460733
0.011446719647991174 0.9607329842931938
0.0015794824128785023 0.9450261780104712
0.012239153077209365 0.9581151832460733
0.008716822158413988 0.9607329842931938
0.014237928162942637 0.9554973821989529
0.01284570917012492 0.9554973821989529
0.0038976019637387005 0.9554973821989529
0.018806735842026138 0.9476439790575916
0.01813156137737346 0.9476439790575916
0.0031933979012136893 0.9554973821989529
0.010902175382264793 0.9607329842931938
0.013479374947283228 0.9554973821989529
0.010149316759246015 0.9607329842931938
0.016319292136087633 0.9502617801047121
0.009388145339074014 0.9607329842931938
0.006776138050600733 0.9607329842931938
0.008244527062598038 0.9607329842931938
0.008372759644831956 0.9607329842931938
0.010749267363817754 0.9607329842931938
0.010912717849725903 0.9607329842931938
0.01979076756636934 0.9476439790575916
0.010171344162343492 0.9607329842931938
0.0025091163081353398 0.9502617801047121
0.0120714878422504 0.9581151832460733
0.00872311690380113 0.9607329842931938
0.008843554365850815 0.9607329842931938
0.007489859174294181 0.9581151832460733
0.004002559613546395 0.9554973821989529
0.013868698480124121 0.9554973821989529
0.015198352804811334 0.9554973821989529
0.009994030832260102 0.9607329842931938
0.01580490451240301 0.9554973821989529
0.006744944769148863 0.9607329842931938
0.011401261895821224 0.9607329842931938
0.008001853808958459 0.9581151832460733
0.005586293879035566 0.9581151832460733
0.01308911760947254 0.9554973821989529
0.012470908144614714 0.9554973821989529
0.010676982031943031 0.9607329842931938
0.006153218791860505 0.9581151832460733
0.011471923311551861 0.9607329842931938
0.006394044917074783 0.9607329842931938
0.009595487694228234 0.9607329842931938
0.004895167385900229 0.9581151832460733
0.014812047375194367 0.9554973821989529
0.01773671928708428 0.9476439790575916
0.01936463679565847 0.9476439790575916
0.007695646805670734 0.9581151832460733
0.012009773112369358 0.9581151832460733
0.01700615477537368 0.9502617801047121
0.009307299520236536 0.9607329842931938
0.01439882133080133 0.9554973821989529
0.009601191271990493 0.9607329842931938
0.009081340880237574 0.9607329842931938
0.007218992785021215 0.9581151832460733
0.011759989327537185 0.9607329842931938
0.010415867475306397 0.9607329842931938
0.01243413542534391 0.9581151832460733
0.013409633546870452 0.9554973821989529
0.008849074674113007 0.9607329842931938
0.008473443459631773 0.9607329842931938
0.0060512217094874894 0.9581151832460733
0.009754874857797406 0.9607329842931938
0.011256399162740804 0.9607329842931938
0.01009074919036901 0.9607329842931938
0.006996507709714528 0.9607329842931938
0.005385420108950754 0.9581151832460733
0.0033748407475937825 0.9554973821989529
0.011684185018973439 0.9607329842931938
0.015684667361336665 0.9554973821989529
0.014143978534658954 0.9554973821989529
0.012648935922850964 0.9554973821989529
0.0019863539595456753 0.9502617801047121
0.010879439396453349 0.9607329842931938
0.004462831599202177 0.9554973821989529
0.01300975755849184 0.9554973821989529
0.013789210267231244 0.9554973821989529
0.009262861347557787 0.9607329842931938
0.0076139449974912754 0.9581151832460733
0.00823605605190187 0.9607329842931938
0.006964527165342595 0.9607329842931938
0.006698079371855881 0.9607329842931938
0.004881482945303199 0.9581151832460733
0.010316812891735031 0.9607329842931938
0.00923215777847426 0.9607329842931938
0.007805648727009966 0.9581151832460733
0.00889571105573143 0.9607329842931938
0.011227274109244924 0.9607329842931938
0.010745857963513428 0.9607329842931938
0.012201537768607301 0.9581151832460733
0.0029212885810799677 0.9528795811518325
0.009864584417891679 0.9607329842931938
0.009851442876624743 0.9607329842931938
0.004279117569586928 0.9554973821989529
0.011407633315266475 0.9607329842931938
0.014701903661957005 0.9554973821989529
0.010536839662926775 0.9607329842931938
0.008638980669739671 0.9607329842931938
0.006063316017593726 0.9581151832460733
0.008104940634026845 0.9581151832460733
0.01619734341188172 0.9554973821989529
0.0074932754426462345 0.9581151832460733
0.006433465589800817 0.9607329842931938
0.005445486215008624 0.9581151832460733
0.01272736250712373 0.9554973821989529
0.010479334282372976 0.963276836158192
0.016210262739582367 0.9519774011299436
0.007571053139671034 0.96045197740113
0.004392617119307294 0.9519774011299436
0.006461025250197164 0.9576271186440678
0.008584473983876906 0.96045197740113
0.003467243186701579 0.9576271186440678
0.016058420218261912 0.9548022598870056
0.006869966325801025 0.96045197740113
0.008993686669290114 0.96045197740113
0.010930779846591885 0.96045197740113
0.0030470335995159263 0.963276836158192
0.019790898188184813 0.9491525423728814
0.004511413365256442 0.9519774011299436
0.007920841330824309 0.96045197740113
0.01963427159129284 0.9491525423728814
0.006098771928106139 0.9576271186440678
0.004665576351909028 0.9519774011299436
0.005744618963188624 0.9576271186440678
0.013258756376054899 0.9548022598870056
0.0017134177369534777 0.9491525423728814
0.0014927507625236715 0.9491525423728814
0.011109370700764749 0.96045197740113
0.01283653481450592 0.9548022598870056
0.016362983181606155 0.9519774011299436
0.013851473675774858 0.9548022598870056
0.018174382413427163 0.9519774011299436
0.0026856935653908776 0.96045197740113
0.009627540667426515 0.96045197740113
0.014743875124049611 0.9548022598870056
0.011429201530557714 0.96045197740113
0.011989867551838469 0.96045197740113
0.009841472386951017 0.96045197740113
0.017612229525509494 0.9519774011299436
0.003446629205319453 0.9576271186440678
0.008026779935050526 0.96045197740113
0.005191601824285862 0.9519774011299436
0.015088279181619358 0.9548022598870056
0.006981719155338519 0.96045197740113
0.010034200997630954 0.96045197740113
0.0023320704866758406 0.9576271186440678
0.003497066294348666 0.9576271186440678
0.00866487240851582 0.96045197740113
0.007191273151987394 0.96045197740113
0.018507847757188493 0.9491525423728814
0.016232044526373352 0.9519774011299436
0.012211566657586454 0.96045197740113
0.0010334108462774615 0.9519774011299436
0.005661830533661343 0.9548022598870056
0.003656374629676905 0.9576271186440678
0.01709764697131394 0.9519774011299436
0.014404701047330703 0.9548022598870056
0.009113131609761897 0.96045197740113
0.007768046741412654 0.96045197740113
0.00623828780040107 0.9576271186440678
0.019993517271911114 0.9491525423728814
0.010560767210031859 0.963276836158192
0.0191372212166876 0.9491525423728814
0.004290434812400666 0.9548022598870056
0.0024445167924583232 0.96045197740113
0.010630122104733778 0.963276836158192
0.013097300049829001 0.9548022598870056
0.011934224869776107 0.96045197740113
0.015619073919067888 0.9548022598870056
0.013653494920634505 0.9548022598870056
0.01048753130641232 0.963276836158192
0.010624340687472188 0.963276836158192
0.012489084206634879 0.9576271186440678
0.011417637279328648 0.96045197740113
0.009270439370221258 0.96045197740113
0.008204854307588116 0.96045197740113
0.010122279759423685 0.96045197740113
0.013942765921499792 0.9548022598870056
0.011105226498360187 0.96045197740113
0.008519114475985369 0.96045197740113
0.006518244695370435 0.9576271186440678
0.007374154268858563 0.96045197740113
0.009594840470469105 0.96045197740113
0.005676950888814376 0.9548022598870056
0.013425192360496701 0.9548022598870056
0.0015377499471614356 0.9491525423728814
0.015252008919931032 0.9548022598870056
0.011660122495726129 0.96045197740113
0.01676304480303671 0.9519774011299436
0.014382201577819676 0.9548022598870056
0.012711170703675168 0.9576271186440678
0.006504789324215509 0.9576271186440678
0.004861185819375285 0.9519774011299436
0.005196410200729783 0.9519774011299436
0.010180735734342368 0.96045197740113
0.003969346661483666 0.9548022598870056
0.010897379039349614 0.96045197740113
0.0027673524833884923 0.96045197740113
0.017645496210974297 0.9519774011299436
0.008522617199922878 0.96045197740113
0.01233414045620946 0.9576271186440678
0.009457109038301032 0.96045197740113
0.008968385813708258 0.96045197740113
0.006889066043474428 0.96045197740113
0.001881830105641618 0.9548022598870056
0.0076974118451073655 0.96045197740113
0.011419187406637494 0.96045197740113
0.010585774603498284 0.963276836158192
0.012942457450355315 0.9548022598870056
0.015868703731287803 0.9548022598870056
0.011807056078354337 0.96045197740113
0.009857900675966572 0.96045197740113
0.014364766399711085 0.9548022598870056
0.008839928485468565 0.96045197740113
0.01392499974496671 0.9548022598870056
0.008036572672778429 0.96045197740113
0.014956683109090537 0.9548022598870056
0.00531298979311358 0.9548022598870056
0.010904631623824367 0.96045197740113
0.007401250065884022 0.96045197740113
0.0060539444685892806 0.9576271186440678
0.0033457413830547773 0.96045197740113
0.013283347077376398 0.9548022598870056
0.018992104974685405 0.9491525423728814
0.004021910918658434 0.9548022598870056
0.016821718540629273 0.9519774011299436
0.010414920131518015 0.963276836158192
0.012158614527488678 0.96045197740113
0.009286264123996576 0.96045197740113
0.015484420924487862 0.9548022598870056
0.0020512453335405152 0.9548022598870056
0.010194075672192287 0.96045197740113
0.0011529594193966642 0.9491525423728814
0.012564943667558812 0.9576271186440678
0.008434486359586544 0.96045197740113
0.014592202569632309 0.9548022598870056
0.01124411073731702 0.96045197740113
0.013550617444271959 0.9548022598870056
0.0070961162257731185 0.96045197740113
0.010420572742188524 0.963276836158192
0.009796203014883686 0.96045197740113
0.01409310685362123 0.9548022598870056
0.01170360171096458 0.96045197740113
0.008154948122911385 0.96045197740113
0.012876430786209064 0.9548022598870056
0.016320474305403287 0.9519774011299436
0.007786630853610846 0.96045197740113
0.00884649856733789 0.96045197740113
0.01804031430679043 0.9519774011299436
0.006259495919617625 0.9576271186440678
0.01059245482226328 0.963276836158192
0.010354721732319487 0.96045197740113
0.010928977859000327 0.96045197740113
0.004815065405284714 0.9519774011299436
0.009827785109499934 0.96045197740113
0.012001663786260653 0.96045197740113
0.009408144919329783 0.96045197740113
0.011450562965904926 0.96045197740113
0.012339769661145842 0.9576271186440678
0.009073551494723558 0.96045197740113
0.013233376981655276 0.9548022598870056
0.00744520553889769 0.96045197740113
0.010989092299583817 0.96045197740113
0.014848792146182122 0.9548022598870056
0.006802085762858796 0.96045197740113
0.008637131903631627 0.96045197740113
0.0033001481179847415 0.96045197740113
0.004449535639813621 0.9519774011299436
0.010775364469333066 0.963276836158192
0.010086273518306354 0.96045197740113
0.011832976132959956 0.96045197740113
0.01364907809248993 0.9548022598870056
0.009529981583766745 0.96045197740113
0.012474378800873386 0.9576271186440678
0.008221480116390009 0.96045197740113
0.011507360902615088 0.96045197740113
0.012831043996654638 0.9548022598870056
0.015374348390094003 0.9548022598870056
0.00551393809964083 0.9548022598870056
0.009104975051135297 0.96045197740113
0.014141553217033092 0.9548022598870056
0.019221710841378692 0.9491525423728814
0.005969640112313798 0.9576271186440678
0.008438315621356236 0.96045197740113
0.011167457235038107 0.96045197740113
0.007676980353400189 0.96045197740113
0.00996953737618145 0.96045197740113
0.006669794380570052 0.96045197740113
0.01574039262396034 0.9548022598870056
0.010349858909607337 0.96045197740113
0.01228736215284824 0.96045197740113
0.013124323224810667 0.9548022598870056
0.00954379144401416 0.96045197740113
0.007011095729006192 0.96045197740113
0.01198798731210506 0.96045197740113
0.010598281859625004 0.963276836158192
0.010904040442122221 0.96045197740113
0.007975697659868528 0.96045197740113
0.008818302285386178 0.96045197740113
0.013614572231681861 0.9548022598870056
0.011505241381333272 0.96045197740113
0.01457063777886819 0.9548022598870056
0.007386832991878104 0.96045197740113
0.012642576683361042 0.9576271186440678
0.009773504721224126 0.96045197740113

In [154]:
[1 / bests[q]['sigma'] for q in range(4)]


Out[154]:
[124.6218668350479, 103.66107258412467, 118.63862355647069, 95.42590903718711]

In [156]:
plt.xlabel('$1/\\sigma$')
plt.ylabel('Accuracy')
for q in range(4):
    plt.scatter(1 / numpy.array(trials[q].vals['sigma']), [-r['loss'] for r in trials[q].results])
plt.yscale('log')
plt.xscale('log')



In [ ]: