In [1]:
import sys
sys.path.append('/home/jbourbeau/cr-composition')
print('Added to PYTHONPATH')


Added to PYTHONPATH

In [2]:
from __future__ import division
import argparse
from collections import defaultdict
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn.apionly as sns
import scipy.stats as stats

from sklearn.metrics import accuracy_score
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import validation_curve, GridSearchCV, cross_val_score, KFold

import composition as comp

sns.set_palette('muted')
sns.set_color_codes()
%matplotlib inline


/home/jbourbeau/.local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

In [3]:
df, cut_dict = comp.load_sim(return_cut_dict=True)
selection_mask = np.array([True] * len(df))
standard_cut_keys = ['lap_reco_success', 'lap_zenith', 'num_hits_1_30', 'IT_signal',
                     'StationDensity', 'max_qfrac_1_30', 'lap_containment', 'energy_range_lap']
for key in standard_cut_keys:
    selection_mask *= cut_dict[key]

df = df[selection_mask]

feature_list, feature_labels = comp.get_training_features()
print('training features = {}'.format(feature_list))
X_train, X_test, y_train, y_test, le = comp.get_train_test_sets(
    df, feature_list, train_he=True, test_he=True)

print('number training events = ' + str(y_train.shape[0]))
print('number testing events = ' + str(y_test.shape[0]))


/home/jbourbeau/cr-composition/composition/load_sim.py:109: RuntimeWarning: divide by zero encountered in log10
  df['log_NChannels_1_30'] = np.nan_to_num(np.log10(df['NChannels_1_30']))
training features = ['lap_log_energy', 'InIce_log_charge_1_30', 'lap_cos_zenith', 'NChannels_1_30', 'log_s125', 'StationDensity']
number training events = 145932
number testing events = 62543

In [4]:
comp_list = np.unique(df['MC_comp'])
max_depth_list = np.arange(1, 16)
pval_comp = defaultdict(list)
ks_stat = defaultdict(list)
kf = KFold(n_splits=10)
for train_index, test_index in kf.split(X_train):
    X_train_fold, X_test_fold = X_train[train_index], X_train[test_index]
    y_train_fold, y_test_fold = y_train[train_index], y_train[test_index]
    pval_maxdepth = defaultdict(list)
    for max_depth in max_depth_list:
        print('max_depth = {}'.format(max_depth))
        pipeline = comp.get_pipeline('RF')
        pipeline.named_steps['classifier'].set_params(max_depth=max_depth)
        pipeline.fit(X_train_fold, y_train_fold)
        test_probs = pipeline.predict_proba(X_test_fold)
        train_probs = pipeline.predict_proba(X_train_fold)
        for class_ in pipeline.classes_:
            pval_maxdepth[le.inverse_transform(class_)].append(stats.ks_2samp(test_probs[:, class_], train_probs[:, class_])[1])
    for composition in comp_list:
        pval_comp[composition].append(pval_maxdepth[composition])
print(pval_comp)
pval_sys_err = {key: np.std(pval_comp[key], axis=0) for key in pval_comp}
fig, ax = plt.subplots()
for composition in pval:
    ax.errorbar(max_depth_list, pval[composition], yerr=pval_sys_err, linestyle='-.', label=composition)
plt.ylabel('KS-test p-value')
plt.xlabel('Maximum depth')
plt.legend()
plt.grid()
plt.show()


max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
max_depth = 1
max_depth = 2
max_depth = 3
max_depth = 4
max_depth = 5
max_depth = 6
max_depth = 7
max_depth = 8
max_depth = 9
max_depth = 10
max_depth = 11
max_depth = 12
max_depth = 13
max_depth = 14
max_depth = 15
defaultdict(<type 'list'>, {'P': [[0.78277554545624384, 0.74512135532972334, 0.77762801625372147, 0.49703221235570122, 0.78058940472276694, 0.54961000716911024, 0.65748225254073067, 0.80647524623621503, 0.85123065827334254, 0.9540989103031684, 0.87850687641948444, 0.67182037678335516, 0.1914854747217391, 0.010879967713538594, 8.1757486459724147e-06], [0.74109363599688649, 0.77712327038553353, 0.63521606310024636, 0.52788422628376552, 0.22097735778360278, 0.27814401473834638, 0.25161925436476362, 0.19420969673490227, 0.37662884033522082, 0.30241073204710373, 0.43987851727336624, 0.6564928849576569, 0.63643691778014888, 0.03159430860916488, 0.0010699297618879885], [0.97848927310282607, 0.87278976893437199, 0.34213046737953201, 0.31917421578069533, 0.17713532024466494, 0.051632573591179252, 0.11217540574613424, 0.095860581582367807, 0.11422714528556642, 0.075746694027047493, 0.10235862301192657, 0.092231277856207147, 0.016790100462644165, 0.0044291448940033751, 1.0784247741899966e-05], [0.98731777720281211, 0.57729956238586366, 0.46585569764738483, 0.1385238892725886, 0.070184396233174462, 0.015433297560690996, 0.05905082251403921, 0.023412240615325753, 0.024392129092987023, 0.018752256129683911, 0.014152461942360302, 0.014226190678247578, 0.0019898288758910371, 3.5294242769058899e-06, 2.1421548996104643e-11], [0.67864564425539364, 0.86951386513694151, 0.95599569990666844, 0.70643360616061868, 0.80451976137886627, 0.47042500159882628, 0.35091528892160884, 0.38794842802466856, 0.32354993240871155, 0.30363335570474936, 0.24513689423706148, 0.34851582493062089, 0.26575371248633312, 0.034387770500623555, 2.771311179505822e-05], [0.96775379615434953, 0.96958529932000448, 0.4943569995398297, 0.36320408501440166, 0.28764638547432764, 0.26753027068690366, 0.34624669594255103, 0.46536167680372253, 0.43508420919974217, 0.53243657146385326, 0.71821336907656008, 0.71280904894725161, 0.58572196995205172, 0.16538160720380315, 0.0048688084624497804], [0.77230373773632011, 0.75130535107086149, 0.51605951708551834, 0.15215446518797787, 0.5032869899024196, 0.29252482819957987, 0.14024916491750825, 0.1241357637289454, 0.14368856786926609, 0.2448432066572854, 0.26643487002497901, 0.3373375087430443, 0.25271893473194196, 0.007523404608165263, 1.2585542975264548e-05], [0.080299668779393138, 0.41741272033199317, 0.41862404188193941, 0.63336389924938885, 0.75994892231612832, 0.59061540460040096, 0.73247805363098917, 0.35159346699539673, 0.44988591249124937, 0.33159235763255901, 0.21169928395383694, 0.096326633100587811, 0.022857921265772716, 0.001355388187907253, 5.0265590767463189e-07], [0.56825337615063365, 0.5268508393639707, 0.81833865898465785, 0.9787359691904296, 0.78844488815018554, 0.77749861795930919, 0.4806095393604839, 0.66239168915957125, 0.50793711373219397, 0.51767151786932863, 0.7368826785709679, 0.60944561316417178, 0.11953771416730631, 0.014431407785095871, 0.00010970313644695747], [0.79780615037697533, 0.76919378264396054, 0.79073918319071979, 0.78479072786986459, 0.97065985816725908, 0.82293237567701594, 0.91862646994454156, 0.8735633433680825, 0.9117129217374772, 0.73256164619018782, 0.63450676787994242, 0.14479242632730874, 0.089596556879515968, 0.0010570353658370224, 1.1705408471952204e-06]], 'Fe': [[0.9537336910039883, 0.63268571033451659, 0.61568035622449047, 0.61502310989982745, 0.91796851077309516, 0.64054278669207709, 0.69393394144235698, 0.69824020933803665, 0.84931731833127577, 0.79132709451806604, 0.43674785565933177, 0.17810560826637009, 0.098906068802407446, 0.00065606064386744317, 4.1705611891179301e-07], [0.66964028427746725, 0.56009441088041922, 0.53763198903268361, 0.42132412214880027, 0.22360372323133709, 0.15171809099769823, 0.15711078681120286, 0.20447529206509818, 0.27195850508807401, 0.25310229544452262, 0.21460248528703507, 0.076470247894656826, 0.023692806026200334, 0.00041817274121708513, 8.883065247600472e-07], [0.98720861476145949, 0.85414703715553975, 0.70164927285162837, 0.44977753879776861, 0.28973374778100019, 0.5046094340622016, 0.39436780010484734, 0.27390703423061175, 0.32836595662263668, 0.20112982734098647, 0.34152062609756428, 0.38388892048352041, 0.34902943630247274, 0.14059924076771901, 0.0019960193259726321], [0.98647434039533965, 0.46445982967001631, 0.3382960256794888, 0.15139389241900342, 0.093186884365632106, 0.05303494203584011, 0.073768529379319173, 0.044037209117043424, 0.041318082759715775, 0.046395976961613183, 0.056322067615299128, 0.21991810768211109, 0.056783530607103526, 0.033863634888952297, 0.00037388755167783671], [0.76232061941062956, 0.90116616511188052, 0.70628880845779873, 0.64483176136524156, 0.56861587248910905, 0.27449806982441, 0.12183146714852833, 0.20383113445453432, 0.17784291068083072, 0.099554274787535271, 0.19500655003960668, 0.066281628952506125, 0.014149689883677898, 0.0003514172852473466, 3.8508559346073711e-09], [0.9794794562224427, 0.97814943621001016, 0.51641815328839069, 0.78200729189080953, 0.57328573505998737, 0.551724058222966, 0.69047971072444714, 0.56069241930565594, 0.63304399272031209, 0.46373650748306949, 0.28565206044940594, 0.10783627983184824, 0.026313443999425257, 0.0006434910054671049, 5.659015267110473e-07], [0.79014124314057466, 0.69362657256921301, 0.52401149885937348, 0.51711825908858622, 0.31307022696564085, 0.23680941592554033, 0.15014983875968299, 0.060095210927984137, 0.064414765880080618, 0.033254302816204895, 0.033078759112370612, 0.031148629167948201, 0.0015192859822391086, 3.9415361058149796e-05, 1.0626848293965922e-08], [0.0646856194074069, 0.2858440086956241, 0.35881962873800372, 0.47707599574633625, 0.60301376176386501, 0.73541572845797731, 0.28922783835255511, 0.21561042723846829, 0.2378303654280769, 0.25538362738769316, 0.11037468338394194, 0.14412016375584591, 0.11134718373215685, 0.015403460858451606, 0.00014324758559040027], [0.51160590520102245, 0.51596963568572851, 0.86756255837450558, 0.97520490983094488, 0.8918744400164117, 0.62830427982474546, 0.72962370577727276, 0.87022424067300341, 0.73528827155525267, 0.91178521451140426, 0.80450138842415198, 0.85041705307858229, 0.44622852596260049, 0.074400424076494914, 0.00017528993652821486], [0.77463474490539064, 0.74666003829434668, 0.96866066666485529, 0.9691618423463062, 0.9578358794678018, 0.92533408677310902, 0.95012196062425169, 0.92799021959416217, 0.5601853207740739, 0.56447523581799597, 0.56882065831348705, 0.58716361886094315, 0.29524650063606389, 0.0078203548677583442, 8.9387991831241852e-06]], 'O': [[0.33161727239225552, 0.737296629133675, 0.6797758804675289, 0.19962381629541776, 0.61413099576792662, 0.54012450893743069, 0.40825806227339373, 0.41825305985927297, 0.36751116574149578, 0.13864372169012959, 0.024346726462914411, 0.0004027426597974763, 7.4350012983904133e-11, 9.7123280038267771e-23, 1.6659307208262287e-47], [0.99085096546072082, 0.79389928531563181, 0.87735264592852913, 0.71323984520583039, 0.37778328011385925, 0.43371747194825905, 0.62903424834535759, 0.39595552733890488, 0.42226762872802936, 0.11122313841824936, 0.019728646579552086, 7.1994080781439984e-05, 4.5383348824020915e-11, 4.7697838476087756e-23, 4.2268378278846566e-48], [0.94574912503986486, 0.72007763583722284, 0.17042360917709118, 0.20755211523381084, 0.040391488282811312, 0.026651528276972203, 0.058559076943012156, 0.022945959446385628, 0.035374222333937173, 0.083580956357788963, 0.04564961975012042, 0.00026308930502253543, 2.2418981428552454e-11, 2.1727752639074555e-22, 3.0541957757587193e-47], [0.98679220578560622, 0.90891827558748794, 0.24794981880257996, 0.19405681064064376, 0.22566828390678725, 0.11589706945048578, 0.10650496826768785, 0.12517818469840591, 0.22229483525373706, 0.3273057556636752, 0.02168463780799567, 5.4744100148999963e-05, 1.4960173917332762e-09, 1.2162177741058806e-22, 8.284837113872342e-47], [0.63154397319459321, 0.93928971714328724, 0.79746357731454121, 0.89096568527750086, 0.86702802114011601, 0.55070630737043713, 0.26866551070018002, 0.17171122931751173, 0.056371735259059905, 0.05038145467191401, 0.0057498157443756203, 0.00023849813754958543, 2.824078061618872e-10, 6.4150448632879361e-21, 1.5995005939867362e-43], [0.94686877118939705, 0.71662626021509179, 0.21322658338394018, 0.099307091292858279, 0.16620360201026882, 0.1500425585744217, 0.18268303473210323, 0.2542204891167531, 0.33673098112998362, 0.13757200942371384, 0.054653749227151445, 0.00073339285494526836, 3.9395256386057413e-10, 2.2723828189526754e-20, 8.3311151790466098e-42], [0.78058622335524375, 0.7037918337743676, 0.23594210193167478, 0.35910422682095577, 0.31345562680733396, 0.16291260903506349, 0.096012164318947754, 0.1042070459384264, 0.11664132305097792, 0.073452597322540017, 0.026052399081812325, 0.00038210402838004861, 4.7222123319894407e-09, 2.9086127128676134e-20, 1.3764408352251687e-43], [0.024745121744717387, 0.29589409359133911, 0.76638011574587117, 0.69795815617039592, 0.25832829313426459, 0.40685248309841793, 0.73527294058952819, 0.90008640613894397, 0.86539235482258248, 0.91354567317148028, 0.33251509742314861, 0.0025017263971079053, 5.2086179333493006e-08, 2.1885964694189993e-19, 1.7565860249475098e-41], [0.64404333480787179, 0.59855690387633276, 0.61342363602276406, 0.36694903741913543, 0.3354369816105166, 0.4013099418220768, 0.4996088690376343, 0.79537381496093917, 0.83937347283942942, 0.38278587097481759, 0.1026772690579094, 0.0014283903703842477, 6.8765858864103357e-08, 9.0941044025826906e-19, 7.5677703272074918e-42], [0.80181728114315221, 0.68291219741627507, 0.9330707010641639, 0.84036057486371196, 0.93918544570707085, 0.95843489819049377, 0.99359776462426153, 0.98450680349567365, 0.98163625722944514, 0.95964678438826334, 0.39508414971799277, 0.0019327190909365338, 3.7384592275836778e-08, 2.2585012865089599e-17, 5.4086265318489789e-40]], 'He': [[0.42747689517978915, 0.37653285791403085, 0.51278683825232374, 0.78147755697117871, 0.64995831252194902, 0.60214858279215122, 0.47376744184025893, 0.85887322713665959, 0.78901109471096786, 0.54327474040376933, 0.05460376292983618, 0.00038028330670024997, 7.8443066111441337e-09, 2.4829651641526274e-21, 1.1405214971140719e-44], [0.62713901390444793, 0.66633896738535647, 0.52787864135995077, 0.32900360831416947, 0.083025649859823886, 0.23363169773055426, 0.16839898745552651, 0.18390689727766626, 0.086173080128371243, 0.27187905138486523, 0.11872759872667589, 0.00032626615881331311, 6.7148126328754686e-09, 5.4972804998007665e-23, 8.228337745421517e-45], [0.99071272363267815, 0.79155343911538711, 0.30799180318806318, 0.66040356170592074, 0.21442002680777497, 0.41628864724284209, 0.17858282081516913, 0.22252983562848963, 0.18276189512783467, 0.083773633703514386, 0.011796058512760197, 0.00015319159468640825, 1.4096037173132541e-09, 2.2422959695927734e-22, 1.3031774504022478e-46], [0.98092797069700344, 0.44739854086051623, 0.35265792970356119, 0.11338261141511338, 0.086946197150168519, 0.048204570162945846, 0.028591901451545981, 0.050570986553993308, 0.038592136935636713, 0.017507128085164761, 0.0021968722365345431, 2.3956407674033043e-05, 6.3627786322307825e-12, 7.5402626339013704e-24, 1.1100819936520536e-49], [0.68735392027316744, 0.99718296659358763, 0.97515715836462435, 0.60190352993802132, 0.55286728242608019, 0.57318989364575867, 0.2452421023256311, 0.38450509653175052, 0.91586004486924688, 0.52648698079701084, 0.45895543497726571, 0.0032833498862930421, 1.4263756924769137e-07, 1.4946743624889877e-18, 1.0328030413457014e-43], [0.9687711939849496, 0.76138529828611679, 0.55021028074857847, 0.71412278442316646, 0.55023237530791858, 0.33959278838605167, 0.80221489010903158, 0.66435429196537654, 0.4368884846245098, 0.5230555344255452, 0.044360375437434062, 0.00018685304334407367, 3.5483885168244508e-08, 3.2363061826255542e-19, 4.1361553937563499e-42], [0.72585999271694002, 0.77680403050802971, 0.30629322852738522, 0.43280462049105173, 0.2752384674286642, 0.15208718065380106, 0.24339973813050267, 0.29433875324375419, 0.17270739127174703, 0.037068557738303254, 0.010926076355522805, 0.0001595127130080534, 1.9174601918768955e-09, 1.6418415515430131e-22, 3.4449050146487596e-43], [0.081730337589469737, 0.21685212781172045, 0.31723614731556593, 0.56496360670775858, 0.66551744514725952, 0.23958933860477366, 0.34468739869749709, 0.27002106753067262, 0.22042028319961965, 0.12288567803952181, 0.0054875732447387214, 1.0016322378005586e-05, 3.2227709176018395e-10, 1.0843217465686275e-23, 3.7233163323431706e-44], [0.56673844031569875, 0.32497799682375117, 0.97500612210906468, 0.99895062579089988, 0.73371039739922039, 0.70343883075479963, 0.97648334193154218, 0.86569067150429968, 0.93374882414927973, 0.95580326404958349, 0.43081044337546348, 0.0052994184323482459, 6.1435961830347933e-08, 6.7561690291710638e-21, 5.3948879216946043e-42], [0.68086848893360419, 0.73092716084719034, 0.96102685183642467, 0.98982656261162938, 0.94220191158613587, 0.84912644485113831, 0.4633310093004071, 0.30546579667675527, 0.44350146021467984, 0.17489638171374747, 0.013515519968449749, 0.0012501442341803035, 6.1434144944551122e-08, 5.1765672702679086e-19, 5.5073946635135009e-45]]})

In [34]:
comp_list = np.unique(df['MC_comp'])
min_samples_list = np.arange(1, 400, 25)
pval = defaultdict(list)
ks_stat = defaultdict(list)
for min_samples_leaf in min_samples_list:
    print('min_samples_leaf = {}'.format(min_samples_leaf))
    pipeline = comp.get_pipeline('RF')
    params = {'max_depth': 4, 'min_samples_leaf': min_samples_leaf}
    pipeline.named_steps['classifier'].set_params(**params)
    pipeline.fit(X_train, y_train)
    test_probs = pipeline.predict_proba(X_test)
    train_probs = pipeline.predict_proba(X_train)
    for class_ in pipeline.classes_:
        pval[le.inverse_transform(class_)].append(stats.ks_2samp(test_probs[:, class_], train_probs[:, class_])[1])
fig, ax = plt.subplots()
for composition in pval:
    ax.plot(min_samples_list, pval[composition], linestyle='-.', label=composition)
plt.ylabel('KS-test p-value')
plt.xlabel('Minimum samples leaf')
plt.legend()
plt.grid()
plt.show()


min_samples_leaf = 1
min_samples_leaf = 26
min_samples_leaf = 51
min_samples_leaf = 76
min_samples_leaf = 101
min_samples_leaf = 126
min_samples_leaf = 151
min_samples_leaf = 176
min_samples_leaf = 201
min_samples_leaf = 226
min_samples_leaf = 251
min_samples_leaf = 276
min_samples_leaf = 301
min_samples_leaf = 326
min_samples_leaf = 351
min_samples_leaf = 376

In [1]:
comp_list = np.unique(df['MC_comp'])
min_samples_list = [1, 25, 50, 75]
# min_samples_list = [1, 100, 200, 300]
fig, axarr = plt.subplots(2, 2, sharex=True, sharey=True)
for min_samples_leaf, ax in zip(min_samples_list, axarr.flatten()):
    print('min_samples_leaf = {}'.format(min_samples_leaf))
    max_depth_list = np.arange(1, 16)
    pval = defaultdict(list)
    ks_stat = defaultdict(list)
    for max_depth in max_depth_list:
        pipeline = comp.get_pipeline('RF')
        params = {'max_depth': max_depth, 'min_samples_leaf': min_samples_leaf}
        pipeline.named_steps['classifier'].set_params(**params)
        pipeline.fit(X_train, y_train)
        test_probs = pipeline.predict_proba(X_test)
        train_probs = pipeline.predict_proba(X_train)
        for class_ in pipeline.classes_:
            pval[le.inverse_transform(class_)].append(stats.ks_2samp(test_probs[:, class_], train_probs[:, class_])[1])
    for composition in pval:
        ax.plot(max_depth_list, pval[composition], linestyle='-.', label=composition)
    ax.set_ylabel('KS-test p-value')
    ax.set_xlabel('Maximum depth')
    ax.set_title('min samples = {}'.format(min_samples_leaf))
    ax.legend()
    ax.grid()
plt.tight_layout()
plt.show()



NameErrorTraceback (most recent call last)
<ipython-input-1-342867e5349f> in <module>()
----> 1 comp_list = np.unique(df['MC_comp'])
      2 min_samples_list = [1, 25, 50, 75]
      3 # min_samples_list = [1, 100, 200, 300]
      4 fig, axarr = plt.subplots(2, 2, sharex=True, sharey=True)
      5 for min_samples_leaf, ax in zip(min_samples_list, axarr.flatten()):

NameError: name 'np' is not defined

In [ ]: