In [1]:
from itertools import islice
import json
from bubbly.model import Model
from bubbly.dr1 import LocationGenerator
from bubbly.extractors import RingWaveletCompressionExtractor, enhance_contrast
from bubbly.util import summary
from bubbly.util import rfp_curve
import brewer2mpl
%pylab
In [2]:
ex = RingWaveletCompressionExtractor()
ex.preprocessors.append(enhance_contrast)
model = Model(ex, LocationGenerator(),
weak_learner_params=dict(verbose=1, max_depth=1, n_estimators=200, subsample=.4),
cascade_params=dict(verbose=1, max_layers=1))
training_data = json.load(open('../models/reproducing_old_training_data.json'))
In [3]:
model.retrain(training_data)
In [5]:
x, y = model._make_xy(model.training_data[0]['pos'], model.training_data[0]['neg'])
summary(model.estimator, x, y)
In [6]:
cv_locator = LocationGenerator(1)
on2 = cv_locator.positives()
off2 = list(islice(cv_locator.negatives_iterator(), 10000))
x2, y2 = model._make_xy(on2, off2)
summary(model.estimator, x2, y2)
In [10]:
colors = brewer2mpl.get_map('Purples', 'sequential', 7).mpl_colors[::-1]
for i, df in enumerate(model.estimator.staged_decision_function(x2)):
rfp_curve(df, y2, label = 'CV %i' % i, color = colors[i])
yp = model.estimator.decision_function(x)
rfp_curve(yp, y, color='red', label='Training Data')
ylim(0, .01)
legend(loc='upper left')
Out[10]:
In [ ]: