In [1]:
import _initpath
import numpy
import dataset.csv
import dataset.wh40k
import zerosum.balance
from pandas import DataFrame
balance_7 = zerosum.balance.MultiplicativeBalance(dataset.wh40k.wh40k_7_to_wound).optimize()
balance_8 = zerosum.balance.MultiplicativeBalance(dataset.wh40k.wh40k_8_to_wound).optimize()
labels = [str(i + 1) for i in range(10)]
dataset.csv.write_csv('out/wh40k_7_to_wound_init.csv',
dataset.wh40k.wh40k_7_to_wound,
labels)
dataset.csv.write_csv('out/wh40k_8_to_wound_init.csv',
dataset.wh40k.wh40k_8_to_wound,
labels)
dataset.csv.write_csv('out/wh40k_7_to_wound_opt.csv',
balance_7.F, labels,
row_footers = balance_7.row_handicaps / balance_7.row_handicaps[0],
col_footers = balance_7.col_handicaps / balance_7.col_handicaps[0],
numeric_format = '%0.4f')
dataset.csv.write_csv('out/wh40k_8_to_wound_opt.csv',
balance_8.F, labels,
row_footers = balance_8.row_handicaps / balance_8.row_handicaps[0],
col_footers = balance_8.col_handicaps / balance_8.col_handicaps[0],
numeric_format = '%0.4f')
In [2]:
DataFrame(data = dataset.wh40k.wh40k_7_to_wound, index = labels, columns = labels)
Out[2]:
In [3]:
DataFrame(data = balance_7.F, index = labels, columns = labels)
Out[3]:
In [4]:
DataFrame(data = dataset.wh40k.wh40k_8_to_wound, index = labels, columns = labels)
Out[4]:
In [5]:
DataFrame(data = balance_8.F, index = labels, columns = labels)
Out[5]:
In [6]:
strength_weights = numpy.array([0.0, 0.0, 2.0, 2.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0])
toughness_weights = strength_weights
balance_7_weighted = zerosum.balance.MultiplicativeBalance(dataset.wh40k.wh40k_7_to_wound, strength_weights, toughness_weights).optimize()
dataset.csv.write_csv('out/wh40k_7_to_wound_weighted_opt.csv',
balance_7_weighted.F, [str(i + 1) for i in range(10)],
row_footers = balance_7_weighted.row_handicaps / balance_7_weighted.row_handicaps[0],
col_footers = balance_7_weighted.col_handicaps / balance_7_weighted.col_handicaps[0],
numeric_format = '%0.4f')
DataFrame(data = balance_7_weighted.F, index = labels, columns = labels)
Out[6]: