Пример #1
0
def main(events):

    data = get_event_data(events)

    if len(data) == 0:
        sys.exit("ERROR: Unable to retrieve data from Mixpanel")

    matrix = event_data_to_matrix(data, events)

    response_name = events.pop(0)
    response_data = matrix[:,0]

    predictors_data = matrix[:,1:]
    predictors_names = events

    model = ols(response_data, predictors_data, response_name, predictors_names)

    model.summary()

    ## Generate Equation

    # Gather list of coefficients so we can build our formula
    coeff_dict = dict(zip(model.x_varnm, model.b))

    equation = "%s = %.5f" % (response_name, coeff_dict['const']) # Start with constant coefficient

    for name in predictors_names:
        val = coeff_dict[name]
        equation += " + %.5f(%s)" % (val, name)

    print "Regression equation for response variable '%s'" % response_name
    print
    print equation
Пример #2
0
def main(events):

    data = get_event_data(events)
    matrix = event_data_to_matrix(data, events)

    print "Correlation coefficients"

    for event1, event2 in list_to_pairs(events):

        data1 = matrix[:,events.index(event1)]
        data2 = matrix[:,events.index(event2)]

        coeff = corrcoef(data1, data2)[0][1]

        print "%s\tx\t%s:\t%f" % (event1, event2, coeff)