예제 #1
0
파일: experiments.py 프로젝트: dridon/aml1
def print_valdiate_k(k, errors):
  e  = [["Reggression", "True Error", "Training Error"]]
  for key in errors.iterkeys(): 
    e.append([key, kfv.mean_error(errors[key]["errors"]), kfv.mean_error(errors[key]["terrors"])])
  w= csv.writer(open("data/error/" +str(k) + "_fold_validation.csv", "w+"))
  w.writerows(e) 
  return e
예제 #2
0
파일: experiments.py 프로젝트: dridon/aml1
def vary_alpha(data, k, alphas, iterations):
  errors = [] 
  params = {"iterations": iterations}
  for a in alphas:
    print "On alpha " + str(a)
    params["alpha"] = a
    es, ts = kfv.k_fold_cvalidation(data, k, kfv.train_grad_descent, kfv.test_regression, params)
    errors.append([a, kfv.mean_error(es), kfv.mean_error(ts)])
  return errors
예제 #3
0
파일: experiments.py 프로젝트: dridon/aml1
def vary_iterations(data, k, alpha, iterations):
  errors = [] 
  params = {"alpha": alpha}
  for i in iterations:
    print "On iteration count " + str(i)
    params["iterations"] = i
    es, ts = kfv.k_fold_cvalidation(data, k, kfv.train_grad_descent, kfv.test_regression, params)
    errors.append([i, kfv.mean_error(es), kfv.mean_error(ts)])
  return errors
예제 #4
0
파일: experiments.py 프로젝트: dridon/aml1
def vary_iterations(data, k, alpha, iterations):
    errors = []
    params = {"alpha": alpha}
    for i in iterations:
        print "On iteration count " + str(i)
        params["iterations"] = i
        es, ts = kfv.k_fold_cvalidation(data, k, kfv.train_grad_descent,
                                        kfv.test_regression, params)
        errors.append([i, kfv.mean_error(es), kfv.mean_error(ts)])
    return errors
예제 #5
0
파일: experiments.py 프로젝트: dridon/aml1
def vary_alpha(data, k, alphas, iterations):
    errors = []
    params = {"iterations": iterations}
    for a in alphas:
        print "On alpha " + str(a)
        params["alpha"] = a
        es, ts = kfv.k_fold_cvalidation(data, k, kfv.train_grad_descent,
                                        kfv.test_regression, params)
        errors.append([a, kfv.mean_error(es), kfv.mean_error(ts)])
    return errors
예제 #6
0
파일: experiments.py 프로젝트: dridon/aml1
def vary_k(data, rs, min_k, max_k, inc, params):
  errors = {} 
  for key in rs.iterkeys():
    print "On regression: " + str(key)
    l = []
    for k in range(min_k, max_k + 1, inc):
      print "On k value of " + str(k)
      es, ts = kfv.k_fold_cvalidation(data, k, rs[key], kfv.test_regression, params)
      l.append([k,kfv.mean_error(es), kfv.mean_error(ts)])
    errors[key] = l  
  return errors
예제 #7
0
파일: experiments.py 프로젝트: dridon/aml1
def print_valdiate_k(k, errors):
    e = [["Reggression", "True Error", "Training Error"]]
    for key in errors.iterkeys():
        e.append([
            key,
            kfv.mean_error(errors[key]["errors"]),
            kfv.mean_error(errors[key]["terrors"])
        ])
    w = csv.writer(open("data/error/" + str(k) + "_fold_validation.csv", "w+"))
    w.writerows(e)
    return e
예제 #8
0
파일: experiments.py 프로젝트: dridon/aml1
def vary_k(data, rs, min_k, max_k, inc, params):
    errors = {}
    for key in rs.iterkeys():
        print "On regression: " + str(key)
        l = []
        for k in range(min_k, max_k + 1, inc):
            print "On k value of " + str(k)
            es, ts = kfv.k_fold_cvalidation(data, k, rs[key],
                                            kfv.test_regression, params)
            l.append([k, kfv.mean_error(es), kfv.mean_error(ts)])
        errors[key] = l
    return errors