from __future__ import division, print_function
from collections import Counter
from capstone.util.c4uci import load_instance

FILENAME = 'datasets/connect-4.data'

outcomes = []

with open(FILENAME) as f:
    for i, line in enumerate(f, 1):
        _, outcome = load_instance(line)
        outcomes.append(outcome)
        if i % 1000 == 0:
            print(i)

counter = Counter(outcomes)
print('\n---------')
print(' Results')
print('---------\n')
print('total: {}'.format(len(outcomes)))
for outcome in ['win', 'loss', 'draw']:
    print('{outcome}: {count} ({pct:.2f}%)'.format(
        outcome=outcome,
        count=counter[outcome],
        pct=((counter[outcome] / len(outcomes)) * 100)
    ))

@@ -45,39 +45,118 @@
 ion%0A
-from collections import Counter
+import pandas as pd%0Afrom sklearn.linear_model import LinearRegression%0Afrom capstone.game import Connect4 as C4
 %0Afro
@@ -174,22 +174,16 @@
 util
-.c4uci
  import 
 load
@@ -178,29 +178,28 @@
  import 
-load_instance
+print_header
 %0A%0AFILENA
@@ -234,543 +234,593 @@
 a'%0A%0A
-outcomes = %5B%5D%0A%0Awith open(FILENAME) as f:%0A    for i, line in enumerate(f, 1):%0A        _, outcome = load_instance(line)%0A        outcomes.append(outcome)%0A        if i %25 1000 == 0:%0A            print(i)%0A%0Acounter = Counter(outcomes)%0Aprint('%5Cn---------')%0Aprint(' Results')%0Aprint('---------
+def column_name(i):%0A    if i == 42:%0A        return 'outcome'%0A    row = chr(ord('a') + (i // C4.ROWS))%0A    col = (i %25 C4.ROWS) + 1%0A    return '%7Brow%7D%7Bcol%7D'.format(row=row, col=col)%0A%0Acolumn_names = %5Bcolumn_name(i) for i in range(43)%5D%0Adf = pd.read_csv(FILENAME, header=None, names=column_names)%0Aoutcomes = df.loc%5B:, 'outcome'%5D%0A%0Aprint_header('Dataset')%0Aprint(df, end='%5Cn
 %5Cn')%0A
+%0A
 print
-('total: %7B%7D'.format(len(outcomes)))%0Afor outcome in %5B'win', 'loss', 'draw'%5D:%0A    print('%7Boutcome%7D: %7Bcount%7D (%7Bpct:.2f%7D%25)'.format(%0A        outcome=outcome,%0A        count=counter%5Boutcome%5D,%0A        pct=((counter%5Boutcome%5D / len(outcomes)) * 100)%0A    
+_header('Number of instances')%0Aprint(df.shape%5B0%5D, end='%5Cn%5Cn')%0A%0Aprint_header('Outcomes')%0Aprint(outcomes.value_counts(), end='%5Cn%5Cn')%0A%0Aprint_header('Normalized Outcomes')%0Aprint(outcomes.value_counts(normalize=True
 ))%0A

Use pandas dataframes for UCI C4 dataset