#################################################################################### # # A file that takes in a .dat file (a time series that has been discretiezed) # and outputs import cssr_interface import sys import pylab import numpy import ipdb # Use CSSR to generate the CSM files fname = 'timeseries_synthetic/Bernoulli/sample1' historyLength = 5 is_multiline = False cssr_interface.run_CSSR(filename = fname, L = historyLength, savefiles = True, showdot = True, is_multiline = is_multiline, showCSSRoutput = True) hist_length, Cmu, hmu, num_states = cssr_interface.parseResultFile(fname) print 'C_mu: {0}\nh_mu: {1}\nNumber of States: {2}'.format(Cmu, hmu, num_states)
if true == majority_vote: base_rate += 1 # print true, pred print 'Accuracy rate: {}...'.format(float(correct)/len(prediction)) print 'Compared to using a biased coin {}...'.format(numpy.max((float(base_rate)/len(prediction), 1 - float(base_rate)/len(prediction)))) metric = 'accuracy' fname = '{}/sample{}'.format(datatype, noi) zero_order_predict = generate_zero_order_CSM(fname) cssr_interface.run_CSSR(filename = fname, L = L_CSSR, savefiles = True, showdot = True, is_multiline = False, showCSSRoutput = False) CSM = get_CSM(fname = fname) epsilon_machine = get_epsilon_machine(fname = fname) states, L = get_equivalence_classes(fname) # A dictionary structure with the ordered pair # (symbol sequence, state) correct_rates = run_tests(fname = fname, CSM = CSM, zero_order_CSM = zero_order_predict, states = states, epsilon_machine = epsilon_machine, L = L_CSSR, L_max = L_max, metric = metric, print_predictions = False, print_state_series = False) print 'Compared to using CSSR on the timeseries {}...'.format(correct_rates[0]) for state_ind, state in enumerate(states_final): print '\nState {}\n========'.format(state_ind) enum_hists, enum_probs = state
import cssr_interface L_val = 20 # prefix = 'sample-60s-' prefix = 'sample' user = '******' fname = '{}{}'.format(prefix, user) cssr_interface.run_CSSR(filename = fname, L = L_val, savefiles = True, showdot = True, is_multiline = False, showCSSRoutput = False)