#if deceased population is higher then 1.000.000 people, classify as 1 
    classes[result[:, -1] > 1000000] = 1
    
    return classes

#load data
fn = r'./data/1000 flu cases.tar.gz'
results = load_results(fn)
experiments, results = results

#extract results for 1 policy
logical = experiments['policy'] == 'no policy'
new_experiments = experiments[ logical ]
new_results = {}
for key, value in results.items():
    new_results[key] = value[logical]

results = (new_experiments, new_results)

#perform cart on modified results tuple

cart_alg = cart.setup_cart(results, classify, mass_min=0.05)
cart_alg.build_tree()

#print cart to std_out
print cart_alg.stats_to_dataframe()
print cart_alg.boxes_to_dataframe()

#visualize
cart_alg.display_boxes(together=True)
plt.show()
    def test_setup_cart(self):
        results = test_utilities.load_flu_data()

        cart_algorithm = cart.setup_cart(results, flu_classify, mass_min=0.05)
示例#3
0
 def test_setup_cart(self):
     results = util.load_flu_data()
     
     cart_algorithm = cart.setup_cart(results, flu_classify, mass_min=0.05)
    classes[result[:, -1] > 1000000] = 1

    return classes


#load data
fn = r'./data/1000 flu cases.tar.gz'
results = load_results(fn)
experiments, results = results

#extract results for 1 policy
logical = experiments['policy'] == 'no policy'
new_experiments = experiments[logical]
new_results = {}
for key, value in results.items():
    new_results[key] = value[logical]

results = (new_experiments, new_results)

#perform cart on modified results tuple

cart_alg = cart.setup_cart(results, classify, mass_min=0.05)
cart_alg.build_tree()

#print cart to std_out
print cart_alg.stats_to_dataframe()
print cart_alg.boxes_to_dataframe()

#visualize
cart_alg.display_boxes(together=True)
plt.show()