In [14]:
ModelsDir = '/home/kate/Research/Property/Models/'
ModelName='gamma_tmp'
In [15]:
import pandas as pd
import numpy as np
import pickle
import xgboost as xgb
import math
In [16]:
from sklearn.metrics import mean_absolute_error
def evalerror(preds, dtrain):
    labels = dtrain.get_label()
    return 'mae', mean_absolute_error(preds, labels)
In [17]:
data = pd.read_csv('/home/kate/Research/Property/Data/EDA_Severity_FI_dataset.csv', error_bad_lines=False, index_col=False)
In [18]:
featureset  = [
 'stories', 
 'units', 
 'multipolicyind', 
 'functionalreplacementcost', 
 'landlordind', 
 'burglaryalarmtype', 
 'propertymanager', 
 'gatedcommunityind', 
 'replacementcostdwellingind', 
 'equipmentbreakdown', 
 'cova_deductible', 
 'water_risk_sev_3_blk', 
 'fixture_leak_3_blk', 
 'rep_cost_3_blk', 
 'sqft', 
 'waterded', 
 'constructioncd_encd', 
 'multipolicyindumbrella', 
 'usagetype_encd', 
 'homegardcreditind', 
 'rentersinsurance', 
 'waterdetectiondevice', 
 'safeguardplusind', 
 'deadboltind', 
 'replacementvalueind', 
 'numberoffamilies', 
 'water_risk_fre_3_blk', 
 'pipe_froze_3_blk', 
 'ustructure_fail_3_blk', 
 'customer_cnt_active_policies_binned', 
 'ecy', 
 'yearbuilt', 
 'roofcd_encd', 
 'occupancy_encd', 
 'protectionclass', 
 'fire_risk_model_score', 
 'earthquakeumbrellaind', 
 'ordinanceorlawpct', 
 'sprinklersystem', 
 'firealarmtype', 
 'neighborhoodcrimewatchind', 
 'kitchenfireextinguisherind', 
 'poolind', 
 'serviceline', 
 'cova_limit', 
 'water_risk_3_blk', 
 'appl_fail_3_blk', 
 'plumb_leak_3_blk', 
 'waterh_fail_3_blk'
]
In [19]:
target_column = 'cova_il_nc_water' 
prediction_column = 'pred'
In [20]:
X=data[featureset]
y=data[target_column]
Dtrain = xgb.DMatrix(X.values,y)
In [21]:
nrounds = 600
esr=100
kfold=5
xgb_params = {
    'seed': 42,
    'eta': 0.02, 
    'colsample_bytree': 0.9, 
    'silent': 1,
    'subsample': 0.9,
    'max_depth': 6,
    'gamma': 0.9, 
    'min_child_weight': 4,
    'objective': 'reg:gamma'
}
In [22]:
xgb_model = xgb.train(xgb_params, Dtrain, nrounds, feval=evalerror)
xgb_model_file='%s%s.model'%(ModelsDir,ModelName)
pickle.dump(xgb_model, open(xgb_model_file, 'wb'))
In [23]:
data[prediction_column]=  xgb_model.predict(Dtrain, ntree_limit=xgb_model.best_ntree_limit+50)  
In [24]:
fmap_filename='%s/%s.fmap'%(ModelsDir,ModelName)
outfile = open(fmap_filename, 'w')
for i, feat in enumerate(featureset):
    outfile.write('{0}\t{1}\tq\n'.format(i, feat))
outfile.close()
In [25]:
#feature importance
feat_imp = pd.Series(xgb_model.get_score(fmap=fmap_filename,importance_type='weight')).to_frame()
feat_imp.columns=['Weight']
feat_imp = feat_imp.join(pd.Series(xgb_model.get_score(fmap=fmap_filename,importance_type='gain')).to_frame())
feat_imp.columns=['Weight','Gain']
feat_imp = feat_imp.join(pd.Series(xgb_model.get_score(fmap=fmap_filename,importance_type='cover')).to_frame())
feat_imp.columns=['Weight','Gain','Cover']
#feat_imp['fold']=i
feat_imp['FeatureName'] = feat_imp.index
feat_imp['ModelName'] = ModelName
#feat_imp_all = feat_imp_all.append(feat_imp, ignore_index=True)
feat_imp.sort_values(by=['Gain'], ascending=False)
Out[25]:
Weight Gain Cover FeatureName ModelName
functionalreplacementcost 2 16.000000 1.464015e+08 functionalreplacementcost gamma_tmp
numberoffamilies 3 4.518246 1.112514e+03 numberoffamilies gamma_tmp
units 53 4.493083 1.672204e+07 units gamma_tmp
stories 52 4.419848 2.230910e+07 stories gamma_tmp
cova_deductible 463 4.389974 8.823188e+05 cova_deductible gamma_tmp
replacementvalueind 5 4.347486 1.462596e+03 replacementvalueind gamma_tmp
neighborhoodcrimewatchind 90 3.796316 5.681384e+03 neighborhoodcrimewatchind gamma_tmp
fire_risk_model_score 189 3.772311 5.362348e+03 fire_risk_model_score gamma_tmp
water_risk_sev_3_blk 1200 3.767190 5.402790e+05 water_risk_sev_3_blk gamma_tmp
burglaryalarmtype 26 3.746985 4.303590e+02 burglaryalarmtype gamma_tmp
deadboltind 100 3.721376 9.758553e+03 deadboltind gamma_tmp
waterh_fail_3_blk 199 3.697212 1.637063e+03 waterh_fail_3_blk gamma_tmp
safeguardplusind 85 3.638771 4.144940e+03 safeguardplusind gamma_tmp
equipmentbreakdown 48 3.629159 1.073562e+03 equipmentbreakdown gamma_tmp
cova_limit 309 3.616859 7.850007e+03 cova_limit gamma_tmp
water_risk_3_blk 752 3.564179 2.827695e+03 water_risk_3_blk gamma_tmp
usagetype_encd 61 3.532421 2.229909e+03 usagetype_encd gamma_tmp
multipolicyindumbrella 2 3.495724 4.564441e+03 multipolicyindumbrella gamma_tmp
constructioncd_encd 135 3.418134 4.845767e+03 constructioncd_encd gamma_tmp
replacementcostdwellingind 51 3.343665 1.076930e+03 replacementcostdwellingind gamma_tmp
roofcd_encd 211 3.316613 1.340865e+03 roofcd_encd gamma_tmp
gatedcommunityind 9 3.288508 1.636375e+03 gatedcommunityind gamma_tmp
homegardcreditind 59 3.273190 2.272108e+03 homegardcreditind gamma_tmp
ustructure_fail_3_blk 169 3.250192 2.642660e+03 ustructure_fail_3_blk gamma_tmp
water_risk_fre_3_blk 983 3.239168 3.898432e+04 water_risk_fre_3_blk gamma_tmp
ecy 991 3.194771 5.608527e+04 ecy gamma_tmp
appl_fail_3_blk 166 3.136612 1.051211e+03 appl_fail_3_blk gamma_tmp
pipe_froze_3_blk 147 3.085890 1.614391e+03 pipe_froze_3_blk gamma_tmp
firealarmtype 49 3.065218 2.816969e+02 firealarmtype gamma_tmp
fixture_leak_3_blk 237 3.054127 8.004591e+02 fixture_leak_3_blk gamma_tmp
sqft 632 3.030429 1.689040e+05 sqft gamma_tmp
yearbuilt 1109 2.993038 3.189390e+03 yearbuilt gamma_tmp
customer_cnt_active_policies_binned 73 2.952427 3.114781e+03 customer_cnt_active_policies_binned gamma_tmp
protectionclass 282 2.883158 2.527831e+03 protectionclass gamma_tmp
multipolicyind 85 2.870329 2.729600e+06 multipolicyind gamma_tmp
rep_cost_3_blk 95 2.852325 5.520903e+03 rep_cost_3_blk gamma_tmp
plumb_leak_3_blk 207 2.850293 4.307500e+03 plumb_leak_3_blk gamma_tmp
rentersinsurance 40 2.849397 9.053856e+05 rentersinsurance gamma_tmp
sprinklersystem 6 2.797093 6.085422e+02 sprinklersystem gamma_tmp
kitchenfireextinguisherind 67 2.736327 3.832848e+02 kitchenfireextinguisherind gamma_tmp
poolind 21 2.734698 1.005394e+03 poolind gamma_tmp
landlordind 94 2.710784 3.735012e+03 landlordind gamma_tmp
occupancy_encd 96 2.666661 2.103296e+03 occupancy_encd gamma_tmp
ordinanceorlawpct 159 2.641697 3.074468e+03 ordinanceorlawpct gamma_tmp
waterded 12 2.407402 6.136746e+03 waterded gamma_tmp
serviceline 51 2.316521 1.888864e+03 serviceline gamma_tmp
propertymanager 19 2.299168 2.662099e+03 propertymanager gamma_tmp
earthquakeumbrellaind 15 2.195267 7.637548e+03 earthquakeumbrellaind gamma_tmp
In [26]:
# from https://xiaoxiaowang87.github.io/monotonicity_constraint/
def partial_dependency(model, X,  feature):

    """
    Calculate the dependency (or partial dependency) of a response variable on a predictor (or multiple predictors)
    1. Sample a grid of values of a predictor for numeric continuous or all unique values for categorical or discrete continuous.
    2. For each value, replace every row of that predictor with this value, calculate the average prediction.
    """

    X_temp = X.copy()
    
    if feature in ['sqft','yearbuilt','water_risk_sev_3_blk', 'water_risk_3_blk','water_risk_fre_3_blk','ecy']:
        # continuous
        grid = np.linspace(np.percentile(X_temp[feature], 0.1),
                       np.percentile(X_temp[feature], 99.5),
                       50)
    else:
        #categorical
        grid = X_temp[feature].unique()

    y_pred = np.zeros(len(grid))

    for i, val in enumerate(grid):
        X_temp[feature] = val
        d_temp=xgb.DMatrix(X_temp.values)
        y_pred[i] = np.average(model.predict(d_temp,ntree_limit=model.best_ntree_limit+50))


    return grid, y_pred
In [27]:
pd_features = ['functionalreplacementcost',
'numberoffamilies',
'units',
'stories',
'cova_deductible',
'replacementvalueind',
'neighborhoodcrimewatchind',
'fire_risk_model_score',
'water_risk_sev_3_blk',
'burglaryalarmtype',
'deadboltind',
'waterh_fail_3_blk',
'safeguardplusind',
'equipmentbreakdown',
'cova_limit',
'water_risk_3_blk',
'usagetype_encd',
'multipolicyindumbrella',
'constructioncd_encd',
'replacementcostdwellingind',
'roofcd_encd',
'gatedcommunityind',
'homegardcreditind',
'ustructure_fail_3_blk',
'water_risk_fre_3_blk',
'ecy',
'appl_fail_3_blk',
'pipe_froze_3_blk',
'firealarmtype',
'fixture_leak_3_blk',
'sqft',
'yearbuilt',
'customer_cnt_active_policies_binned',
'protectionclass',
'multipolicyind',
'rep_cost_3_blk',
'plumb_leak_3_blk',
'rentersinsurance',
'sprinklersystem',
'kitchenfireextinguisherind',
'poolind',
'landlordind',
'occupancy_encd',
'ordinanceorlawpct',
'waterded',
'serviceline',
'propertymanager',
'earthquakeumbrellaind'
]
In [28]:
all_fm_pd = pd.DataFrame()
for f in pd_features:
    print('Processing:%s'%f)
    grid, y_pred = partial_dependency(xgb_model,X,f)
    fm_pd=pd.concat([pd.Series(grid), pd.Series(y_pred)], axis=1)
    fm_pd.columns=['value','pd']
    fm_pd['feature']=f
    all_fm_pd=all_fm_pd.append(fm_pd)
    all_fm_pd.to_csv('%s%s_PartialDependency.csv'%(ModelsDir,ModelName),header=True,index=False);
Processing:functionalreplacementcost
Processing:numberoffamilies
Processing:units
Processing:stories
Processing:cova_deductible
Processing:replacementvalueind
Processing:neighborhoodcrimewatchind
Processing:fire_risk_model_score
Processing:water_risk_sev_3_blk
Processing:burglaryalarmtype
Processing:deadboltind
Processing:waterh_fail_3_blk
Processing:safeguardplusind
Processing:equipmentbreakdown
Processing:cova_limit
Processing:water_risk_3_blk
Processing:usagetype_encd
Processing:multipolicyindumbrella
Processing:constructioncd_encd
Processing:replacementcostdwellingind
Processing:roofcd_encd
Processing:gatedcommunityind
Processing:homegardcreditind
Processing:ustructure_fail_3_blk
Processing:water_risk_fre_3_blk
Processing:ecy
Processing:appl_fail_3_blk
Processing:pipe_froze_3_blk
Processing:firealarmtype
Processing:fixture_leak_3_blk
Processing:sqft
Processing:yearbuilt
Processing:customer_cnt_active_policies_binned
Processing:protectionclass
Processing:multipolicyind
Processing:rep_cost_3_blk
Processing:plumb_leak_3_blk
Processing:rentersinsurance
Processing:sprinklersystem
Processing:kitchenfireextinguisherind
Processing:poolind
Processing:landlordind
Processing:occupancy_encd
Processing:ordinanceorlawpct
Processing:waterded
Processing:serviceline
Processing:propertymanager
Processing:earthquakeumbrellaind
In [29]:
%matplotlib inline
In [30]:
for f in pd_features:
    all_fm_pd[all_fm_pd['feature']==f].plot(kind='scatter',x='value', y='pd', title=f)
/home/kate/anaconda/lib/python3.6/site-packages/matplotlib/pyplot.py:537: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
In [31]:
for f in pd_features:
    print(all_fm_pd[all_fm_pd['feature']==f])
   value           pd                    feature
0    0.0  8492.592773  functionalreplacementcost
1    1.0  8492.589844  functionalreplacementcost
   value           pd           feature
0    1.0  8492.752930  numberoffamilies
1    4.0  8487.075195  numberoffamilies
2    3.0  8478.901367  numberoffamilies
3    2.0  8478.901367  numberoffamilies
   value           pd feature
0    1.0  8497.088867   units
1    4.0  8144.883301   units
2    3.0  8156.194336   units
3    2.0  8332.265625   units
   value           pd  feature
0    1.0  8483.548828  stories
1    2.0  8505.031250  stories
2    3.0  8458.759766  stories
     value           pd          feature
0   1000.0  8615.696289  cova_deductible
1    500.0  7751.595703  cova_deductible
2    250.0  7642.566406  cova_deductible
3   2500.0  9159.107422  cova_deductible
4    100.0  7641.805664  cova_deductible
5   5000.0  9234.652344  cova_deductible
6  10000.0  9234.646484  cova_deductible
7   2000.0  8911.544922  cova_deductible
8   7500.0  9234.646484  cova_deductible
   value           pd              feature
0    0.0  8493.489258  replacementvalueind
1    1.0  8456.016602  replacementvalueind
   value           pd                    feature
0    0.0  8514.923828  neighborhoodcrimewatchind
1    1.0  7236.075684  neighborhoodcrimewatchind
    value           pd                feature
0     0.0  8461.205078  fire_risk_model_score
1     2.0  8795.879883  fire_risk_model_score
2     1.0  8483.328125  fire_risk_model_score
3     4.0  8822.990234  fire_risk_model_score
4    -1.0  8364.264648  fire_risk_model_score
5     5.0  8830.449219  fire_risk_model_score
6     3.0  8777.344727  fire_risk_model_score
7     6.0  8849.273438  fire_risk_model_score
8     7.0  8849.273438  fire_risk_model_score
9    12.0  8849.273438  fire_risk_model_score
10   11.0  8849.273438  fire_risk_model_score
         value           pd               feature
0    51.956000  7024.315918  water_risk_sev_3_blk
1    55.344653  7304.024902  water_risk_sev_3_blk
2    58.733306  7304.024902  water_risk_sev_3_blk
3    62.121959  7304.024902  water_risk_sev_3_blk
4    65.510612  7445.099121  water_risk_sev_3_blk
5    68.899265  7481.741211  water_risk_sev_3_blk
6    72.287918  7521.537109  water_risk_sev_3_blk
7    75.676571  7520.557617  water_risk_sev_3_blk
8    79.065224  7534.037598  water_risk_sev_3_blk
9    82.453878  7579.154297  water_risk_sev_3_blk
10   85.842531  7701.488281  water_risk_sev_3_blk
11   89.231184  7714.610352  water_risk_sev_3_blk
12   92.619837  7781.646973  water_risk_sev_3_blk
13   96.008490  7885.678223  water_risk_sev_3_blk
14   99.397143  7931.534668  water_risk_sev_3_blk
15  102.785796  7941.884766  water_risk_sev_3_blk
16  106.174449  7919.162598  water_risk_sev_3_blk
17  109.563102  7949.352539  water_risk_sev_3_blk
18  112.951755  8257.536133  water_risk_sev_3_blk
19  116.340408  8473.297852  water_risk_sev_3_blk
20  119.729061  8633.009766  water_risk_sev_3_blk
21  123.117714  8640.759766  water_risk_sev_3_blk
22  126.506367  8757.593750  water_risk_sev_3_blk
23  129.895020  8771.209961  water_risk_sev_3_blk
24  133.283673  8764.462891  water_risk_sev_3_blk
25  136.672327  8769.904297  water_risk_sev_3_blk
26  140.060980  8766.847656  water_risk_sev_3_blk
27  143.449633  8786.654297  water_risk_sev_3_blk
28  146.838286  8831.890625  water_risk_sev_3_blk
29  150.226939  8840.866211  water_risk_sev_3_blk
30  153.615592  8837.594727  water_risk_sev_3_blk
31  157.004245  8826.704102  water_risk_sev_3_blk
32  160.392898  8791.278320  water_risk_sev_3_blk
33  163.781551  8776.005859  water_risk_sev_3_blk
34  167.170204  8788.850586  water_risk_sev_3_blk
35  170.558857  8771.219727  water_risk_sev_3_blk
36  173.947510  8635.541992  water_risk_sev_3_blk
37  177.336163  8446.182617  water_risk_sev_3_blk
38  180.724816  8434.174805  water_risk_sev_3_blk
39  184.113469  8471.306641  water_risk_sev_3_blk
40  187.502122  8453.906250  water_risk_sev_3_blk
41  190.890776  8440.037109  water_risk_sev_3_blk
42  194.279429  8436.355469  water_risk_sev_3_blk
43  197.668082  8382.309570  water_risk_sev_3_blk
44  201.056735  8341.290039  water_risk_sev_3_blk
45  204.445388  8314.096680  water_risk_sev_3_blk
46  207.834041  7933.520996  water_risk_sev_3_blk
47  211.222694  7901.283203  water_risk_sev_3_blk
48  214.611347  7792.038574  water_risk_sev_3_blk
49  218.000000  7748.852539  water_risk_sev_3_blk
   value           pd            feature
0    0.0  8494.762695  burglaryalarmtype
1    1.0  8488.555664  burglaryalarmtype
   value           pd      feature
0    1.0  8554.587891  deadboltind
1    0.0  8307.191406  deadboltind
   value           pd            feature
0    1.0  8530.165039  waterh_fail_3_blk
1    4.0  8174.417969  waterh_fail_3_blk
2    0.0  8529.366211  waterh_fail_3_blk
3    5.0  8178.131836  waterh_fail_3_blk
4    2.0  8529.666016  waterh_fail_3_blk
5    3.0  8255.002930  waterh_fail_3_blk
   value           pd           feature
0    0.0  8424.227539  safeguardplusind
1    1.0  8581.267578  safeguardplusind
   value           pd             feature
0    0.0  8502.949219  equipmentbreakdown
1    1.0  8382.711914  equipmentbreakdown
        value           pd     feature
0    300000.0  8258.373047  cova_limit
1    200000.0  8215.385742  cova_limit
2    900000.0  8487.606445  cova_limit
3    400000.0  8445.053711  cova_limit
4    500000.0  8564.589844  cova_limit
5    600000.0  8579.848633  cova_limit
6   1200000.0  8317.544922  cova_limit
7    100000.0  8120.736816  cova_limit
8    700000.0  8584.602539  cova_limit
9    800000.0  8539.592773  cova_limit
10  1300000.0  8362.029297  cova_limit
11  1000000.0  8461.880859  cova_limit
         value           pd           feature
0    47.000000  7544.555664  water_risk_3_blk
1    60.861633  7757.417480  water_risk_3_blk
2    74.723265  7728.365234  water_risk_3_blk
3    88.584898  7757.059082  water_risk_3_blk
4   102.446531  7856.661621  water_risk_3_blk
5   116.308163  7929.493164  water_risk_3_blk
6   130.169796  8384.061523  water_risk_3_blk
7   144.031429  8440.071289  water_risk_3_blk
8   157.893061  8510.914062  water_risk_3_blk
9   171.754694  8522.486328  water_risk_3_blk
10  185.616327  8563.892578  water_risk_3_blk
11  199.477959  8532.326172  water_risk_3_blk
12  213.339592  8536.152344  water_risk_3_blk
13  227.201224  8475.797852  water_risk_3_blk
14  241.062857  8388.579102  water_risk_3_blk
15  254.924490  8358.613281  water_risk_3_blk
16  268.786122  8407.258789  water_risk_3_blk
17  282.647755  8418.336914  water_risk_3_blk
18  296.509388  8295.443359  water_risk_3_blk
19  310.371020  8302.099609  water_risk_3_blk
20  324.232653  8419.453125  water_risk_3_blk
21  338.094286  8564.171875  water_risk_3_blk
22  351.955918  8570.822266  water_risk_3_blk
23  365.817551  8570.446289  water_risk_3_blk
24  379.679184  8570.483398  water_risk_3_blk
25  393.540816  8542.517578  water_risk_3_blk
26  407.402449  8566.575195  water_risk_3_blk
27  421.264082  8577.256836  water_risk_3_blk
28  435.125714  8571.329102  water_risk_3_blk
29  448.987347  8570.015625  water_risk_3_blk
30  462.848980  8587.540039  water_risk_3_blk
31  476.710612  8597.290039  water_risk_3_blk
32  490.572245  8584.461914  water_risk_3_blk
33  504.433878  8567.468750  water_risk_3_blk
34  518.295510  8556.303711  water_risk_3_blk
35  532.157143  8541.623047  water_risk_3_blk
36  546.018776  8533.403320  water_risk_3_blk
37  559.880408  8476.096680  water_risk_3_blk
38  573.742041  8384.620117  water_risk_3_blk
39  587.603673  8384.620117  water_risk_3_blk
40  601.465306  8299.949219  water_risk_3_blk
41  615.326939  8241.187500  water_risk_3_blk
42  629.188571  8241.187500  water_risk_3_blk
43  643.050204  8241.187500  water_risk_3_blk
44  656.911837  8241.187500  water_risk_3_blk
45  670.773469  8241.187500  water_risk_3_blk
46  684.635102  8241.187500  water_risk_3_blk
47  698.496735  8241.187500  water_risk_3_blk
48  712.358367  8241.187500  water_risk_3_blk
49  726.220000  8241.187500  water_risk_3_blk
   value           pd         feature
0    6.0  8478.395508  usagetype_encd
1    7.0  8493.944336  usagetype_encd
2    2.0  8436.836914  usagetype_encd
3    3.0  8436.836914  usagetype_encd
4    5.0  8434.756836  usagetype_encd
5    4.0  8436.836914  usagetype_encd
   value           pd                 feature
0    0.0  8492.435547  multipolicyindumbrella
1    1.0  8534.068359  multipolicyindumbrella
   value           pd              feature
0    5.0  8431.171875  constructioncd_encd
1    1.0  8535.299805  constructioncd_encd
2    4.0  8605.019531  constructioncd_encd
3    3.0  8524.183594  constructioncd_encd
4    2.0  8497.114258  constructioncd_encd
   value           pd                     feature
0    1.0  8448.648438  replacementcostdwellingind
1    0.0  8499.214844  replacementcostdwellingind
   value           pd      feature
0    7.0  8507.404297  roofcd_encd
1    8.0  8525.974609  roofcd_encd
2    5.0  8384.458984  roofcd_encd
3    6.0  8373.650391  roofcd_encd
4    1.0  8446.632812  roofcd_encd
5    2.0  8445.070312  roofcd_encd
6    3.0  8389.512695  roofcd_encd
   value           pd            feature
0    0.0  8493.321289  gatedcommunityind
1    1.0  8424.342773  gatedcommunityind
   value           pd            feature
0    0.0  8513.140625  homegardcreditind
1    1.0  8431.197266  homegardcreditind
   value           pd                feature
0    5.0  8458.607422  ustructure_fail_3_blk
1    4.0  8556.288086  ustructure_fail_3_blk
2    2.0  8570.750000  ustructure_fail_3_blk
3    1.0  8556.199219  ustructure_fail_3_blk
4    0.0  8539.087891  ustructure_fail_3_blk
5    3.0  8537.303711  ustructure_fail_3_blk
         value           pd               feature
0    31.956000  6506.258301  water_risk_fre_3_blk
1    44.105878  6475.143066  water_risk_fre_3_blk
2    56.255755  7342.146973  water_risk_fre_3_blk
3    68.405633  8032.358398  water_risk_fre_3_blk
4    80.555510  8570.929688  water_risk_fre_3_blk
5    92.705388  8610.034180  water_risk_fre_3_blk
6   104.855265  8516.573242  water_risk_fre_3_blk
7   117.005143  8526.054688  water_risk_fre_3_blk
8   129.155020  8484.581055  water_risk_fre_3_blk
9   141.304898  8355.494141  water_risk_fre_3_blk
10  153.454776  8385.797852  water_risk_fre_3_blk
11  165.604653  8383.669922  water_risk_fre_3_blk
12  177.754531  8391.249023  water_risk_fre_3_blk
13  189.904408  8399.318359  water_risk_fre_3_blk
14  202.054286  8414.100586  water_risk_fre_3_blk
15  214.204163  8419.252930  water_risk_fre_3_blk
16  226.354041  8407.480469  water_risk_fre_3_blk
17  238.503918  8409.731445  water_risk_fre_3_blk
18  250.653796  8397.877930  water_risk_fre_3_blk
19  262.803673  8228.165039  water_risk_fre_3_blk
20  274.953551  8315.492188  water_risk_fre_3_blk
21  287.103429  8345.490234  water_risk_fre_3_blk
22  299.253306  8363.804688  water_risk_fre_3_blk
23  311.403184  8354.946289  water_risk_fre_3_blk
24  323.553061  8352.285156  water_risk_fre_3_blk
25  335.702939  8352.426758  water_risk_fre_3_blk
26  347.852816  8509.620117  water_risk_fre_3_blk
27  360.002694  8490.800781  water_risk_fre_3_blk
28  372.152571  8533.880859  water_risk_fre_3_blk
29  384.302449  8516.414062  water_risk_fre_3_blk
30  396.452327  8382.408203  water_risk_fre_3_blk
31  408.602204  8495.752930  water_risk_fre_3_blk
32  420.752082  8448.651367  water_risk_fre_3_blk
33  432.901959  8448.651367  water_risk_fre_3_blk
34  445.051837  8316.213867  water_risk_fre_3_blk
35  457.201714  8205.041992  water_risk_fre_3_blk
36  469.351592  8195.436523  water_risk_fre_3_blk
37  481.501469  8207.166016  water_risk_fre_3_blk
38  493.651347  8256.868164  water_risk_fre_3_blk
39  505.801224  8248.364258  water_risk_fre_3_blk
40  517.951102  8226.256836  water_risk_fre_3_blk
41  530.100980  8226.256836  water_risk_fre_3_blk
42  542.250857  8218.577148  water_risk_fre_3_blk
43  554.400735  8089.230957  water_risk_fre_3_blk
44  566.550612  8089.224609  water_risk_fre_3_blk
45  578.700490  8038.321289  water_risk_fre_3_blk
46  590.850367  8038.321289  water_risk_fre_3_blk
47  603.000245  8038.321289  water_risk_fre_3_blk
48  615.150122  8035.307617  water_risk_fre_3_blk
49  627.300000  8030.968262  water_risk_fre_3_blk
       value           pd feature
0   0.027300  7865.873535     ecy
1   0.047080  7912.894531     ecy
2   0.066859  8134.233887     ecy
3   0.086639  7981.893066     ecy
4   0.106418  7982.659668     ecy
5   0.126198  8038.077637     ecy
6   0.145978  8182.745117     ecy
7   0.165757  8244.695312     ecy
8   0.185537  8390.294922     ecy
9   0.205316  8372.963867     ecy
10  0.225096  8435.837891     ecy
11  0.244876  8262.927734     ecy
12  0.264655  8303.532227     ecy
13  0.284435  8362.430664     ecy
14  0.304214  8343.817383     ecy
15  0.323994  8349.582031     ecy
16  0.343773  8358.146484     ecy
17  0.363553  8339.134766     ecy
18  0.383333  8391.514648     ecy
19  0.403112  8397.063477     ecy
20  0.422892  8347.709961     ecy
21  0.442671  8479.197266     ecy
22  0.462451  8535.302734     ecy
23  0.482231  8531.625977     ecy
24  0.502010  8498.373047     ecy
25  0.521790  8366.022461     ecy
26  0.541569  8391.029297     ecy
27  0.561349  8529.246094     ecy
28  0.581129  8532.040039     ecy
29  0.600908  8534.141602     ecy
30  0.620688  8518.823242     ecy
31  0.640467  8521.520508     ecy
32  0.660247  8501.976562     ecy
33  0.680027  8489.493164     ecy
34  0.699806  8484.421875     ecy
35  0.719586  8489.081055     ecy
36  0.739365  8537.859375     ecy
37  0.759145  8608.238281     ecy
38  0.778924  8648.325195     ecy
39  0.798704  8639.369141     ecy
40  0.818484  8636.211914     ecy
41  0.838263  8630.084961     ecy
42  0.858043  8625.457031     ecy
43  0.877822  8637.434570     ecy
44  0.897602  8625.327148     ecy
45  0.917382  8699.918945     ecy
46  0.937161  8647.813477     ecy
47  0.956941  8457.104492     ecy
48  0.976720  8388.023438     ecy
49  0.996500  8373.566406     ecy
   value           pd          feature
0    5.0  8512.766602  appl_fail_3_blk
1    3.0  8459.010742  appl_fail_3_blk
2    1.0  8379.066406  appl_fail_3_blk
3    2.0  8480.463867  appl_fail_3_blk
4    4.0  8464.223633  appl_fail_3_blk
5    0.0  8305.974609  appl_fail_3_blk
   value           pd           feature
0    0.0  8517.274414  pipe_froze_3_blk
1    2.0  8478.609375  pipe_froze_3_blk
2    5.0  8233.500000  pipe_froze_3_blk
3    1.0  8484.154297  pipe_froze_3_blk
4    3.0  8488.708984  pipe_froze_3_blk
5    4.0  8408.938477  pipe_froze_3_blk
   value           pd        feature
0    0.0  8489.390625  firealarmtype
1    1.0  8492.125977  firealarmtype
   value           pd             feature
0    1.0  8465.944336  fixture_leak_3_blk
1    4.0  8351.408203  fixture_leak_3_blk
2    2.0  8518.116211  fixture_leak_3_blk
3    3.0  8489.454102  fixture_leak_3_blk
4    0.0  8472.956055  fixture_leak_3_blk
5    5.0  8334.703125  fixture_leak_3_blk
          value           pd feature
0    800.000000  7421.320312    sqft
1    885.714286  7434.107910    sqft
2    971.428571  7549.191406    sqft
3   1057.142857  7650.645996    sqft
4   1142.857143  7650.560059    sqft
5   1228.571429  8265.697266    sqft
6   1314.285714  8303.266602    sqft
7   1400.000000  8287.720703    sqft
8   1485.714286  8387.248047    sqft
9   1571.428571  8397.619141    sqft
10  1657.142857  8414.733398    sqft
11  1742.857143  8414.410156    sqft
12  1828.571429  8477.270508    sqft
13  1914.285714  8473.690430    sqft
14  2000.000000  8495.481445    sqft
15  2085.714286  8511.971680    sqft
16  2171.428571  8514.208984    sqft
17  2257.142857  8558.699219    sqft
18  2342.857143  8559.269531    sqft
19  2428.571429  8601.259766    sqft
20  2514.285714  8605.108398    sqft
21  2600.000000  8611.489258    sqft
22  2685.714286  8579.750000    sqft
23  2771.428571  8575.750000    sqft
24  2857.142857  8575.549805    sqft
25  2942.857143  8576.724609    sqft
26  3028.571429  8572.069336    sqft
27  3114.285714  8566.916992    sqft
28  3200.000000  8568.771484    sqft
29  3285.714286  8568.574219    sqft
30  3371.428571  8551.900391    sqft
31  3457.142857  8551.900391    sqft
32  3542.857143  8578.856445    sqft
33  3628.571429  8578.856445    sqft
34  3714.285714  8581.020508    sqft
35  3800.000000  8578.604492    sqft
36  3885.714286  8578.604492    sqft
37  3971.428571  8578.604492    sqft
38  4057.142857  8578.604492    sqft
39  4142.857143  8578.604492    sqft
40  4228.571429  8578.688477    sqft
41  4314.285714  8578.688477    sqft
42  4400.000000  8578.688477    sqft
43  4485.714286  8578.688477    sqft
44  4571.428571  8507.444336    sqft
45  4657.142857  8507.444336    sqft
46  4742.857143  8507.444336    sqft
47  4828.571429  8507.444336    sqft
48  4914.285714  8507.444336    sqft
49  5000.000000  8507.444336    sqft
          value           pd    feature
0   1900.000000  6900.436035  yearbuilt
1   1902.346939  6900.436035  yearbuilt
2   1904.693878  6866.835938  yearbuilt
3   1907.040816  6866.835938  yearbuilt
4   1909.387755  6842.509277  yearbuilt
5   1911.734694  6842.509277  yearbuilt
6   1914.081633  7191.683105  yearbuilt
7   1916.428571  7191.683105  yearbuilt
8   1918.775510  7223.943848  yearbuilt
9   1921.122449  7223.943848  yearbuilt
10  1923.469388  7453.063477  yearbuilt
11  1925.816327  7453.063477  yearbuilt
12  1928.163265  7532.257324  yearbuilt
13  1930.510204  7531.466797  yearbuilt
14  1932.857143  7694.676270  yearbuilt
15  1935.204082  7712.775391  yearbuilt
16  1937.551020  7717.756348  yearbuilt
17  1939.897959  7717.756348  yearbuilt
18  1942.244898  7715.589355  yearbuilt
19  1944.591837  7724.029785  yearbuilt
20  1946.938776  7921.907227  yearbuilt
21  1949.285714  7964.643066  yearbuilt
22  1951.632653  7897.146973  yearbuilt
23  1953.979592  8750.357422  yearbuilt
24  1956.326531  8855.816406  yearbuilt
25  1958.673469  8903.099609  yearbuilt
26  1961.020408  8938.388672  yearbuilt
27  1963.367347  8944.510742  yearbuilt
28  1965.714286  8939.580078  yearbuilt
29  1968.061224  8944.030273  yearbuilt
30  1970.408163  8932.170898  yearbuilt
31  1972.755102  8930.420898  yearbuilt
32  1975.102041  8902.553711  yearbuilt
33  1977.448980  8846.190430  yearbuilt
34  1979.795918  8652.162109  yearbuilt
35  1982.142857  8314.684570  yearbuilt
36  1984.489796  8411.171875  yearbuilt
37  1986.836735  8366.744141  yearbuilt
38  1989.183673  8343.843750  yearbuilt
39  1991.530612  8333.457031  yearbuilt
40  1993.877551  8336.818359  yearbuilt
41  1996.224490  8310.616211  yearbuilt
42  1998.571429  8298.776367  yearbuilt
43  2000.918367  8282.718750  yearbuilt
44  2003.265306  8180.345703  yearbuilt
45  2005.612245  8068.573730  yearbuilt
46  2007.959184  8062.375977  yearbuilt
47  2010.306122  7976.051758  yearbuilt
48  2012.653061  7556.921875  yearbuilt
49  2015.000000  7556.921875  yearbuilt
   value           pd                              feature
0    1.0  8514.475586  customer_cnt_active_policies_binned
1   10.0  8318.300781  customer_cnt_active_policies_binned
2   15.0  8257.291016  customer_cnt_active_policies_binned
3   20.0  8257.291016  customer_cnt_active_policies_binned
4   30.0  8257.291016  customer_cnt_active_policies_binned
    value           pd          feature
0     3.0  8473.734375  protectionclass
1     4.0  8501.862305  protectionclass
2     6.0  8486.983398  protectionclass
3     2.0  8514.344727  protectionclass
4     7.0  8279.200195  protectionclass
5     5.0  8425.882812  protectionclass
6     1.0  8346.201172  protectionclass
7     8.0  8250.286133  protectionclass
8     0.0  8318.116211  protectionclass
9    10.0  8250.286133  protectionclass
10    9.0  8250.286133  protectionclass
   value           pd         feature
0    0.0  8499.496094  multipolicyind
1    1.0  8454.563477  multipolicyind
   value           pd         feature
0    4.0  8272.486328  rep_cost_3_blk
1    1.0  7875.243164  rep_cost_3_blk
2    5.0  8506.521484  rep_cost_3_blk
3    3.0  8249.144531  rep_cost_3_blk
4    0.0  7517.165039  rep_cost_3_blk
5    2.0  8227.507812  rep_cost_3_blk
   value           pd           feature
0    5.0  8415.182617  plumb_leak_3_blk
1    4.0  8519.049805  plumb_leak_3_blk
2    1.0  8459.904297  plumb_leak_3_blk
3    3.0  8507.939453  plumb_leak_3_blk
4    2.0  8480.197266  plumb_leak_3_blk
5    0.0  7419.490234  plumb_leak_3_blk
   value           pd           feature
0    0.0  8495.142578  rentersinsurance
1    1.0  8052.348633  rentersinsurance
   value           pd          feature
0    0.0  8493.255859  sprinklersystem
1    1.0  8469.648438  sprinklersystem
   value           pd                     feature
0    1.0  8505.937500  kitchenfireextinguisherind
1    0.0  8479.601562  kitchenfireextinguisherind
   value           pd  feature
0    0.0  8492.480469  poolind
1    1.0  8495.879883  poolind
   value           pd      feature
0    0.0  8510.948242  landlordind
1    1.0  8100.716797  landlordind
   value           pd         feature
0    2.0  8054.671875  occupancy_encd
1    1.0  8509.809570  occupancy_encd
    value           pd            feature
0    10.0  8501.998047  ordinanceorlawpct
1    25.0  8372.366211  ordinanceorlawpct
2     0.0  8506.958008  ordinanceorlawpct
3    20.0  8449.482422  ordinanceorlawpct
4    65.0  7986.954102  ordinanceorlawpct
5    15.0  8476.483398  ordinanceorlawpct
6    90.0  7214.403809  ordinanceorlawpct
7    40.0  8303.697266  ordinanceorlawpct
8    50.0  8242.092773  ordinanceorlawpct
9    75.0  7798.558594  ordinanceorlawpct
10  100.0  7248.769531  ordinanceorlawpct
     value           pd   feature
0      0.0  8493.447266  waterded
1   5000.0  8316.601562  waterded
2   7500.0  8316.601562  waterded
3  10000.0  8316.601562  waterded
   value           pd      feature
0    0.0  8496.472656  serviceline
1    1.0  8395.607422  serviceline
   value           pd          feature
0    0.0  8495.204102  propertymanager
1    1.0  8320.742188  propertymanager
   value           pd                feature
0    0.0  8493.206055  earthquakeumbrellaind
1    1.0  8213.036133  earthquakeumbrellaind