try:
                        conditions[condition] = val['prices_centered']
                    except KeyError:
                        pass

results = []
for condition, offset in conditions.iteritems():
    results.append([float(condition), np.average(offset)])


results = sorted(results, key = itemgetter(0))

# NOTE - there is clearly an issue with condition 4.0 selling prices :(
# it doesn't make any sense by that set of prices would be above the average
# while 3.9 and 4.1 are significantly below average
# let's just adjust this value and interpolate between 3.9 and 4.1

results[1][1] = (results[0][1] + results[2][1]) / 2

condition_map = {}
for item in results:
    condition_map[str(item[0])] = item[1]
    print item[0], item[1]

#plt.scatter([item[0] for item in results], [item[1] for item in results])
#plt.savefig('./plots/condition-offset.png')

EXPORT = Exporter()

EXPORT.save('condition-offset.json', dataset=condition_map)
Beispiel #2
0
                try:
                    states[state] = states[state] + val['prices_centered']
                except KeyError:
                    try:
                        states[state] = val['prices_centered']
                    except KeyError:
                        pass

results = []
for state, offset in states.iteritems():
    count = len(offset)
    if count < 1 / pow(confidence, 2):
        print 'state: %s, n: %s' % (state, count)
        print 'not enough data to calculate reliable offset'
    else:
        results.append([state, np.average(offset)])

results = sorted(results, key = itemgetter(0))

state_map = {}
for item in results:
    state_map[item[0]] =  item[1]
    print item[0], item[1]

# plt.scatter([i for i, item in enumerate(results)], [item[1] for item in results])
# plt.savefig('./plots/state-offset.png')

EXPORT = Exporter()

EXPORT.save('state-offset.json', dataset=state_map)