def first_principal_component_SGD(data):
    """ Uses SGD method to determine the direction that maximizes the
        directional_variance gradient """
    guess = data[0]
    unscaled_maximizer, _ = Ch8.maximize_stochastic(lambda x,_,w:
                            directional_variance_i(x,w), lambda x,_,w:
                            directional_variance_gradient_i(x,w), data, 
                            [None for _ in data], guess)
    return direction(unscaled_maximizer)
def first_principal_component_SGD(data):
    """ Uses SGD method to determine the direction that maximizes the
        directional_variance gradient """
    guess = data[0]
    unscaled_maximizer, _ = Ch8.maximize_stochastic(
        lambda x, _, w: directional_variance_i(x, w),
        lambda x, _, w: directional_variance_gradient_i(x, w), data,
        [None for _ in data], guess)
    return direction(unscaled_maximizer)
def first_principal_component(data):
    guess = [1 for _ in data[0]]
    # use partial to make the target and grade fncs a variable of w only
    unscaled_maximizer, _, _ = Ch8.maximize_batch(
                            partial(directional_variance, data),
                            partial(directional_variance_gradient, data),
                            guess,tolerance = 0.00001)

    return direction(unscaled_maximizer)
def first_principal_component(data):
    guess = [1 for _ in data[0]]
    # use partial to make the target and grade fncs a variable of w only
    unscaled_maximizer, _, _ = Ch8.maximize_batch(
        partial(directional_variance, data),
        partial(directional_variance_gradient, data),
        guess,
        tolerance=0.00001)

    return direction(unscaled_maximizer)