In [1]:
ModelsDir = '/home/kate/Research/Property/Models/'
ModelName='tmp_XGB_Class'
In [2]:
import pandas as pd
import numpy as np
import pickle
import xgboost as xgb
import math
In [3]:
data = pd.read_csv('/home/kate/Research/Property/Data/EDA_FI_dataset.csv', error_bad_lines=False, index_col=False)
In [4]:
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 [5]:
target_column = 'hasclaim'
prediction_column = 'pred'
In [6]:
X=data[featureset]
y=data[target_column]
Dtrain = xgb.DMatrix(X.values,y)
In [7]:
nrounds = 5000
esr=100
kfold=5
xgb_params = {
        'objective': 'binary:logistic',
        'eval_metric': 'auc',
        'silent': True,
        'booster': 'gbtree',
        'seed': 42,
        'scale_pos_weight':0.3,
        'colsample_bylevel': 0.8,
        'colsample_bytree': 0.8,
        'eta': 0.01,
        'max_depth': 6}
In [8]:
xgb_model = xgb.train(xgb_params, Dtrain, nrounds)
xgb_model_file='%s%s.model'%(ModelsDir,ModelName)
pickle.dump(xgb_model, open(xgb_model_file, 'wb'))
In [9]:
data[prediction_column]=  xgb_model.predict(Dtrain, ntree_limit=xgb_model.best_ntree_limit+50)  
In [10]:
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 [11]:
#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[11]:
Weight Gain Cover FeatureName ModelName
usagetype_encd 2665 4.543677 8801.158309 usagetype_encd tmp_XGB_Class
customer_cnt_active_policies_binned 1520 4.192398 2612.005409 customer_cnt_active_policies_binned tmp_XGB_Class
ecy 20424 4.095145 2984.471424 ecy tmp_XGB_Class
cova_deductible 4968 3.714126 3605.500513 cova_deductible tmp_XGB_Class
yearbuilt 16185 2.365337 1699.176706 yearbuilt tmp_XGB_Class
landlordind 454 2.006281 807.152587 landlordind tmp_XGB_Class
pipe_froze_3_blk 3983 1.687517 618.650110 pipe_froze_3_blk tmp_XGB_Class
roofcd_encd 3645 1.625080 898.171355 roofcd_encd tmp_XGB_Class
sqft 11046 1.535138 579.667779 sqft tmp_XGB_Class
firealarmtype 1528 1.492261 777.513049 firealarmtype tmp_XGB_Class
stories 1516 1.372210 485.879269 stories tmp_XGB_Class
equipmentbreakdown 856 1.322345 418.300073 equipmentbreakdown tmp_XGB_Class
cova_limit 6410 1.311486 629.272308 cova_limit tmp_XGB_Class
replacementvalueind 365 1.301134 835.733372 replacementvalueind tmp_XGB_Class
propertymanager 168 1.241164 849.889962 propertymanager tmp_XGB_Class
multipolicyind 1041 1.218538 321.722036 multipolicyind tmp_XGB_Class
poolind 645 1.214443 444.507496 poolind tmp_XGB_Class
replacementcostdwellingind 832 1.194331 276.050745 replacementcostdwellingind tmp_XGB_Class
safeguardplusind 1061 1.175438 294.200178 safeguardplusind tmp_XGB_Class
ustructure_fail_3_blk 2654 1.155200 507.200996 ustructure_fail_3_blk tmp_XGB_Class
water_risk_3_blk 17613 1.153824 992.741093 water_risk_3_blk tmp_XGB_Class
serviceline 586 1.133154 646.167956 serviceline tmp_XGB_Class
protectionclass 4723 1.124646 506.282326 protectionclass tmp_XGB_Class
water_risk_fre_3_blk 16851 1.118500 860.356444 water_risk_fre_3_blk tmp_XGB_Class
rep_cost_3_blk 1085 1.089945 233.513604 rep_cost_3_blk tmp_XGB_Class
waterh_fail_3_blk 3034 1.089490 333.142797 waterh_fail_3_blk tmp_XGB_Class
deadboltind 952 1.085089 207.340833 deadboltind tmp_XGB_Class
homegardcreditind 909 1.084496 333.508509 homegardcreditind tmp_XGB_Class
ordinanceorlawpct 2882 1.069464 401.962206 ordinanceorlawpct tmp_XGB_Class
occupancy_encd 332 1.036220 251.752819 occupancy_encd tmp_XGB_Class
burglaryalarmtype 1436 1.024049 120.678928 burglaryalarmtype tmp_XGB_Class
waterded 383 1.021460 2628.869908 waterded tmp_XGB_Class
plumb_leak_3_blk 2967 1.010072 271.977269 plumb_leak_3_blk tmp_XGB_Class
appl_fail_3_blk 2769 1.009864 234.770934 appl_fail_3_blk tmp_XGB_Class
numberoffamilies 523 0.990639 876.929592 numberoffamilies tmp_XGB_Class
units 794 0.990000 721.721121 units tmp_XGB_Class
water_risk_sev_3_blk 14984 0.984590 768.328194 water_risk_sev_3_blk tmp_XGB_Class
multipolicyindumbrella 150 0.978089 2485.899355 multipolicyindumbrella tmp_XGB_Class
kitchenfireextinguisherind 1184 0.967460 48.544804 kitchenfireextinguisherind tmp_XGB_Class
fixture_leak_3_blk 3747 0.955607 751.968245 fixture_leak_3_blk tmp_XGB_Class
constructioncd_encd 1960 0.945683 506.605280 constructioncd_encd tmp_XGB_Class
fire_risk_model_score 2695 0.935498 895.770378 fire_risk_model_score tmp_XGB_Class
gatedcommunityind 162 0.868234 1399.277593 gatedcommunityind tmp_XGB_Class
sprinklersystem 312 0.864940 764.756986 sprinklersystem tmp_XGB_Class
neighborhoodcrimewatchind 176 0.757932 655.930589 neighborhoodcrimewatchind tmp_XGB_Class
rentersinsurance 107 0.653177 1408.055164 rentersinsurance tmp_XGB_Class
earthquakeumbrellaind 57 0.433011 2301.079988 earthquakeumbrellaind tmp_XGB_Class
functionalreplacementcost 249 0.221680 2891.467366 functionalreplacementcost tmp_XGB_Class
In [14]:
# 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 [15]:
pd_features = [ 'usagetype_encd',
 'customer_cnt_active_policies_binned',
 'ecy',
 'cova_deductible',
 'yearbuilt',
 'landlordind',
 'pipe_froze_3_blk',
 'roofcd_encd',
 'sqft',
 'firealarmtype',
 'stories',
 'equipmentbreakdown',
 'cova_limit',
 'replacementvalueind',
 'propertymanager',
 'multipolicyind',
 'poolind',
 'replacementcostdwellingind',
 'safeguardplusind',
 'ustructure_fail_3_blk',
 'water_risk_3_blk',
 'serviceline',
 'protectionclass',
 'water_risk_fre_3_blk',
 'rep_cost_3_blk',
 'waterh_fail_3_blk',
 'deadboltind',
 'homegardcreditind',
 'ordinanceorlawpct',
 'occupancy_encd',
 'burglaryalarmtype',
 'waterded',
 'plumb_leak_3_blk',
 'appl_fail_3_blk',
 'numberoffamilies',
 'units',
 'water_risk_sev_3_blk',
 'multipolicyindumbrella',
 'kitchenfireextinguisherind',
 'fixture_leak_3_blk',
 'constructioncd_encd',
 'fire_risk_model_score',
 'gatedcommunityind',
 'sprinklersystem',
 'neighborhoodcrimewatchind',
 'rentersinsurance',
 'earthquakeumbrellaind',
 'functionalreplacementcost'
]
In [16]:
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:usagetype_encd
Processing:customer_cnt_active_policies_binned
Processing:ecy
Processing:cova_deductible
Processing:yearbuilt
Processing:landlordind
Processing:pipe_froze_3_blk
Processing:roofcd_encd
Processing:sqft
Processing:firealarmtype
Processing:stories
Processing:equipmentbreakdown
Processing:cova_limit
Processing:replacementvalueind
Processing:propertymanager
Processing:multipolicyind
Processing:poolind
Processing:replacementcostdwellingind
Processing:safeguardplusind
Processing:ustructure_fail_3_blk
Processing:water_risk_3_blk
Processing:serviceline
Processing:protectionclass
Processing:water_risk_fre_3_blk
Processing:rep_cost_3_blk
Processing:waterh_fail_3_blk
Processing:deadboltind
Processing:homegardcreditind
Processing:ordinanceorlawpct
Processing:occupancy_encd
Processing:burglaryalarmtype
Processing:waterded
Processing:plumb_leak_3_blk
Processing:appl_fail_3_blk
Processing:numberoffamilies
Processing:units
Processing:water_risk_sev_3_blk
Processing:multipolicyindumbrella
Processing:kitchenfireextinguisherind
Processing:fixture_leak_3_blk
Processing:constructioncd_encd
Processing:fire_risk_model_score
Processing:gatedcommunityind
Processing:sprinklersystem
Processing:neighborhoodcrimewatchind
Processing:rentersinsurance
Processing:earthquakeumbrellaind
Processing:functionalreplacementcost
In [17]:
%matplotlib inline
In [18]:
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 [19]:
for f in pd_features:
    print(all_fm_pd[all_fm_pd['feature']==f])
   value        pd         feature
0    6.0  0.002502  usagetype_encd
1    3.0  0.002365  usagetype_encd
2    7.0  0.003198  usagetype_encd
3    2.0  0.001376  usagetype_encd
4    4.0  0.000557  usagetype_encd
5    5.0  0.000559  usagetype_encd
6    1.0  0.001376  usagetype_encd
    value        pd                              feature
0     1.0  0.003063  customer_cnt_active_policies_binned
1    10.0  0.002142  customer_cnt_active_policies_binned
2    15.0  0.001193  customer_cnt_active_policies_binned
3    20.0  0.001616  customer_cnt_active_policies_binned
4    30.0  0.001349  customer_cnt_active_policies_binned
5    40.0  0.001349  customer_cnt_active_policies_binned
6   110.0  0.001349  customer_cnt_active_policies_binned
7    70.0  0.001349  customer_cnt_active_policies_binned
8    50.0  0.001349  customer_cnt_active_policies_binned
9   130.0  0.001349  customer_cnt_active_policies_binned
10  150.0  0.001349  customer_cnt_active_policies_binned
11   90.0  0.001349  customer_cnt_active_policies_binned
12  120.0  0.001349  customer_cnt_active_policies_binned
       value        pd feature
0   0.002700  0.000054     ecy
1   0.022927  0.000291     ecy
2   0.043153  0.000235     ecy
3   0.063380  0.000582     ecy
4   0.083606  0.000655     ecy
5   0.103833  0.000763     ecy
6   0.124059  0.000921     ecy
7   0.144286  0.001221     ecy
8   0.164512  0.001018     ecy
9   0.184739  0.001372     ecy
10  0.204965  0.001398     ecy
11  0.225192  0.001382     ecy
12  0.245418  0.001567     ecy
13  0.265645  0.001851     ecy
14  0.285871  0.001904     ecy
15  0.306098  0.001884     ecy
16  0.326324  0.001432     ecy
17  0.346551  0.002042     ecy
18  0.366778  0.002610     ecy
19  0.387004  0.002666     ecy
20  0.407231  0.002805     ecy
21  0.427457  0.002851     ecy
22  0.447684  0.003001     ecy
23  0.467910  0.003095     ecy
24  0.488137  0.003141     ecy
25  0.508363  0.003186     ecy
26  0.528590  0.003067     ecy
27  0.548816  0.003214     ecy
28  0.569043  0.003861     ecy
29  0.589269  0.003947     ecy
30  0.609496  0.004036     ecy
31  0.629722  0.004112     ecy
32  0.649949  0.004025     ecy
33  0.670176  0.004399     ecy
34  0.690402  0.004785     ecy
35  0.710629  0.004775     ecy
36  0.730855  0.004813     ecy
37  0.751082  0.004876     ecy
38  0.771308  0.004979     ecy
39  0.791535  0.004933     ecy
40  0.811761  0.004927     ecy
41  0.831988  0.004938     ecy
42  0.852214  0.005019     ecy
43  0.872441  0.004975     ecy
44  0.892667  0.005171     ecy
45  0.912894  0.005426     ecy
46  0.933120  0.006144     ecy
47  0.953347  0.004632     ecy
48  0.973573  0.006099     ecy
49  0.993800  0.006597     ecy
     value        pd          feature
0    250.0  0.004348  cova_deductible
1    500.0  0.003950  cova_deductible
2   2500.0  0.001813  cova_deductible
3   1000.0  0.003261  cova_deductible
4    100.0  0.005110  cova_deductible
5      0.0  0.005110  cova_deductible
6   5000.0  0.000940  cova_deductible
7  10000.0  0.000374  cova_deductible
8   7500.0  0.000533  cova_deductible
9   2000.0  0.002719  cova_deductible
          value        pd    feature
0   1900.000000  0.001925  yearbuilt
1   1902.428571  0.001925  yearbuilt
2   1904.857143  0.001410  yearbuilt
3   1907.285714  0.001410  yearbuilt
4   1909.714286  0.001383  yearbuilt
5   1912.142857  0.001383  yearbuilt
6   1914.571429  0.001326  yearbuilt
7   1917.000000  0.001326  yearbuilt
8   1919.428571  0.001295  yearbuilt
9   1921.857143  0.001295  yearbuilt
10  1924.285714  0.001636  yearbuilt
11  1926.714286  0.001636  yearbuilt
12  1929.142857  0.001793  yearbuilt
13  1931.571429  0.001793  yearbuilt
14  1934.000000  0.001907  yearbuilt
15  1936.428571  0.001907  yearbuilt
16  1938.857143  0.001822  yearbuilt
17  1941.285714  0.001822  yearbuilt
18  1943.714286  0.001829  yearbuilt
19  1946.142857  0.001817  yearbuilt
20  1948.571429  0.002148  yearbuilt
21  1951.000000  0.002318  yearbuilt
22  1953.428571  0.002379  yearbuilt
23  1955.857143  0.002651  yearbuilt
24  1958.285714  0.002687  yearbuilt
25  1960.714286  0.003236  yearbuilt
26  1963.142857  0.003449  yearbuilt
27  1965.571429  0.003446  yearbuilt
28  1968.000000  0.003268  yearbuilt
29  1970.428571  0.003174  yearbuilt
30  1972.857143  0.003166  yearbuilt
31  1975.285714  0.003150  yearbuilt
32  1977.714286  0.003183  yearbuilt
33  1980.142857  0.003247  yearbuilt
34  1982.571429  0.003273  yearbuilt
35  1985.000000  0.003784  yearbuilt
36  1987.428571  0.003907  yearbuilt
37  1989.857143  0.004105  yearbuilt
38  1992.285714  0.003814  yearbuilt
39  1994.714286  0.003708  yearbuilt
40  1997.142857  0.003458  yearbuilt
41  1999.571429  0.003197  yearbuilt
42  2002.000000  0.002860  yearbuilt
43  2004.428571  0.002254  yearbuilt
44  2006.857143  0.001710  yearbuilt
45  2009.285714  0.001367  yearbuilt
46  2011.714286  0.001367  yearbuilt
47  2014.142857  0.001008  yearbuilt
48  2016.571429  0.001008  yearbuilt
49  2019.000000  0.000587  yearbuilt
   value        pd      feature
0    0.0  0.002966  landlordind
1    1.0  0.002353  landlordind
   value        pd           feature
0    2.0  0.002729  pipe_froze_3_blk
1    0.0  0.003731  pipe_froze_3_blk
2    3.0  0.002838  pipe_froze_3_blk
3    1.0  0.002844  pipe_froze_3_blk
4    4.0  0.002819  pipe_froze_3_blk
5    5.0  0.003006  pipe_froze_3_blk
   value        pd      feature
0    8.0  0.002766  roofcd_encd
1    7.0  0.003098  roofcd_encd
2    6.0  0.003051  roofcd_encd
3    5.0  0.003103  roofcd_encd
4    1.0  0.003069  roofcd_encd
5    2.0  0.003155  roofcd_encd
6    3.0  0.002863  roofcd_encd
          value        pd feature
0    800.000000  0.002181    sqft
1    885.714286  0.002063    sqft
2    971.428571  0.002045    sqft
3   1057.142857  0.002422    sqft
4   1142.857143  0.002422    sqft
5   1228.571429  0.002491    sqft
6   1314.285714  0.002552    sqft
7   1400.000000  0.002510    sqft
8   1485.714286  0.002634    sqft
9   1571.428571  0.002973    sqft
10  1657.142857  0.002933    sqft
11  1742.857143  0.002933    sqft
12  1828.571429  0.002907    sqft
13  1914.285714  0.002947    sqft
14  2000.000000  0.003148    sqft
15  2085.714286  0.003175    sqft
16  2171.428571  0.003171    sqft
17  2257.142857  0.003125    sqft
18  2342.857143  0.003125    sqft
19  2428.571429  0.003192    sqft
20  2514.285714  0.003273    sqft
21  2600.000000  0.003274    sqft
22  2685.714286  0.003275    sqft
23  2771.428571  0.003320    sqft
24  2857.142857  0.003362    sqft
25  2942.857143  0.003362    sqft
26  3028.571429  0.003495    sqft
27  3114.285714  0.003546    sqft
28  3200.000000  0.003620    sqft
29  3285.714286  0.003620    sqft
30  3371.428571  0.003196    sqft
31  3457.142857  0.003196    sqft
32  3542.857143  0.003257    sqft
33  3628.571429  0.003257    sqft
34  3714.285714  0.003257    sqft
35  3800.000000  0.003320    sqft
36  3885.714286  0.003320    sqft
37  3971.428571  0.003320    sqft
38  4057.142857  0.003320    sqft
39  4142.857143  0.003320    sqft
40  4228.571429  0.003320    sqft
41  4314.285714  0.003320    sqft
42  4400.000000  0.003320    sqft
43  4485.714286  0.003320    sqft
44  4571.428571  0.003153    sqft
45  4657.142857  0.003153    sqft
46  4742.857143  0.003153    sqft
47  4828.571429  0.003153    sqft
48  4914.285714  0.003153    sqft
49  5000.000000  0.003153    sqft
   value        pd        feature
0    0.0  0.002725  firealarmtype
1    1.0  0.003069  firealarmtype
   value        pd  feature
0    1.0  0.002865  stories
1    2.0  0.003180  stories
2    3.0  0.002821  stories
   value        pd             feature
0    0.0  0.002882  equipmentbreakdown
1    1.0  0.002933  equipmentbreakdown
        value        pd     feature
0    200000.0  0.002424  cova_limit
1    300000.0  0.002536  cova_limit
2    500000.0  0.003083  cova_limit
3    400000.0  0.002925  cova_limit
4    100000.0  0.003054  cova_limit
5    700000.0  0.003012  cova_limit
6    600000.0  0.003129  cova_limit
7   1300000.0  0.003139  cova_limit
8    900000.0  0.003123  cova_limit
9    800000.0  0.002929  cova_limit
10  1000000.0  0.002975  cova_limit
11  1200000.0  0.003177  cova_limit
   value        pd              feature
0    0.0  0.002938  replacementvalueind
1    1.0  0.003259  replacementvalueind
   value        pd          feature
0    0.0  0.002946  propertymanager
1    1.0  0.002978  propertymanager
   value        pd         feature
0    0.0  0.002985  multipolicyind
1    1.0  0.002803  multipolicyind
   value        pd  feature
0    0.0  0.002953  poolind
1    1.0  0.002868  poolind
   value        pd                     feature
0    1.0  0.002972  replacementcostdwellingind
1    0.0  0.002925  replacementcostdwellingind
   value        pd           feature
0    0.0  0.003002  safeguardplusind
1    1.0  0.002860  safeguardplusind
   value        pd                feature
0    5.0  0.002876  ustructure_fail_3_blk
1    3.0  0.002986  ustructure_fail_3_blk
2    1.0  0.003115  ustructure_fail_3_blk
3    4.0  0.003024  ustructure_fail_3_blk
4    2.0  0.003349  ustructure_fail_3_blk
5    0.0  0.002899  ustructure_fail_3_blk
         value        pd           feature
0    40.000000  0.000856  water_risk_3_blk
1    53.061224  0.001985  water_risk_3_blk
2    66.122449  0.001842  water_risk_3_blk
3    79.183673  0.002652  water_risk_3_blk
4    92.244898  0.002562  water_risk_3_blk
5   105.306122  0.002403  water_risk_3_blk
6   118.367347  0.002626  water_risk_3_blk
7   131.428571  0.002671  water_risk_3_blk
8   144.489796  0.002938  water_risk_3_blk
9   157.551020  0.002837  water_risk_3_blk
10  170.612245  0.002839  water_risk_3_blk
11  183.673469  0.002923  water_risk_3_blk
12  196.734694  0.002942  water_risk_3_blk
13  209.795918  0.002958  water_risk_3_blk
14  222.857143  0.002923  water_risk_3_blk
15  235.918367  0.002903  water_risk_3_blk
16  248.979592  0.002979  water_risk_3_blk
17  262.040816  0.002954  water_risk_3_blk
18  275.102041  0.003172  water_risk_3_blk
19  288.163265  0.003066  water_risk_3_blk
20  301.224490  0.003382  water_risk_3_blk
21  314.285714  0.003182  water_risk_3_blk
22  327.346939  0.003274  water_risk_3_blk
23  340.408163  0.003337  water_risk_3_blk
24  353.469388  0.003547  water_risk_3_blk
25  366.530612  0.003506  water_risk_3_blk
26  379.591837  0.003293  water_risk_3_blk
27  392.653061  0.003154  water_risk_3_blk
28  405.714286  0.003757  water_risk_3_blk
29  418.775510  0.002658  water_risk_3_blk
30  431.836735  0.002828  water_risk_3_blk
31  444.897959  0.003265  water_risk_3_blk
32  457.959184  0.002929  water_risk_3_blk
33  471.020408  0.003541  water_risk_3_blk
34  484.081633  0.003464  water_risk_3_blk
35  497.142857  0.003289  water_risk_3_blk
36  510.204082  0.003167  water_risk_3_blk
37  523.265306  0.003205  water_risk_3_blk
38  536.326531  0.003595  water_risk_3_blk
39  549.387755  0.002569  water_risk_3_blk
40  562.448980  0.003517  water_risk_3_blk
41  575.510204  0.003601  water_risk_3_blk
42  588.571429  0.003331  water_risk_3_blk
43  601.632653  0.003270  water_risk_3_blk
44  614.693878  0.003202  water_risk_3_blk
45  627.755102  0.002816  water_risk_3_blk
46  640.816327  0.002707  water_risk_3_blk
47  653.877551  0.003156  water_risk_3_blk
48  666.938776  0.002703  water_risk_3_blk
49  680.000000  0.002704  water_risk_3_blk
   value        pd      feature
0    0.0  0.002916  serviceline
1    1.0  0.002703  serviceline
    value        pd          feature
0     3.0  0.002923  protectionclass
1     2.0  0.002825  protectionclass
2     4.0  0.003065  protectionclass
3     6.0  0.002973  protectionclass
4     5.0  0.002893  protectionclass
5     8.0  0.001292  protectionclass
6     7.0  0.003179  protectionclass
7     1.0  0.003076  protectionclass
8    10.0  0.001293  protectionclass
9     9.0  0.001293  protectionclass
10    0.0  0.003193  protectionclass
    value        pd               feature
0    30.0  0.002341  water_risk_fre_3_blk
1    42.0  0.001133  water_risk_fre_3_blk
2    54.0  0.002733  water_risk_fre_3_blk
3    66.0  0.002171  water_risk_fre_3_blk
4    78.0  0.002950  water_risk_fre_3_blk
5    90.0  0.002659  water_risk_fre_3_blk
6   102.0  0.002629  water_risk_fre_3_blk
7   114.0  0.002674  water_risk_fre_3_blk
8   126.0  0.002688  water_risk_fre_3_blk
9   138.0  0.002747  water_risk_fre_3_blk
10  150.0  0.002922  water_risk_fre_3_blk
11  162.0  0.003029  water_risk_fre_3_blk
12  174.0  0.003034  water_risk_fre_3_blk
13  186.0  0.003090  water_risk_fre_3_blk
14  198.0  0.003023  water_risk_fre_3_blk
15  210.0  0.003009  water_risk_fre_3_blk
16  222.0  0.003218  water_risk_fre_3_blk
17  234.0  0.003445  water_risk_fre_3_blk
18  246.0  0.003096  water_risk_fre_3_blk
19  258.0  0.003169  water_risk_fre_3_blk
20  270.0  0.002736  water_risk_fre_3_blk
21  282.0  0.002636  water_risk_fre_3_blk
22  294.0  0.002948  water_risk_fre_3_blk
23  306.0  0.003092  water_risk_fre_3_blk
24  318.0  0.003374  water_risk_fre_3_blk
25  330.0  0.003472  water_risk_fre_3_blk
26  342.0  0.003572  water_risk_fre_3_blk
27  354.0  0.003520  water_risk_fre_3_blk
28  366.0  0.003672  water_risk_fre_3_blk
29  378.0  0.003074  water_risk_fre_3_blk
30  390.0  0.003044  water_risk_fre_3_blk
31  402.0  0.002900  water_risk_fre_3_blk
32  414.0  0.002803  water_risk_fre_3_blk
33  426.0  0.002364  water_risk_fre_3_blk
34  438.0  0.003381  water_risk_fre_3_blk
35  450.0  0.002777  water_risk_fre_3_blk
36  462.0  0.002737  water_risk_fre_3_blk
37  474.0  0.003058  water_risk_fre_3_blk
38  486.0  0.003316  water_risk_fre_3_blk
39  498.0  0.003199  water_risk_fre_3_blk
40  510.0  0.003216  water_risk_fre_3_blk
41  522.0  0.003310  water_risk_fre_3_blk
42  534.0  0.002676  water_risk_fre_3_blk
43  546.0  0.002829  water_risk_fre_3_blk
44  558.0  0.002940  water_risk_fre_3_blk
45  570.0  0.002748  water_risk_fre_3_blk
46  582.0  0.002664  water_risk_fre_3_blk
47  594.0  0.002694  water_risk_fre_3_blk
48  606.0  0.003197  water_risk_fre_3_blk
49  618.0  0.002351  water_risk_fre_3_blk
   value        pd         feature
0    1.0  0.003080  rep_cost_3_blk
1    5.0  0.002939  rep_cost_3_blk
2    4.0  0.003012  rep_cost_3_blk
3    0.0  0.003172  rep_cost_3_blk
4    2.0  0.003016  rep_cost_3_blk
5    3.0  0.003047  rep_cost_3_blk
   value        pd            feature
0    2.0  0.002985  waterh_fail_3_blk
1    3.0  0.002857  waterh_fail_3_blk
2    1.0  0.003085  waterh_fail_3_blk
3    4.0  0.002958  waterh_fail_3_blk
4    0.0  0.002872  waterh_fail_3_blk
5    5.0  0.003014  waterh_fail_3_blk
   value        pd      feature
0    0.0  0.002949  deadboltind
1    1.0  0.002936  deadboltind
   value        pd            feature
0    0.0  0.002960  homegardcreditind
1    1.0  0.002943  homegardcreditind
    value        pd            feature
0    10.0  0.002967  ordinanceorlawpct
1    25.0  0.002820  ordinanceorlawpct
2    50.0  0.003143  ordinanceorlawpct
3    20.0  0.002922  ordinanceorlawpct
4     0.0  0.002929  ordinanceorlawpct
5    40.0  0.002977  ordinanceorlawpct
6    75.0  0.003227  ordinanceorlawpct
7    65.0  0.003168  ordinanceorlawpct
8    90.0  0.003248  ordinanceorlawpct
9    15.0  0.002934  ordinanceorlawpct
10  100.0  0.004956  ordinanceorlawpct
   value        pd         feature
0    2.0  0.002985  occupancy_encd
1    3.0  0.002985  occupancy_encd
2    1.0  0.002944  occupancy_encd
   value        pd            feature
0    0.0  0.002947  burglaryalarmtype
1    1.0  0.002945  burglaryalarmtype
     value        pd   feature
0      0.0  0.002955  waterded
1  10000.0  0.001531  waterded
2   5000.0  0.002392  waterded
3   7500.0  0.001521  waterded
   value        pd           feature
0    4.0  0.002912  plumb_leak_3_blk
1    5.0  0.002989  plumb_leak_3_blk
2    1.0  0.002935  plumb_leak_3_blk
3    3.0  0.002900  plumb_leak_3_blk
4    2.0  0.002933  plumb_leak_3_blk
5    0.0  0.002358  plumb_leak_3_blk
   value        pd          feature
0    5.0  0.002934  appl_fail_3_blk
1    4.0  0.003005  appl_fail_3_blk
2    1.0  0.002950  appl_fail_3_blk
3    3.0  0.002899  appl_fail_3_blk
4    2.0  0.002886  appl_fail_3_blk
5    0.0  0.002858  appl_fail_3_blk
   value        pd           feature
0    1.0  0.002953  numberoffamilies
1    4.0  0.002896  numberoffamilies
2    2.0  0.002684  numberoffamilies
3    3.0  0.002731  numberoffamilies
4    0.0  0.002953  numberoffamilies
   value        pd feature
0    1.0  0.002936   units
1    4.0  0.003499   units
2    2.0  0.002883   units
3    3.0  0.003030   units
         value        pd               feature
0    53.000000  0.004909  water_risk_sev_3_blk
1    56.489796  0.004884  water_risk_sev_3_blk
2    59.979592  0.001677  water_risk_sev_3_blk
3    63.469388  0.003035  water_risk_sev_3_blk
4    66.959184  0.003129  water_risk_sev_3_blk
5    70.448980  0.003040  water_risk_sev_3_blk
6    73.938776  0.002163  water_risk_sev_3_blk
7    77.428571  0.002534  water_risk_sev_3_blk
8    80.918367  0.002599  water_risk_sev_3_blk
9    84.408163  0.002631  water_risk_sev_3_blk
10   87.897959  0.002976  water_risk_sev_3_blk
11   91.387755  0.002958  water_risk_sev_3_blk
12   94.877551  0.003035  water_risk_sev_3_blk
13   98.367347  0.002944  water_risk_sev_3_blk
14  101.857143  0.002943  water_risk_sev_3_blk
15  105.346939  0.002966  water_risk_sev_3_blk
16  108.836735  0.003015  water_risk_sev_3_blk
17  112.326531  0.003075  water_risk_sev_3_blk
18  115.816327  0.002968  water_risk_sev_3_blk
19  119.306122  0.002917  water_risk_sev_3_blk
20  122.795918  0.002972  water_risk_sev_3_blk
21  126.285714  0.002993  water_risk_sev_3_blk
22  129.775510  0.002944  water_risk_sev_3_blk
23  133.265306  0.002931  water_risk_sev_3_blk
24  136.755102  0.002948  water_risk_sev_3_blk
25  140.244898  0.002952  water_risk_sev_3_blk
26  143.734694  0.002949  water_risk_sev_3_blk
27  147.224490  0.002911  water_risk_sev_3_blk
28  150.714286  0.002869  water_risk_sev_3_blk
29  154.204082  0.002648  water_risk_sev_3_blk
30  157.693878  0.002755  water_risk_sev_3_blk
31  161.183673  0.002731  water_risk_sev_3_blk
32  164.673469  0.002719  water_risk_sev_3_blk
33  168.163265  0.002715  water_risk_sev_3_blk
34  171.653061  0.002774  water_risk_sev_3_blk
35  175.142857  0.002950  water_risk_sev_3_blk
36  178.632653  0.002496  water_risk_sev_3_blk
37  182.122449  0.002406  water_risk_sev_3_blk
38  185.612245  0.002314  water_risk_sev_3_blk
39  189.102041  0.002390  water_risk_sev_3_blk
40  192.591837  0.002660  water_risk_sev_3_blk
41  196.081633  0.002588  water_risk_sev_3_blk
42  199.571429  0.002347  water_risk_sev_3_blk
43  203.061224  0.002574  water_risk_sev_3_blk
44  206.551020  0.002375  water_risk_sev_3_blk
45  210.040816  0.002389  water_risk_sev_3_blk
46  213.530612  0.002242  water_risk_sev_3_blk
47  217.020408  0.002154  water_risk_sev_3_blk
48  220.510204  0.002126  water_risk_sev_3_blk
49  224.000000  0.001471  water_risk_sev_3_blk
   value        pd                 feature
0    0.0  0.002951  multipolicyindumbrella
1    1.0  0.002785  multipolicyindumbrella
   value        pd                     feature
0    0.0  0.002953  kitchenfireextinguisherind
1    1.0  0.002930  kitchenfireextinguisherind
   value        pd             feature
0    1.0  0.002768  fixture_leak_3_blk
1    3.0  0.002977  fixture_leak_3_blk
2    2.0  0.002989  fixture_leak_3_blk
3    5.0  0.002389  fixture_leak_3_blk
4    4.0  0.002584  fixture_leak_3_blk
5    0.0  0.003261  fixture_leak_3_blk
   value        pd              feature
0    5.0  0.002940  constructioncd_encd
1    1.0  0.002924  constructioncd_encd
2    4.0  0.002881  constructioncd_encd
3    2.0  0.003002  constructioncd_encd
4    3.0  0.003113  constructioncd_encd
    value        pd                feature
0     0.0  0.002984  fire_risk_model_score
1     1.0  0.002849  fire_risk_model_score
2     2.0  0.002990  fire_risk_model_score
3     6.0  0.002595  fire_risk_model_score
4     7.0  0.001325  fire_risk_model_score
5     3.0  0.002981  fire_risk_model_score
6    -1.0  0.002719  fire_risk_model_score
7     4.0  0.002714  fire_risk_model_score
8     9.0  0.000974  fire_risk_model_score
9    13.0  0.000974  fire_risk_model_score
10    8.0  0.000974  fire_risk_model_score
11    5.0  0.002656  fire_risk_model_score
12   11.0  0.000974  fire_risk_model_score
13   14.0  0.000974  fire_risk_model_score
14   12.0  0.000974  fire_risk_model_score
15   15.0  0.000974  fire_risk_model_score
16   10.0  0.000974  fire_risk_model_score
17   18.0  0.000974  fire_risk_model_score
18   17.0  0.000974  fire_risk_model_score
   value        pd            feature
0    0.0  0.002950  gatedcommunityind
1    1.0  0.002746  gatedcommunityind
   value        pd          feature
0    0.0  0.002949  sprinklersystem
1    1.0  0.002767  sprinklersystem
   value        pd                    feature
0    0.0  0.002948  neighborhoodcrimewatchind
1    1.0  0.002885  neighborhoodcrimewatchind
   value        pd           feature
0    0.0  0.002948  rentersinsurance
1    1.0  0.002982  rentersinsurance
   value        pd                feature
0    0.0  0.002947  earthquakeumbrellaind
1    1.0  0.003151  earthquakeumbrellaind
   value        pd                    feature
0    0.0  0.002947  functionalreplacementcost
1    1.0  0.003566  functionalreplacementcost