def n_deriv(vals): evals = extend_vals(vals) if type(vals) != type(coeffs) or len(evals) != len(coeffs): print("Error in list sizes. Vals {} // Coeffs {}".format(evals, coeffs)) raise IndexError prod = dot(evals, coeffs) deriv = -logistic_func(vals)**2 * (-evals[n] * math.exp(-prod)) return deriv
stdpts = stdpts_with_stats["points"] stats = stdpts_with_stats["stats"] print("Standardized points: {} // stats {}".format(stdpts, stats)) params = (0.1, 0.1, 0.1, 0.1) log_func = logistic_function(params) print("Cost 1: {}".format(non_regularized_cost(log_func, stdpts))) final_func = regularized_logistic_regression_bounded(log_func, 0.1, 0.000001, 10, stdpts, 0.01) print(list(final_func["params"])) print("Output values: {}".format([((x, y), final_func["func"](x)) for x, y in stdpts])) print("Vals {} // Coeffs{} // Dot: {}".format( extend_vals(pts[0][0]), final_func["params"], dot(extend_vals(pts[0][0]), final_func["params"]))) final_func = logistic_regression_bounded(log_func, 0.1, 0.000001, 10, stdpts) print(list(final_func["params"])) print("Output values: {}".format([((x, y), final_func["func"](x)) for x, y in stdpts])) print("Vals {} // Coeffs{} // Dot: {}".format( extend_vals(pts[0][0]), final_func["params"], dot(extend_vals(pts[0][0]), final_func["params"])))
def n_deriv(vals): return extend_vals(vals)[n]
def generated(vals): vals = extend_vals(vals) if len(vals) != len(coeffs): raise IndexError return sum(c*v for (c, v) in zip(coeffs, vals))
def generated(vals): vals = extend_vals(vals) if len(vals) != len(coeffs): raise IndexError prod = dot(vals, coeffs) return 1/(1 + math.exp(-prod))