Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
636 B
0
Indexable
Never
##class distribution
from matplotlib.pyplot import figure, savefig, close, bar,xlabel, ylabel,title
from ds_charts import bar_chart, get_variable_types,HEIGHT
binary_vars = get_variable_types(data)['Binary']
if [] == binary_vars:
    raise ValueError('There are no binary variables.')

for n in range(len(binary_vars)):
    sumCount = data[binary_vars[n]].values.sum()
    labels = ['False','True']
    counts = [len(data[binary_vars[n]].values) - sumCount,sumCount]
    bar(labels,counts)
    xlabel(binary_vars[n])
    ylabel('Nr of records')
    title('Histogram of ' + binary_vars[n])
savefig('imagens/histogram_binary.png')
close()