2019-08-26 15:11:05 huayunhualuo 阅读数 100
  • 机器学习--线性回归数学推导视频教学

    线性回归数学推导是机器学习的基石,是人工智能的算法基础, 可以被广泛的应用在在工作和学习。本节课就带领同学们从零开始一步一步的推导线性回归。课程内容包括矩阵转换、误差值分析、似然函数、小二乘、结果推导。 任务作业: 设计并实现一个三层架构的员工管理系统。要求: 1、数据库及其表自行设计,遵循数据库及表设计的一般命名规则 2、要求有管理员的登录功能及对员工信息的增删改查 3、功能的实现严格采用三层架构的设计框架,注意命名的一般规范 4、采用B/S架构,界面大方美观 5、思考下三层架构与MVC框架有什么区别 (温馨提示: 注意 作业需写在CSDN博客中,请把作业链接贴在评论区,老师会定期逐个批改~~)

    3966 人正在学习 去看看 陆永剑


基本设置

导入包

import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model, discriminant_analysis,model_selection

使用数据集是scikit-learn自带的一个糖尿病人的数据集,该数据集的采样特点如下

  • 数据集有442个样本
  • 每个样本有10个特征
  • 每个特征都是浮点数,数据都在0.20.2-0.2\sim 0.2
  • 样本的目标在整数2534625\sim 346之间

数据加载函数

def load_data():
    diabetes = datasets.load_diabetes()
    print(diabetes.DESCR)
    return model_selection.train_test_split(diabetes.data, diabetes.target, test_size=0.25,random_state=8)

**返回值:**一个元组,元组依次是:训练样本集、测试样本集、训练标签集、测试标签集。

load_data函数加载数据集并随机切分数据集为两个部分

线性回归模型

LinearRegressionscikit-learn提供的线性回归模型,原型为

class LinearRegression(fit_intercept=True, normalize=False,copy_x=True, n_jobs=1)

参数

  • fit_intercept:一个布尔值,表示是否需要计算bb值。
  • normalize:一个布尔值,如果为True,那么样本会在回归之前被归一化
  • copy_x:一个布尔值,如果为True,则会复制x。
  • n_jobs:一个正数。任务并行是指定的CPU数量,如果为-1表示使用所有的CPU

属性

  • coef_:权重向量
  • intercept_:b值

方法

  • fit(X,y[,sample_weight]):训练模型

  • predict(X):用模型来预测,返回预测值

  • score(X,y[,sample_weight]):返回预测性能得分,设预测集为TtestT_{test},真实值为yiy_i,真实值的均值为y\overline{y},预测值为y^\hat y
    score=1Ttest(yiy^i)2(yiy)2 score = 1-\frac{\sum_{T_{test}}(y_i-\hat y_i)^2}{(y_i-\overline{y})^2}

    • score不超过1,可能为负值
    • score越大,预测性能越好
def test_LinearRegression(*data):
    X_train,X_test,y_train,y_test = data
    regr = linear_model.LinearRegression()
    regr.fit(X_train,y_train)
    print("Coefficients:%s, intercept %.2f"%(regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" %regr.score(X_test,y_test))

调用函数

X_train,X_test,y_train,y_test = load_data()
test_LinearRegression(X_train,X_test,y_train,y_test)

输出的结果

Coefficients:[   11.5106203   -282.51347161   534.20455671   401.73142674
 -1043.89718398   634.92464089   186.43262636   204.93373199
   762.47149733    91.9460394 ], intercept 152.56
Residual sum of squares: 3108.04
Score: 0.46

线性回归模型的正则化

岭回归和LASSO是目前最流行的两种线性回归正则化方法

  • Ridge Regression:正则化为αω22,α0\alpha||\pmb\omega||_2^2,\alpha \ge 0
  • Lasso Regression:正则化为αω1,α0\alpha ||\pmb \omega||_1,\alpha\ge 0
  • Elastic Net:正则化为αρω1+α(1ρ)2ω22,α0,1ρ0\alpha \rho||\pmb \omega||_1 + \frac{\alpha(1-\rho)}{2}||\pmb\omega||_2^2,\alpha \ge 0,1\ge \rho \ge 0

其中正则项系数α\alpha的选择十分关键,为learning rate

岭回归(Ridge Regression)

原型

Ridge(alpha=1.0, fit_intercept=True, normalize=False,copy_X=True, max_iter=None, tol=1e-3, solver="auto",random_state=None):

参数

  • alpha:α\alpha值,越大则正则化项占的比例越大
  • fit_intercept:是否计算b值
  • max_iter:一个整数,指定最大迭代次数
  • normlize:是否归一化
  • copy_X:是否复制X
  • solver:一个字符串,指定求解最优化问题的算法
    • auto:自动选择算法
    • svd:使用奇异值分解来计算回归系数
    • cholesky:使用scipy.linalg.solve函数来求解
    • sparse_cg:使用scipy.sparse.linalg.cg函数来求解
    • lsqr:使用scipy.sparse.linalg.lsqr函数来求解,运算速度快,但是老版本不支持
    • sag:使用Stochastic Average Gradient descent 算法那
  • tol:指定判断迭代收敛与否的阈值
  • random_state:一个整数或一个RandomState实例
    • 如果为整数,则指定随机数生成器的种子
    • 如果为RandomState,则使用指定的随机数生成器
    • 如果为None,则使用默认的随机数生成器

属性

  • coef_:权重向量
  • intercept_:b值
  • n_iter_:实际迭代次数

方法

同线性回归的方法

使用Ridge函数

def test_Ridge(*data):
    X_train,X_test,y_train,y_test = data
    regr = linear_model.Ridge()
    regr.fit(X_train,y_train)
    print("Coefficients:%s, intercept %.2f"%(regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" %regr.score(X_test,y_test))
   
X_train,X_test,y_train,y_test = load_data()
test_Ridge(X_train,X_test,y_train,y_test)

输出的结果如下

Coefficients:[  36.8262072   -75.80823733  282.42652716  207.39314972   -1.46580263
  -27.81750835 -134.3740951    98.97724793  222.67543268  117.97255343], intercept 152.55
Residual sum of squares: 3262.23
Score: 0.43

下面测试不同的α\alpha的值的预测性能的影响

def test_Ridge_alpha(*data):
    X_train, X_test, y_train, y_test = data
    #设置不同的alpha值
    alphas = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5,
        1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]
    scores = []
    for i, alpha in enumerate(alphas):
        regr = linear_model.Ridge(alpha=alpha)
        regr.fit(X_train, y_train)
        scores.append(regr.score(X_test, y_test))
  
    # 绘图
    fig=plt.figure()
    ax=fig.add_subplot(1, 1, 1)
    ax.plot(alphas, scores)
    ax.set_xlabel(r"$\alpha$")
    ax.set_ylabel(r"score")
    ax.set_xscale('log')
    ax.set_title("Ridge")
    plt.show()

在这里插入图片描述
α\alpha超过1之后,随着α\alpha的增长,预测性能急剧下降,因为α\alpha较大时,正则化项影像比较大,模型简单。

Lasso回归

Lasso回归与岭回归的区别在于它的惩罚项是基于L1L_1范数。他可以将系数控制收缩到0,从而达到变量选择的效果。

函数为Lasso()

参数:

之前已经叙述过的变量不在描述

  • precompute:是否提前计算Gram矩阵来加速计算
  • warm_start:从头训练还是使用前一次的训练结果继续训练
  • positive:如果为True,那么要求所有的权重向量的分量都是正数
  • selection:一个字符串,可以为‘cyclic’或者‘random’,选择权重向量的哪个分量来更新
    • random 更新的时候,随机选择权重向量的一个分量来更新
    • cyclic:更新的时候,从前向后依次选择权重向量的一个分量来更新。
def test_Lasso(*data):
    X_train, X_test, y_train, y_test = data
    regr = linear_model.Lasso()
    regr.fit(X_train, y_train)
    print("Coefficients:%s, intercept %.2f" % (regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" % regr.score(X_test, y_test))

结果

Coefficients:[  0.          -0.         384.73421807  72.69325545   0.
   0.          -0.           0.         247.88881314   0.        ], intercept 152.69
Residual sum of squares: 3646.84
Score: 0.37

测试不同α\alpha的影响

def test_Lasso_alpha(*data):
    X_train, X_test, y_train, y_test = data
    #设置不同的alpha值
    alphas = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5,
        1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]
    scores = []
    for i, alpha in enumerate(alphas):
        regr = linear_model.Lasso(alpha=alpha)
        regr.fit(X_train, y_train)
        scores.append(regr.score(X_test, y_test))
  
    # 绘图
    fig=plt.figure()
    ax=fig.add_subplot(1, 1, 1)
    ax.plot(alphas, scores)
    ax.set_xlabel(r"$\alpha$")
    ax.set_ylabel(r"score")
    ax.set_xscale('log')
    ax.set_title("Lasso")
    plt.show()

在这里插入图片描述

ELasticNet回归

ElasticNet回归是对Lasso回归和岭回归的融合。其惩罚项为L1L_1L2L_2范数的一个权衡。

def test_ElasticNet(*data):
    X_train, X_test, y_train, y_test = data
    regr = linear_model.ElasticNet()
    regr.fit(X_train, y_train)
    print("Coefficients:%s, intercept %.2f" % (regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" % regr.score(X_test, y_test))

输出的结果为

Coefficients:[ 0.21886047  0.          3.32172605  2.40903271  0.39329589  0.0813468
 -1.66664402  1.86756919  3.0113635   1.88112395], intercept 152.84
Residual sum of squares: 5704.63
Score: 0.01

对于不同的α,ρ\alpha,\rho

def test_ElasticNet_alpha_rho(*data):
    X_train, X_test, y_train, y_test = data
    alphas = np.logspace(-2,2)
    rhos = np.linspace(0.01, 1)
    scores = []
    for alpha in alphas:
        for rho in rhos:
            regr = linear_model.ElasticNet(alpha=alpha, l1_ratio= rho)
            regr.fit(X_train, y_train)
            scores.append(regr.score(X_test,y_test))

    # 绘图
    alphas,rhos = np.meshgrid(alphas, rhos)
    scores = np.array(scores).reshape(alphas.shape)
    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib import cm
    fig = plt.figure()
    ax = Axes3D(fig)
    surf = ax.plot_surface(alphas, rhos, scores, rstride=1, cstride=1, cmap=cm.jet, linewidth=0, antialiased = False)
    fig.colorbar(surf, shrink = 0.5, aspect=5)
    ax.set_xlabel(r"$\alpha$")
    ax.set_ylabel(r"$\rho$")
    ax.set_zlabel("score")
    ax.set_title("ElasticNet")
    plt.show()

在这里插入图片描述

所有代码

import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model, discriminant_analysis, model_selection


def load_data():
    diabetes = datasets.load_diabetes()
    # print(diabetes.DESCR)
    return model_selection.train_test_split(diabetes.data, diabetes.target, test_size=0.25, random_state=8)


def test_LinearRegression(*data):
    X_train, X_test, y_train, y_test = data
    regr = linear_model.LinearRegression()
    regr.fit(X_train, y_train)
    print("Coefficients:%s, intercept %.2f" % (regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %
          np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" % regr.score(X_test, y_test))


def test_Ridge(*data):
    X_train, X_test, y_train, y_test = data
    regr = linear_model.Ridge()
    regr.fit(X_train, y_train)
    print("Coefficients:%s, intercept %.2f" % (regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %
          np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" % regr.score(X_test, y_test))


def test_Ridge_alpha(*data):
    X_train, X_test, y_train, y_test = data
    #设置不同的alpha值
    alphas = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5,
        1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]
    scores = []
    for i, alpha in enumerate(alphas):
        regr = linear_model.Ridge(alpha=alpha)
        regr.fit(X_train, y_train)
        scores.append(regr.score(X_test, y_test))
  
    # 绘图
    fig=plt.figure()
    ax=fig.add_subplot(1, 1, 1)
    ax.plot(alphas, scores)
    ax.set_xlabel(r"$\alpha$")
    ax.set_ylabel(r"score")
    ax.set_xscale('log')
    ax.set_title("Ridge")
    plt.show()


def test_Lasso(*data):
    X_train, X_test, y_train, y_test = data
    regr = linear_model.Lasso()
    regr.fit(X_train, y_train)
    print("Coefficients:%s, intercept %.2f" % (regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" % regr.score(X_test, y_test))

def test_Lasso_alpha(*data):
    X_train, X_test, y_train, y_test = data
    #设置不同的alpha值
    alphas = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5,
        1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]
    scores = []
    for i, alpha in enumerate(alphas):
        regr = linear_model.Lasso(alpha=alpha)
        regr.fit(X_train, y_train)
        scores.append(regr.score(X_test, y_test))
  
    # 绘图
    fig=plt.figure()
    ax=fig.add_subplot(1, 1, 1)
    ax.plot(alphas, scores)
    ax.set_xlabel(r"$\alpha$")
    ax.set_ylabel(r"score")
    ax.set_xscale('log')
    ax.set_title("Lasso")
    plt.show()

def test_ElasticNet(*data):
    X_train, X_test, y_train, y_test = data
    regr = linear_model.ElasticNet()
    regr.fit(X_train, y_train)
    print("Coefficients:%s, intercept %.2f" % (regr.coef_, regr.intercept_))
    print("Residual sum of squares: %.2f" %np.mean((regr.predict(X_test)-y_test)**2))
    print("Score: %.2f" % regr.score(X_test, y_test))

def test_ElasticNet_alpha_rho(*data):
    X_train, X_test, y_train, y_test = data
    alphas = np.logspace(-2,2)
    rhos = np.linspace(0.01, 1)
    scores = []
    for alpha in alphas:
        for rho in rhos:
            regr = linear_model.ElasticNet(alpha=alpha, l1_ratio= rho)
            regr.fit(X_train, y_train)
            scores.append(regr.score(X_test,y_test))

    # 绘图
    alphas,rhos = np.meshgrid(alphas, rhos)
    scores = np.array(scores).reshape(alphas.shape)
    from mpl_toolkits.mplot3d import Axes3D
    from matplotlib import cm
    fig = plt.figure()
    ax = Axes3D(fig)
    surf = ax.plot_surface(alphas, rhos, scores, rstride=1, cstride=1, cmap=cm.jet, linewidth=0, antialiased = False)
    fig.colorbar(surf, shrink = 0.5, aspect=5)
    ax.set_xlabel(r"$\alpha$")
    ax.set_ylabel(r"$\rho$")
    ax.set_zlabel("score")
    ax.set_title("ElasticNet")
    plt.show()

if __name__ == '__main__':
    X_train, X_test, y_train, y_test=load_data()
    test_ElasticNet_alpha_rho(X_train,X_test,y_train,y_test)
   

2018-07-01 15:33:16 weixin_42429422 阅读数 387
  • 机器学习--线性回归数学推导视频教学

    线性回归数学推导是机器学习的基石,是人工智能的算法基础, 可以被广泛的应用在在工作和学习。本节课就带领同学们从零开始一步一步的推导线性回归。课程内容包括矩阵转换、误差值分析、似然函数、小二乘、结果推导。 任务作业: 设计并实现一个三层架构的员工管理系统。要求: 1、数据库及其表自行设计,遵循数据库及表设计的一般命名规则 2、要求有管理员的登录功能及对员工信息的增删改查 3、功能的实现严格采用三层架构的设计框架,注意命名的一般规范 4、采用B/S架构,界面大方美观 5、思考下三层架构与MVC框架有什么区别 (温馨提示: 注意 作业需写在CSDN博客中,请把作业链接贴在评论区,老师会定期逐个批改~~)

    3966 人正在学习 去看看 陆永剑

上一个笔记,我们大概了解了什么是机器学习以及机器学习的两个重要的分类,本篇笔记将带领大家了解机器学习的第一个模型——线性回归

例题

为了让大家更加直观的理解这个模型,我们引入一个例题,我们有一组波特兰市的城市住房的价格数据,我们要通过这些数据来找出一个函数,来预测任意面积下的房价,这就是一个简单的线性回归问题。

这里给出的数据是一组房子面积对应的房价
数据集
其中m代表训练集,x是输入,y是输出。我们用(x,y)来代表一个训练集,(x^i,y^i)代表第i行训练数据,比如x^2=2104.

我们训练的目的就是让我们假设一个函数h,使这个函数拟合我们的数据集。

代价函数

我们首先假设函数h(x)= θ0 + θ1x,其中θ0,θ1是这个模型需要变化的参数,我们主要就是训练这两个参数,让函数能达到我们预期的输入输出效果。

那么如何直观的表现出这个函数的拟合度呢,也就是这个函数的正确度,我们这里就引入了代价函数的概念。
代价函数
代价函数就是我们函数的输出值和相对应的真实值的方差,我们归回的目的就让方差最小化。

梯度下降

既然我们的目的已经明确了,就是让代价函数最小化,我们怎么才能达到这个目的呢, 我们这里使用梯度下降的方法来达到这个目的,这个方法被广泛应用到机器学习领域之中。梯度下降原理很简单,就是不停的改变θ0,θ1的值,让代价函数得到最小值或者局部最小值。首先我们来看看梯度下降是如何工作的:


这是一个代价函数的图像,首先我们先初始赋值θ0,θ1,在上图的位置标注好了。然后从这个点出发,不断的找到下降的方向,一步一步的下降,直到走到无法继续下降位置。此时的θ0,θ1值就是代价函数的最小值或者是局部最小值。

梯度下降

那么怎么用数学公式来表达这个梯度下降的过程呢,其实很简单,只要用这个公式就行了:
梯度下降公式
这个就是传说中的梯度下降公式,其实原理很简单,就是让参数等于这个参数减去学习率乘于参数的偏导。但要注意的是两个参数的值要同时变化,这个:=号是赋值的意思,不是等于号!!!。如何理解这个公式呢?我们可以选择删去一个参数,只用一个参数来梯度下降,来看一下这个公式的工作原理:

单参数梯度下降
首先假如我们初始赋值在图中位置,我们运用公式。这个偏导数就是这一点在函数中的斜率,我们用斜率来乘于学习率(待会我们再解释这个学习率),再用原θ1的值减去这个乘积,我们可以发现,其实就是向函数下降的方向走了一步,这个学习率就是我们走的一步的长度,学习率大,我们一步下降的就多,斜率大我们下降的也多,但是总的来看下降的步长还是看学习率,应为越是快到最小值,我们的斜率就越小,我们下降的就越慢,当到达最小值的时候,斜率就等于零,参数就停止移动了。我们可以看出图片上面给了当θ1大于或者小于最小值的情况下公式的运算情况,有兴趣的可以自己一步一步的计算试试看。

后记

通过我们得出的公式,你可以用完成一个完整的回归模型。接下来的笔记我会带大家学习,多个x输入情况下的回归建立。

2013-05-25 15:26:37 jzlxiaohei 阅读数 7456
  • 机器学习--线性回归数学推导视频教学

    线性回归数学推导是机器学习的基石,是人工智能的算法基础, 可以被广泛的应用在在工作和学习。本节课就带领同学们从零开始一步一步的推导线性回归。课程内容包括矩阵转换、误差值分析、似然函数、小二乘、结果推导。 任务作业: 设计并实现一个三层架构的员工管理系统。要求: 1、数据库及其表自行设计,遵循数据库及表设计的一般命名规则 2、要求有管理员的登录功能及对员工信息的增删改查 3、功能的实现严格采用三层架构的设计框架,注意命名的一般规范 4、采用B/S架构,界面大方美观 5、思考下三层架构与MVC框架有什么区别 (温馨提示: 注意 作业需写在CSDN博客中,请把作业链接贴在评论区,老师会定期逐个批改~~)

    3966 人正在学习 去看看 陆永剑

这个系列是我学习coursera上《机器学习》课程的笔记,边学边练。上面有一些习题,课程要求用Octave(或Matlab)完成,但是这两个软件太强大,掩盖了很多细节,而且我写Octave代码的时候,总有种支离破碎的感觉,最后还是用C#去实现了,果然不适合当科学家,还是老老实实作码农吧。

界面使用WPF,我还自己写了个做图表的库,本来准备好好写写的,但是真的是太烦,特别是API的设计,因为是第一次设计,各种问题,自己用着都觉得翔气逼人。。不过作为演示还是可以的,勿喷。。。

一、线性回归

1.理论说明:

线性回归:Wiki上说:在统计学中,线性回归是利用称为线性回归方程的最小二乘函数对一个或多个自变量和因变量之间关系进行建模的一种回归分析。

说白了,就是给你一大堆点,点由两个变量(先只考虑一元线性回归)决定;观察后,认为这两个变量应该是线性关系,于是就根据这堆点找出这个线性关系。

对于线性回归,有公式可以直接套,这里换种思路。

 

假设回归的函数为h(x) = a*x + b,这个是假设函数;回归的目的就是使假设函数靠谱,即对于测试数据(x1y1),把x1代入假设函数,算出h(y1),然后h(x1)y1越接近越好,两者的差距可以用( h(x1) - y1 )2来衡量。对于所有测试数据,就是求个和:

                             

这个求和的式子就是一元线性回归的cost function(不知要怎么翻译),θ代指参数(这里是θ0aθ1b)cost函数是与参数有关的函数,和xy无关(这话要好好理解一下)。前面的1/2是为了以后求导方便,对结果没有影响(也可以接着除以测试数据的个数m,即前面的系数为1/2m);上标i表示第i个测试数据。cost函数表征了假设的函数与实际数据的偏差。要使偏差最小,问题最终转化为最小化cost函数

看到这里,如果你高中数学学得还不错,应该能说一句:我艹,不就是令导数等于0吗!但是,这一句话,要转换成程序就不是很容易了。计算机最擅长迭代,可以换种思路:

打个比方,你从山上下去,你也不知道怎么走最好,环顾四周发现,左斜45度下去的方向下降的最快。好,走一步;然后从新环顾四周,发现直走一步,下去的最多,好,走一步。一直重复这个过程,直到你发现,四周海拔都比你高。如下图所示。

下山图

首先要解决的就是,这个方向怎么确定。针对这张图,这个方向是由θ0θ1共同确定的。沿θ0方向走一定长度,沿θ1方向走一定长度,两个向量相加,就确定了要下降的方向,即确定两个向量的长度比例即可。

实际上,这个方向是梯度的负方向。梯度方向,是函数上升最快的方向,那么负梯度方向当然就是下降最快的方向。关于梯度的推导和性质,可以参考高等数学的相关内容(记得是同济版高数书下册的空间几何相关章节,不确定)。这里直接给出其形式:

 

Jθ0求偏导,得到沿θ0方向前进的距离;Jθ1求偏导,得到沿θ1方向前进的距离;保持两个向量的比例,即确定了下一步的前进方向。

对于h=a* x + b的情况,假设这一步需要沿a方向走d(a)距离,沿b方向走的d(b)距离,那么在一次迭代中,只要下式同步更新ab的值,那么这次迭代后,J函数就沿下降最快的方向,走了一步

a := a + α * d(a)

 b: = b +α* d(b)

对于步长α,总的来说就是不能太大,也不要太少。有没有一种自然辨证法的感觉(⊙﹏⊙|汗)。想象一个二次曲线,如果步子太大,会直接把最低点夸过去,而且步子大了,还有可能扯着那啥;步子太小,收敛太慢。步长一般不是常数,是一个函数,就是说随着迭代的进行,它的值会变化。

迭代公式的思想其实很简单,就是:

下一个值 =当前值 +步长 *方向

这个式子可以高度概括最优化这门课一半以上的内容,有这个式子,这门课就可以及格了~ ~

 

 二:把数学公式写成程序的形式

数学公式太难输入,下面用写程序的方式对公式进行表示,请大家熟悉以下表述方法(对于24K纯屌丝码农,应该挺适应这种方式的~~):

J写成代码形式:

J = 1/2 * sum ( powOf2(h-y)  ) ;

Pd(J)来表示求偏导函数。按照这种方式,迭代公式可以写成如下形式:

θ := θ – step() * Pd(J)

 

三、迭代公式推导:

下面针对h=a * x + b的情况进行偏导计算,如果对推导过程不感兴趣,可以直接看下面的推导结果。不过,还是建议大家拿笔推一下。

首先对参数a进行求偏导:

Cost函数Ja求偏导:

Pda(J)  = sum(  ( h-y )*Pd(h-y)  )//链式求导法则

Pda(J)  = sum(  (a*x+b-y) * Pd(a*x-+b-y) ) //h=a * x + b代入

Pda(J)  =  sum( (a*x+b-y) * x  )//  a*x+b-ya求偏导后,得x

 

b求偏导

Pdb(J) =sum(  (a*x+b-y)*1 ) //可以认为b x0项的系数,x0是常数,等于1

写成数学式子,就是:

                             

四、推导结果:

如果对推导不感兴趣,直接看迭代的式子吧:

a := a – α * (a*x+b-y ) * x

b := b - α*  (a*x+b-y )

    有这个结果后,就可以写程序啦。

一头雾水吗?这说明,你还比较正常~~。现在你需要记住迭代公式的思想

下一个值 =当前值 +步长 *方向

下面通过代码来演示这一过程。

五、准备数据

下面实际上,就是完成Coursera上课程的编程练习1。具体信息大家可以去www.coursera.org 上去看。

ex1data1.txt中为需要回归的数据每一行2个数,以英文逗号分割。

 

  
  private void Button_Click_LoadData(object sender, RoutedEventArgs e)
        {
	    //点击load data按钮,装载数据
            LoadData(@"ex1data1.txt");//把ex1data1.txt直接放在Debug或Release目录下
        }

         private void LoadData(String fileName)
        {
            
            StreamReader sr = new StreamReader(fileName);
            String line = null;
            while((line = sr.ReadLine())!=null)
            {
                data.Add(ConvertToPoint2D(line.Split(',')));
            }
            sr.Close();
            //…后面是画图的部分,没有使用第三方控件,自己写的画图库,但是写的翔气熏天,大家看看知道干嘛就好,别深究,求大神轻虐
        }
	//ConvertToPoint2D函数就是把长度是2的字符串数组,转成point
	private Point ConvertToPoint2D(String[] ss)
        {
            if(ss.Length!=2)
                throw new ArgumentException("parameter should contains two string");
            return new Point(){X = Convert.ToDouble(ss[0]),Y=Convert.ToDouble(ss[1])};
        } 

 

结果见图

 

点击“线性回归”按钮后,得到结果,图和代码见下面:

 

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //h : a*x+b
            //cost function J : 1/2 * sum( Pow(a*x+b-y,2) )
            //J 对 a的偏导为 sum((a*x+b-y)*x)
            //J 对 a的偏导为 sum((a*x+b-y)*x)
            //
            //a := a - 0.01 * sum((a*x+b-y)*x)
            //b := b - 0.01 * sum((a*x+b-y))

            //a,b初始为0
            double a = 0;
            double b = 0;
            double m = data.Count;

            //StreamWriter sw =new StreamWriter(@"E:\result4.txt");
            List<double> cost =new List<double>();
            double d1 = 0, d2 = 0;
            double d3 = 0;
            /*判定停止的条件:
            1.cost function的值,变化足够小
            2.各个参数的值,变化均足够小
            3.迭代一定次数(这里简单的使用这一方法)
            4.whatever
            */
            for(int i=0;i<10000;i++)
            {

                d1 = data.Sum(pt => (a * pt.X + b - pt.Y) * pt.X)/m;
                d2 = data.Sum(pt => a * pt.X + b - pt.Y)/m;
                d3 = Math.Sqrt(d1 * d1 + d2 * d2);//用于把方向变成单位向量
  
                a = a -   0.01*d1 / d3;//步长定为0.01,实际上应该是个函数,这里进行了简化
                b = b -  0.01*d2 / d3;//步长的大小需要一样,以保证方向
                //a = a -  d1 / d3/(i+1);
                //b = b -  d2 / d3/(i+1);
                //把a,b和cost输出为文件
                //sw.WriteLine(String.Format("{0},{1},{2}",a,b,data.Sum(pt=>Math.Pow(a*pt.X+b-pt.Y,2))));
            }
            //sw.Close();
            List<Point> twoPoints = new List<Point>() { new Point(4, a * 4 + b), new Point(24, a * 24 + b) };
            LineSeries ls = new LineSeries();
            ls.ItemSource = twoPoints;
            this.chart.AddSeries(ls);
            this.chart.UpdateChart();
        }

总结一下回归步骤吧,这个流程很重要:

1. 找到假设函数H

2.找到合适的Cost函数J

3 最小化函数J,按照下面的思路:

        下一个值 =当前值 +步长 *方向

        如何定步长和方向是关键,可能需要不断的尝试

4.写程序,调试

 

下一节练习Logistic回归,本节Over

 

2017-10-18 09:32:23 kiooooo 阅读数 122
  • 机器学习--线性回归数学推导视频教学

    线性回归数学推导是机器学习的基石,是人工智能的算法基础, 可以被广泛的应用在在工作和学习。本节课就带领同学们从零开始一步一步的推导线性回归。课程内容包括矩阵转换、误差值分析、似然函数、小二乘、结果推导。 任务作业: 设计并实现一个三层架构的员工管理系统。要求: 1、数据库及其表自行设计,遵循数据库及表设计的一般命名规则 2、要求有管理员的登录功能及对员工信息的增删改查 3、功能的实现严格采用三层架构的设计框架,注意命名的一般规范 4、采用B/S架构,界面大方美观 5、思考下三层架构与MVC框架有什么区别 (温馨提示: 注意 作业需写在CSDN博客中,请把作业链接贴在评论区,老师会定期逐个批改~~)

    3966 人正在学习 去看看 陆永剑

第一周主要是对机器学习进行简单的介绍和线性回归的知识点:

一、Introduction

machine learning的举例
machine learning的举例

machine learning定义和例题

machine learning分类
- Supervised learning

right answer given,有标记的
1.regression:continuous(house price prediction)
2.classification:discrete(breast cancer:malignant or benign)
classification

-Unsupervised learning

无标记的,we’re not told what to do with and what each point is.
cluster
①Organize computing clusters
②Social network analysis
③Market segmentation
④Astronomical data analysis
cluster
例:Cocktail party problem (鸡尾酒会问题):
separate out these two audio sources that were being added or being summed together to form other recordings.
[W,s,v] = svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x’);

-Reinforcement learning(强化学习)
- recommender systems(推荐系统)

二、Linear regression with one variable

1.Model representation
这里写图片描述
这里写图片描述

2.Cost function
这里写图片描述

代价函数计算的主要代码块:
h=X*theta;
sqr=(h-y).^2;
J=sum(sqr)/(2*m);

h(x)
J

3.Gradient descent
这里写图片描述
这里写图片描述

4.Gradient descent for linear regression
梯度下降算法
梯度下降中theta计算的代码块:
h=X*theta;
error=h-y;
delta=X’*error/m;
theta=theta-alpha*delta;

三、Linear Algebra review

矩阵、向量的转置、相乘等线性代数的知识点回顾

2019-10-30 22:49:32 jintaohahahaha 阅读数 856
  • 机器学习--线性回归数学推导视频教学

    线性回归数学推导是机器学习的基石,是人工智能的算法基础, 可以被广泛的应用在在工作和学习。本节课就带领同学们从零开始一步一步的推导线性回归。课程内容包括矩阵转换、误差值分析、似然函数、小二乘、结果推导。 任务作业: 设计并实现一个三层架构的员工管理系统。要求: 1、数据库及其表自行设计,遵循数据库及表设计的一般命名规则 2、要求有管理员的登录功能及对员工信息的增删改查 3、功能的实现严格采用三层架构的设计框架,注意命名的一般规范 4、采用B/S架构,界面大方美观 5、思考下三层架构与MVC框架有什么区别 (温馨提示: 注意 作业需写在CSDN博客中,请把作业链接贴在评论区,老师会定期逐个批改~~)

    3966 人正在学习 去看看 陆永剑

一、前言

        保险公司对个人投保时或根据历史数据生成的模型来计算个人保费,那么本次我们就以这个模型的求解过程为例来实践下多元线性回归。

二、数据&简单分析

        我们已经获取到了一些数据(模拟数据),文件名为insurance.csv,文件内容如下。

        我们可以看出数据中共有六个维度:age(年龄),sex(性别),bmi(肥胖指数),children(孩子数量),smoker(是否吸烟),region(居住地)。charges则是当前数据人上年度在医院的花销。

        所以我们可以构建一个六维高维空间来求解这个模型。

age,sex,bmi,children,smoker,region,charges
19,female,27.9,0,yes,southwest,16884.924
18,male,33.77,1,no,southeast,1725.5523
28,male,33,3,no,southeast,4449.462
33,male,22.705,0,no,northwest,21984.47061
32,male,28.88,0,no,northwest,3866.8552
31,female,25.74,0,no,southeast,3756.6216
46,female,33.44,1,no,southeast,8240.5896
37,female,27.74,3,no,northwest,7281.5056
37,male,29.83,2,no,northeast,6406.4107
60,female,25.84,0,no,northwest,28923.13692
25,male,26.22,0,no,northeast,2721.3208
62,female,26.29,0,yes,southeast,27808.7251
23,male,34.4,0,no,southwest,1826.843
56,female,39.82,0,no,southeast,11090.7178
27,male,42.13,0,yes,southeast,39611.7577
19,male,24.6,1,no,southwest,1837.237
52,female,30.78,1,no,northeast,10797.3362
23,male,23.845,0,no,northeast,2395.17155
56,male,40.3,0,no,southwest,10602.385
30,male,35.3,0,yes,southwest,36837.467
60,female,36.005,0,no,northeast,13228.84695
30,female,32.4,1,no,southwest,4149.736
18,male,34.1,0,no,southeast,1137.011
34,female,31.92,1,yes,northeast,37701.8768
37,male,28.025,2,no,northwest,6203.90175
59,female,27.72,3,no,southeast,14001.1338
63,female,23.085,0,no,northeast,14451.83515
55,female,32.775,2,no,northwest,12268.63225
23,male,17.385,1,no,northwest,2775.19215
31,male,36.3,2,yes,southwest,38711
22,male,35.6,0,yes,southwest,35585.576
18,female,26.315,0,no,northeast,2198.18985
19,female,28.6,5,no,southwest,4687.797
63,male,28.31,0,no,northwest,13770.0979
28,male,36.4,1,yes,southwest,51194.55914
19,male,20.425,0,no,northwest,1625.43375
62,female,32.965,3,no,northwest,15612.19335
26,male,20.8,0,no,southwest,2302.3
35,male,36.67,1,yes,northeast,39774.2763
60,male,39.9,0,yes,southwest,48173.361
24,female,26.6,0,no,northeast,3046.062
31,female,36.63,2,no,southeast,4949.7587
41,male,21.78,1,no,southeast,6272.4772
37,female,30.8,2,no,southeast,6313.759
38,male,37.05,1,no,northeast,6079.6715
55,male,37.3,0,no,southwest,20630.28351
18,female,38.665,2,no,northeast,3393.35635
28,female,34.77,0,no,northwest,3556.9223
60,female,24.53,0,no,southeast,12629.8967
36,male,35.2,1,yes,southeast,38709.176
18,female,35.625,0,no,northeast,2211.13075
21,female,33.63,2,no,northwest,3579.8287
48,male,28,1,yes,southwest,23568.272
36,male,34.43,0,yes,southeast,37742.5757
40,female,28.69,3,no,northwest,8059.6791
58,male,36.955,2,yes,northwest,47496.49445
58,female,31.825,2,no,northeast,13607.36875
18,male,31.68,2,yes,southeast,34303.1672
53,female,22.88,1,yes,southeast,23244.7902
34,female,37.335,2,no,northwest,5989.52365
43,male,27.36,3,no,northeast,8606.2174
25,male,33.66,4,no,southeast,4504.6624
64,male,24.7,1,no,northwest,30166.61817
28,female,25.935,1,no,northwest,4133.64165
20,female,22.42,0,yes,northwest,14711.7438
19,female,28.9,0,no,southwest,1743.214
61,female,39.1,2,no,southwest,14235.072
40,male,26.315,1,no,northwest,6389.37785
40,female,36.19,0,no,southeast,5920.1041
28,male,23.98,3,yes,southeast,17663.1442
27,female,24.75,0,yes,southeast,16577.7795
31,male,28.5,5,no,northeast,6799.458
53,female,28.1,3,no,southwest,11741.726
58,male,32.01,1,no,southeast,11946.6259
44,male,27.4,2,no,southwest,7726.854
57,male,34.01,0,no,northwest,11356.6609
29,female,29.59,1,no,southeast,3947.4131
21,male,35.53,0,no,southeast,1532.4697
22,female,39.805,0,no,northeast,2755.02095
41,female,32.965,0,no,northwest,6571.02435
31,male,26.885,1,no,northeast,4441.21315
45,female,38.285,0,no,northeast,7935.29115
22,male,37.62,1,yes,southeast,37165.1638
48,female,41.23,4,no,northwest,11033.6617
37,female,34.8,2,yes,southwest,39836.519
45,male,22.895,2,yes,northwest,21098.55405
57,female,31.16,0,yes,northwest,43578.9394
56,female,27.2,0,no,southwest,11073.176
46,female,27.74,0,no,northwest,8026.6666
55,female,26.98,0,no,northwest,11082.5772
21,female,39.49,0,no,southeast,2026.9741
53,female,24.795,1,no,northwest,10942.13205
59,male,29.83,3,yes,northeast,30184.9367
35,male,34.77,2,no,northwest,5729.0053
64,female,31.3,2,yes,southwest,47291.055
28,female,37.62,1,no,southeast,3766.8838
54,female,30.8,3,no,southwest,12105.32
55,male,38.28,0,no,southeast,10226.2842
56,male,19.95,0,yes,northeast,22412.6485
38,male,19.3,0,yes,southwest,15820.699
41,female,31.6,0,no,southwest,6186.127
30,male,25.46,0,no,northeast,3645.0894
18,female,30.115,0,no,northeast,21344.8467
61,female,29.92,3,yes,southeast,30942.1918
34,female,27.5,1,no,southwest,5003.853
20,male,28.025,1,yes,northwest,17560.37975
19,female,28.4,1,no,southwest,2331.519
26,male,30.875,2,no,northwest,3877.30425
29,male,27.94,0,no,southeast,2867.1196
63,male,35.09,0,yes,southeast,47055.5321
54,male,33.63,1,no,northwest,10825.2537
55,female,29.7,2,no,southwest,11881.358
37,male,30.8,0,no,southwest,4646.759
21,female,35.72,0,no,northwest,2404.7338
52,male,32.205,3,no,northeast,11488.31695
60,male,28.595,0,no,northeast,30259.99556
58,male,49.06,0,no,southeast,11381.3254
29,female,27.94,1,yes,southeast,19107.7796
49,female,27.17,0,no,southeast,8601.3293
37,female,23.37,2,no,northwest,6686.4313
44,male,37.1,2,no,southwest,7740.337
18,male,23.75,0,no,northeast,1705.6245
20,female,28.975,0,no,northwest,2257.47525
44,male,31.35,1,yes,northeast,39556.4945
47,female,33.915,3,no,northwest,10115.00885
26,female,28.785,0,no,northeast,3385.39915
19,female,28.3,0,yes,southwest,17081.08
52,female,37.4,0,no,southwest,9634.538
32,female,17.765,2,yes,northwest,32734.1863
38,male,34.7,2,no,southwest,6082.405
59,female,26.505,0,no,northeast,12815.44495
61,female,22.04,0,no,northeast,13616.3586
53,female,35.9,2,no,southwest,11163.568
19,male,25.555,0,no,northwest,1632.56445
20,female,28.785,0,no,northeast,2457.21115
22,female,28.05,0,no,southeast,2155.6815
19,male,34.1,0,no,southwest,1261.442
22,male,25.175,0,no,northwest,2045.68525
54,female,31.9,3,no,southeast,27322.73386
22,female,36,0,no,southwest,2166.732
34,male,22.42,2,no,northeast,27375.90478
26,male,32.49,1,no,northeast,3490.5491
34,male,25.3,2,yes,southeast,18972.495
29,male,29.735,2,no,northwest,18157.876
30,male,28.69,3,yes,northwest,20745.9891
29,female,38.83,3,no,southeast,5138.2567
46,male,30.495,3,yes,northwest,40720.55105
51,female,37.73,1,no,southeast,9877.6077
53,female,37.43,1,no,northwest,10959.6947
19,male,28.4,1,no,southwest,1842.519
35,male,24.13,1,no,northwest,5125.2157
48,male,29.7,0,no,southeast,7789.635
32,female,37.145,3,no,northeast,6334.34355
42,female,23.37,0,yes,northeast,19964.7463
40,female,25.46,1,no,northeast,7077.1894
44,male,39.52,0,no,northwest,6948.7008
48,male,24.42,0,yes,southeast,21223.6758
18,male,25.175,0,yes,northeast,15518.18025
30,male,35.53,0,yes,southeast,36950.2567
50,female,27.83,3,no,southeast,19749.38338
42,female,26.6,0,yes,northwest,21348.706
18,female,36.85,0,yes,southeast,36149.4835
54,male,39.6,1,no,southwest,10450.552
32,female,29.8,2,no,southwest,5152.134
37,male,29.64,0,no,northwest,5028.1466
47,male,28.215,4,no,northeast,10407.08585
20,female,37,5,no,southwest,4830.63
32,female,33.155,3,no,northwest,6128.79745
19,female,31.825,1,no,northwest,2719.27975
27,male,18.905,3,no,northeast,4827.90495
63,male,41.47,0,no,southeast,13405.3903
49,male,30.3,0,no,southwest,8116.68
18,male,15.96,0,no,northeast,1694.7964
35,female,34.8,1,no,southwest,5246.047
24,female,33.345,0,no,northwest,2855.43755
63,female,37.7,0,yes,southwest,48824.45
38,male,27.835,2,no,northwest,6455.86265
54,male,29.2,1,no,southwest,10436.096
46,female,28.9,2,no,southwest,8823.279
41,female,33.155,3,no,northeast,8538.28845
58,male,28.595,0,no,northwest,11735.87905
18,female,38.28,0,no,southeast,1631.8212
22,male,19.95,3,no,northeast,4005.4225
44,female,26.41,0,no,northwest,7419.4779
44,male,30.69,2,no,southeast,7731.4271
36,male,41.895,3,yes,northeast,43753.33705
26,female,29.92,2,no,southeast,3981.9768
30,female,30.9,3,no,southwest,5325.651
41,female,32.2,1,no,southwest,6775.961
29,female,32.11,2,no,northwest,4922.9159
61,male,31.57,0,no,southeast,12557.6053
36,female,26.2,0,no,southwest,4883.866
25,male,25.74,0,no,southeast,2137.6536
56,female,26.6,1,no,northwest,12044.342
18,male,34.43,0,no,southeast,1137.4697
19,male,30.59,0,no,northwest,1639.5631
39,female,32.8,0,no,southwest,5649.715
45,female,28.6,2,no,southeast,8516.829
51,female,18.05,0,no,northwest,9644.2525
64,female,39.33,0,no,northeast,14901.5167
19,female,32.11,0,no,northwest,2130.6759
48,female,32.23,1,no,southeast,8871.1517
60,female,24.035,0,no,northwest,13012.20865
27,female,36.08,0,yes,southeast,37133.8982
46,male,22.3,0,no,southwest,7147.105
28,female,28.88,1,no,northeast,4337.7352
59,male,26.4,0,no,southeast,11743.299
35,male,27.74,2,yes,northeast,20984.0936
63,female,31.8,0,no,southwest,13880.949
40,male,41.23,1,no,northeast,6610.1097
20,male,33,1,no,southwest,1980.07
40,male,30.875,4,no,northwest,8162.71625
24,male,28.5,2,no,northwest,3537.703
34,female,26.73,1,no,southeast,5002.7827
45,female,30.9,2,no,southwest,8520.026
41,female,37.1,2,no,southwest,7371.772
53,female,26.6,0,no,northwest,10355.641
27,male,23.1,0,no,southeast,2483.736
26,female,29.92,1,no,southeast,3392.9768
24,female,23.21,0,no,southeast,25081.76784
34,female,33.7,1,no,southwest,5012.471
53,female,33.25,0,no,northeast,10564.8845
32,male,30.8,3,no,southwest,5253.524
19,male,34.8,0,yes,southwest,34779.615
42,male,24.64,0,yes,southeast,19515.5416
55,male,33.88,3,no,southeast,11987.1682
28,male,38.06,0,no,southeast,2689.4954
58,female,41.91,0,no,southeast,24227.33724
41,female,31.635,1,no,northeast,7358.17565
47,male,25.46,2,no,northeast,9225.2564
42,female,36.195,1,no,northwest,7443.64305
59,female,27.83,3,no,southeast,14001.2867
19,female,17.8,0,no,southwest,1727.785
59,male,27.5,1,no,southwest,12333.828
39,male,24.51,2,no,northwest,6710.1919
40,female,22.22,2,yes,southeast,19444.2658
18,female,26.73,0,no,southeast,1615.7667
31,male,38.39,2,no,southeast,4463.2051
19,male,29.07,0,yes,northwest,17352.6803
44,male,38.06,1,no,southeast,7152.6714
23,female,36.67,2,yes,northeast,38511.6283
33,female,22.135,1,no,northeast,5354.07465
55,female,26.8,1,no,southwest,35160.13457
40,male,35.3,3,no,southwest,7196.867
63,female,27.74,0,yes,northeast,29523.1656
54,male,30.02,0,no,northwest,24476.47851
60,female,38.06,0,no,southeast,12648.7034
24,male,35.86,0,no,southeast,1986.9334
19,male,20.9,1,no,southwest,1832.094
29,male,28.975,1,no,northeast,4040.55825
18,male,17.29,2,yes,northeast,12829.4551
63,female,32.2,2,yes,southwest,47305.305
54,male,34.21,2,yes,southeast,44260.7499
27,male,30.3,3,no,southwest,4260.744
50,male,31.825,0,yes,northeast,41097.16175
55,female,25.365,3,no,northeast,13047.33235
56,male,33.63,0,yes,northwest,43921.1837
38,female,40.15,0,no,southeast,5400.9805
51,male,24.415,4,no,northwest,11520.09985
19,male,31.92,0,yes,northwest,33750.2918
58,female,25.2,0,no,southwest,11837.16
20,female,26.84,1,yes,southeast,17085.2676
52,male,24.32,3,yes,northeast,24869.8368
19,male,36.955,0,yes,northwest,36219.40545
53,female,38.06,3,no,southeast,20462.99766
46,male,42.35,3,yes,southeast,46151.1245
40,male,19.8,1,yes,southeast,17179.522
59,female,32.395,3,no,northeast,14590.63205
45,male,30.2,1,no,southwest,7441.053
49,male,25.84,1,no,northeast,9282.4806
18,male,29.37,1,no,southeast,1719.4363
50,male,34.2,2,yes,southwest,42856.838
41,male,37.05,2,no,northwest,7265.7025
50,male,27.455,1,no,northeast,9617.66245
25,male,27.55,0,no,northwest,2523.1695
47,female,26.6,2,no,northeast,9715.841
19,male,20.615,2,no,northwest,2803.69785
22,female,24.3,0,no,southwest,2150.469
59,male,31.79,2,no,southeast,12928.7911
51,female,21.56,1,no,southeast,9855.1314
40,female,28.12,1,yes,northeast,22331.5668
54,male,40.565,3,yes,northeast,48549.17835
30,male,27.645,1,no,northeast,4237.12655
55,female,32.395,1,no,northeast,11879.10405
52,female,31.2,0,no,southwest,9625.92
46,male,26.62,1,no,southeast,7742.1098
46,female,48.07,2,no,northeast,9432.9253
63,female,26.22,0,no,northwest,14256.1928
59,female,36.765,1,yes,northeast,47896.79135
52,male,26.4,3,no,southeast,25992.82104
28,female,33.4,0,no,southwest,3172.018
29,male,29.64,1,no,northeast,20277.80751
25,male,45.54,2,yes,southeast,42112.2356
22,female,28.82,0,no,southeast,2156.7518
25,male,26.8,3,no,southwest,3906.127
18,male,22.99,0,no,northeast,1704.5681
19,male,27.7,0,yes,southwest,16297.846
47,male,25.41,1,yes,southeast,21978.6769
31,male,34.39,3,yes,northwest,38746.3551
48,female,28.88,1,no,northwest,9249.4952
36,male,27.55,3,no,northeast,6746.7425
53,female,22.61,3,yes,northeast,24873.3849
56,female,37.51,2,no,southeast,12265.5069
28,female,33,2,no,southeast,4349.462
57,female,38,2,no,southwest,12646.207
29,male,33.345,2,no,northwest,19442.3535
28,female,27.5,2,no,southwest,20177.67113
30,female,33.33,1,no,southeast,4151.0287
58,male,34.865,0,no,northeast,11944.59435
41,female,33.06,2,no,northwest,7749.1564
50,male,26.6,0,no,southwest,8444.474
19,female,24.7,0,no,southwest,1737.376
43,male,35.97,3,yes,southeast,42124.5153
49,male,35.86,0,no,southeast,8124.4084
27,female,31.4,0,yes,southwest,34838.873
52,male,33.25,0,no,northeast,9722.7695
50,male,32.205,0,no,northwest,8835.26495
54,male,32.775,0,no,northeast,10435.06525
44,female,27.645,0,no,northwest,7421.19455
32,male,37.335,1,no,northeast,4667.60765
34,male,25.27,1,no,northwest,4894.7533
26,female,29.64,4,no,northeast,24671.66334
34,male,30.8,0,yes,southwest,35491.64
57,male,40.945,0,no,northeast,11566.30055
29,male,27.2,0,no,southwest,2866.091
40,male,34.105,1,no,northeast,6600.20595
27,female,23.21,1,no,southeast,3561.8889
45,male,36.48,2,yes,northwest,42760.5022
64,female,33.8,1,yes,southwest,47928.03
52,male,36.7,0,no,southwest,9144.565
61,female,36.385,1,yes,northeast,48517.56315
52,male,27.36,0,yes,northwest,24393.6224
61,female,31.16,0,no,northwest,13429.0354
56,female,28.785,0,no,northeast,11658.37915
43,female,35.72,2,no,northeast,19144.57652
64,male,34.5,0,no,southwest,13822.803
60,male,25.74,0,no,southeast,12142.5786
62,male,27.55,1,no,northwest,13937.6665
50,male,32.3,1,yes,northeast,41919.097
46,female,27.72,1,no,southeast,8232.6388
24,female,27.6,0,no,southwest,18955.22017
62,male,30.02,0,no,northwest,13352.0998
60,female,27.55,0,no,northeast,13217.0945
63,male,36.765,0,no,northeast,13981.85035
49,female,41.47,4,no,southeast,10977.2063
34,female,29.26,3,no,southeast,6184.2994
33,male,35.75,2,no,southeast,4889.9995
46,male,33.345,1,no,northeast,8334.45755
36,female,29.92,1,no,southeast,5478.0368
19,male,27.835,0,no,northwest,1635.73365
57,female,23.18,0,no,northwest,11830.6072
50,female,25.6,0,no,southwest,8932.084
30,female,27.7,0,no,southwest,3554.203
33,male,35.245,0,no,northeast,12404.8791
18,female,38.28,0,no,southeast,14133.03775
46,male,27.6,0,no,southwest,24603.04837
46,male,43.89,3,no,southeast,8944.1151
47,male,29.83,3,no,northwest,9620.3307
23,male,41.91,0,no,southeast,1837.2819
18,female,20.79,0,no,southeast,1607.5101
48,female,32.3,2,no,northeast,10043.249
35,male,30.5,1,no,southwest,4751.07
19,female,21.7,0,yes,southwest,13844.506
21,female,26.4,1,no,southwest,2597.779
21,female,21.89,2,no,southeast,3180.5101
49,female,30.78,1,no,northeast,9778.3472
56,female,32.3,3,no,northeast,13430.265
42,female,24.985,2,no,northwest,8017.06115
44,male,32.015,2,no,northwest,8116.26885
18,male,30.4,3,no,northeast,3481.868
61,female,21.09,0,no,northwest,13415.0381
57,female,22.23,0,no,northeast,12029.2867
42,female,33.155,1,no,northeast,7639.41745
26,male,32.9,2,yes,southwest,36085.219
20,male,33.33,0,no,southeast,1391.5287
23,female,28.31,0,yes,northwest,18033.9679
39,female,24.89,3,yes,northeast,21659.9301
24,male,40.15,0,yes,southeast,38126.2465
64,female,30.115,3,no,northwest,16455.70785
62,male,31.46,1,no,southeast,27000.98473
27,female,17.955,2,yes,northeast,15006.57945
55,male,30.685,0,yes,northeast,42303.69215
55,male,33,0,no,southeast,20781.48892
35,female,43.34,2,no,southeast,5846.9176
44,male,22.135,2,no,northeast,8302.53565
19,male,34.4,0,no,southwest,1261.859
58,female,39.05,0,no,southeast,11856.4115
50,male,25.365,2,no,northwest,30284.64294
26,female,22.61,0,no,northwest,3176.8159
24,female,30.21,3,no,northwest,4618.0799
48,male,35.625,4,no,northeast,10736.87075
19,female,37.43,0,no,northwest,2138.0707
48,male,31.445,1,no,northeast,8964.06055
49,male,31.35,1,no,northeast,9290.1395
46,female,32.3,2,no,northeast,9411.005
46,male,19.855,0,no,northwest,7526.70645
43,female,34.4,3,no,southwest,8522.003
21,male,31.02,0,no,southeast,16586.49771
64,male,25.6,2,no,southwest,14988.432
18,female,38.17,0,no,southeast,1631.6683
51,female,20.6,0,no,southwest,9264.797
47,male,47.52,1,no,southeast,8083.9198
64,female,32.965,0,no,northwest,14692.66935
49,male,32.3,3,no,northwest,10269.46
31,male,20.4,0,no,southwest,3260.199
52,female,38.38,2,no,northeast,11396.9002
33,female,24.31,0,no,southeast,4185.0979
47,female,23.6,1,no,southwest,8539.671
38,male,21.12,3,no,southeast,6652.5288
32,male,30.03,1,no,southeast,4074.4537
19,male,17.48,0,no,northwest,1621.3402
44,female,20.235,1,yes,northeast,19594.80965
26,female,17.195,2,yes,northeast,14455.64405
25,male,23.9,5,no,southwest,5080.096
19,female,35.15,0,no,northwest,2134.9015
43,female,35.64,1,no,southeast,7345.7266
52,male,34.1,0,no,southeast,9140.951
36,female,22.6,2,yes,southwest,18608.262
64,male,39.16,1,no,southeast,14418.2804
63,female,26.98,0,yes,northwest,28950.4692
64,male,33.88,0,yes,southeast,46889.2612
61,male,35.86,0,yes,southeast,46599.1084
40,male,32.775,1,yes,northeast,39125.33225
25,male,30.59,0,no,northeast,2727.3951
48,male,30.2,2,no,southwest,8968.33
45,male,24.31,5,no,southeast,9788.8659
38,female,27.265,1,no,northeast,6555.07035
18,female,29.165,0,no,northeast,7323.734819
21,female,16.815,1,no,northeast,3167.45585
27,female,30.4,3,no,northwest,18804.7524
19,male,33.1,0,no,southwest,23082.95533
29,female,20.235,2,no,northwest,4906.40965
42,male,26.9,0,no,southwest,5969.723
60,female,30.5,0,no,southwest,12638.195
31,male,28.595,1,no,northwest,4243.59005
60,male,33.11,3,no,southeast,13919.8229
22,male,31.73,0,no,northeast,2254.7967
35,male,28.9,3,no,southwest,5926.846
52,female,46.75,5,no,southeast,12592.5345
26,male,29.45,0,no,northeast,2897.3235
31,female,32.68,1,no,northwest,4738.2682
33,female,33.5,0,yes,southwest,37079.372
18,male,43.01,0,no,southeast,1149.3959
59,female,36.52,1,no,southeast,28287.89766
56,male,26.695,1,yes,northwest,26109.32905
45,female,33.1,0,no,southwest,7345.084
60,male,29.64,0,no,northeast,12730.9996
56,female,25.65,0,no,northwest,11454.0215
40,female,29.6,0,no,southwest,5910.944
35,male,38.6,1,no,southwest,4762.329
39,male,29.6,4,no,southwest,7512.267
30,male,24.13,1,no,northwest,4032.2407
24,male,23.4,0,no,southwest,1969.614
20,male,29.735,0,no,northwest,1769.53165
32,male,46.53,2,no,southeast,4686.3887
59,male,37.4,0,no,southwest,21797.0004
55,female,30.14,2,no,southeast,11881.9696
57,female,30.495,0,no,northwest,11840.77505
56,male,39.6,0,no,southwest,10601.412
40,female,33,3,no,southeast,7682.67
49,female,36.63,3,no,southeast,10381.4787
42,male,30,0,yes,southwest,22144.032
62,female,38.095,2,no,northeast,15230.32405
56,male,25.935,0,no,northeast,11165.41765
19,male,25.175,0,no,northwest,1632.03625
30,female,28.38,1,yes,southeast,19521.9682
60,female,28.7,1,no,southwest,13224.693
56,female,33.82,2,no,northwest,12643.3778
28,female,24.32,1,no,northeast,23288.9284
18,female,24.09,1,no,southeast,2201.0971
27,male,32.67,0,no,southeast,2497.0383
18,female,30.115,0,no,northeast,2203.47185
19,female,29.8,0,no,southwest,1744.465
47,female,33.345,0,no,northeast,20878.78443
54,male,25.1,3,yes,southwest,25382.297
61,male,28.31,1,yes,northwest,28868.6639
24,male,28.5,0,yes,northeast,35147.52848
25,male,35.625,0,no,northwest,2534.39375
21,male,36.85,0,no,southeast,1534.3045
23,male,32.56,0,no,southeast,1824.2854
63,male,41.325,3,no,northwest,15555.18875
49,male,37.51,2,no,southeast,9304.7019
18,female,31.35,0,no,southeast,1622.1885
51,female,39.5,1,no,southwest,9880.068
48,male,34.3,3,no,southwest,9563.029
31,female,31.065,0,no,northeast,4347.02335
54,female,21.47,3,no,northwest,12475.3513
19,male,28.7,0,no,southwest,1253.936
44,female,38.06,0,yes,southeast,48885.13561
53,male,31.16,1,no,northwest,10461.9794
19,female,32.9,0,no,southwest,1748.774
61,female,25.08,0,no,southeast,24513.09126
18,female,25.08,0,no,northeast,2196.4732
61,male,43.4,0,no,southwest,12574.049
21,male,25.7,4,yes,southwest,17942.106
20,male,27.93,0,no,northeast,1967.0227
31,female,23.6,2,no,southwest,4931.647
45,male,28.7,2,no,southwest,8027.968
44,female,23.98,2,no,southeast,8211.1002
62,female,39.2,0,no,southwest,13470.86
29,male,34.4,0,yes,southwest,36197.699
43,male,26.03,0,no,northeast,6837.3687
51,male,23.21,1,yes,southeast,22218.1149
19,male,30.25,0,yes,southeast,32548.3405
38,female,28.93,1,no,southeast,5974.3847
37,male,30.875,3,no,northwest,6796.86325
22,male,31.35,1,no,northwest,2643.2685
21,male,23.75,2,no,northwest,3077.0955
24,female,25.27,0,no,northeast,3044.2133
57,female,28.7,0,no,southwest,11455.28
56,male,32.11,1,no,northeast,11763.0009
27,male,33.66,0,no,southeast,2498.4144
51,male,22.42,0,no,northeast,9361.3268
19,male,30.4,0,no,southwest,1256.299
39,male,28.3,1,yes,southwest,21082.16
58,male,35.7,0,no,southwest,11362.755
20,male,35.31,1,no,southeast,27724.28875
45,male,30.495,2,no,northwest,8413.46305
35,female,31,1,no,southwest,5240.765
31,male,30.875,0,no,northeast,3857.75925
50,female,27.36,0,no,northeast,25656.57526
32,female,44.22,0,no,southeast,3994.1778
51,female,33.915,0,no,northeast,9866.30485
38,female,37.73,0,no,southeast,5397.6167
42,male,26.07,1,yes,southeast,38245.59327
18,female,33.88,0,no,southeast,11482.63485
19,female,30.59,2,no,northwest,24059.68019
51,female,25.8,1,no,southwest,9861.025
46,male,39.425,1,no,northeast,8342.90875
18,male,25.46,0,no,northeast,1708.0014
57,male,42.13,1,yes,southeast,48675.5177
62,female,31.73,0,no,northeast,14043.4767
59,male,29.7,2,no,southeast,12925.886
37,male,36.19,0,no,southeast,19214.70553
64,male,40.48,0,no,southeast,13831.1152
38,male,28.025,1,no,northeast,6067.12675
33,female,38.9,3,no,southwest,5972.378
46,female,30.2,2,no,southwest,8825.086
46,female,28.05,1,no,southeast,8233.0975
53,male,31.35,0,no,southeast,27346.04207
34,female,38,3,no,southwest,6196.448
20,female,31.79,2,no,southeast,3056.3881
63,female,36.3,0,no,southeast,13887.204
54,female,47.41,0,yes,southeast,63770.42801
54,male,30.21,0,no,northwest,10231.4999
49,male,25.84,2,yes,northwest,23807.2406
28,male,35.435,0,no,northeast,3268.84665
54,female,46.7,2,no,southwest,11538.421
25,female,28.595,0,no,northeast,3213.62205
43,female,46.2,0,yes,southeast,45863.205
63,male,30.8,0,no,southwest,13390.559
32,female,28.93,0,no,southeast,3972.9247
62,male,21.4,0,no,southwest,12957.118
52,female,31.73,2,no,northwest,11187.6567
25,female,41.325,0,no,northeast,17878.90068
28,male,23.8,2,no,southwest,3847.674
46,male,33.44,1,no,northeast,8334.5896
34,male,34.21,0,no,southeast,3935.1799
35,female,34.105,3,yes,northwest,39983.42595
19,male,35.53,0,no,northwest,1646.4297
46,female,19.95,2,no,northwest,9193.8385
54,female,32.68,0,no,northeast,10923.9332
27,male,30.5,0,no,southwest,2494.022
50,male,44.77,1,no,southeast,9058.7303
18,female,32.12,2,no,southeast,2801.2588
19,female,30.495,0,no,northwest,2128.43105
38,female,40.565,1,no,northwest,6373.55735
41,male,30.59,2,no,northwest,7256.7231
49,female,31.9,5,no,southwest,11552.904
48,male,40.565,2,yes,northwest,45702.02235
31,female,29.1,0,no,southwest,3761.292
18,female,37.29,1,no,southeast,2219.4451
30,female,43.12,2,no,southeast,4753.6368
62,female,36.86,1,no,northeast,31620.00106
57,female,34.295,2,no,northeast,13224.05705
58,female,27.17,0,no,northwest,12222.8983
22,male,26.84,0,no,southeast,1664.9996
31,female,38.095,1,yes,northeast,58571.07448
52,male,30.2,1,no,southwest,9724.53
25,female,23.465,0,no,northeast,3206.49135
59,male,25.46,1,no,northeast,12913.9924
19,male,30.59,0,no,northwest,1639.5631
39,male,45.43,2,no,southeast,6356.2707
32,female,23.65,1,no,southeast,17626.23951
19,male,20.7,0,no,southwest,1242.816
33,female,28.27,1,no,southeast,4779.6023
21,male,20.235,3,no,northeast,3861.20965
34,female,30.21,1,yes,northwest,43943.8761
61,female,35.91,0,no,northeast,13635.6379
38,female,30.69,1,no,southeast,5976.8311
58,female,29,0,no,southwest,11842.442
47,male,19.57,1,no,northwest,8428.0693
20,male,31.13,2,no,southeast,2566.4707
21,female,21.85,1,yes,northeast,15359.1045
41,male,40.26,0,no,southeast,5709.1644
46,female,33.725,1,no,northeast,8823.98575
42,female,29.48,2,no,southeast,7640.3092
34,female,33.25,1,no,northeast,5594.8455
43,male,32.6,2,no,southwest,7441.501
52,female,37.525,2,no,northwest,33471.97189
18,female,39.16,0,no,southeast,1633.0444
51,male,31.635,0,no,northwest,9174.13565
56,female,25.3,0,no,southwest,11070.535
64,female,39.05,3,no,southeast,16085.1275
19,female,28.31,0,yes,northwest,17468.9839
51,female,34.1,0,no,southeast,9283.562
27,female,25.175,0,no,northeast,3558.62025
59,female,23.655,0,yes,northwest,25678.77845
28,male,26.98,2,no,northeast,4435.0942
30,male,37.8,2,yes,southwest,39241.442
47,female,29.37,1,no,southeast,8547.6913
38,female,34.8,2,no,southwest,6571.544
18,female,33.155,0,no,northeast,2207.69745
34,female,19,3,no,northeast,6753.038
20,female,33,0,no,southeast,1880.07
47,female,36.63,1,yes,southeast,42969.8527
56,female,28.595,0,no,northeast,11658.11505
49,male,25.6,2,yes,southwest,23306.547
19,female,33.11,0,yes,southeast,34439.8559
55,female,37.1,0,no,southwest,10713.644
30,male,31.4,1,no,southwest,3659.346
37,male,34.1,4,yes,southwest,40182.246
49,female,21.3,1,no,southwest,9182.17
18,male,33.535,0,yes,northeast,34617.84065
59,male,28.785,0,no,northwest,12129.61415
29,female,26.03,0,no,northwest,3736.4647
36,male,28.88,3,no,northeast,6748.5912
33,male,42.46,1,no,southeast,11326.71487
58,male,38,0,no,southwest,11365.952
44,female,38.95,0,yes,northwest,42983.4585
53,male,36.1,1,no,southwest,10085.846
24,male,29.3,0,no,southwest,1977.815
29,female,35.53,0,no,southeast,3366.6697
40,male,22.705,2,no,northeast,7173.35995
51,male,39.7,1,no,southwest,9391.346
64,male,38.19,0,no,northeast,14410.9321
19,female,24.51,1,no,northwest,2709.1119
35,female,38.095,2,no,northeast,24915.04626
39,male,26.41,0,yes,northeast,20149.3229
56,male,33.66,4,no,southeast,12949.1554
33,male,42.4,5,no,southwest,6666.243
42,male,28.31,3,yes,northwest,32787.45859
61,male,33.915,0,no,northeast,13143.86485
23,female,34.96,3,no,northwest,4466.6214
43,male,35.31,2,no,southeast,18806.14547
48,male,30.78,3,no,northeast,10141.1362
39,male,26.22,1,no,northwest,6123.5688
40,female,23.37,3,no,northeast,8252.2843
18,male,28.5,0,no,northeast,1712.227
58,female,32.965,0,no,northeast,12430.95335
49,female,42.68,2,no,southeast,9800.8882
53,female,39.6,1,no,southeast,10579.711
48,female,31.13,0,no,southeast,8280.6227
45,female,36.3,2,no,southeast,8527.532
59,female,35.2,0,no,southeast,12244.531
52,female,25.3,2,yes,southeast,24667.419
26,female,42.4,1,no,southwest,3410.324
27,male,33.155,2,no,northwest,4058.71245
48,female,35.91,1,no,northeast,26392.26029
57,female,28.785,4,no,northeast,14394.39815
37,male,46.53,3,no,southeast,6435.6237
57,female,23.98,1,no,southeast,22192.43711
32,female,31.54,1,no,northeast,5148.5526
18,male,33.66,0,no,southeast,1136.3994
64,female,22.99,0,yes,southeast,27037.9141
43,male,38.06,2,yes,southeast,42560.4304
49,male,28.7,1,no,southwest,8703.456
40,female,32.775,2,yes,northwest,40003.33225
62,male,32.015,0,yes,northeast,45710.20785
40,female,29.81,1,no,southeast,6500.2359
30,male,31.57,3,no,southeast,4837.5823
29,female,31.16,0,no,northeast,3943.5954
36,male,29.7,0,no,southeast,4399.731
41,female,31.02,0,no,southeast,6185.3208
44,female,43.89,2,yes,southeast,46200.9851
45,male,21.375,0,no,northwest,7222.78625
55,female,40.81,3,no,southeast,12485.8009
60,male,31.35,3,yes,northwest,46130.5265
56,male,36.1,3,no,southwest,12363.547
49,female,23.18,2,no,northwest,10156.7832
21,female,17.4,1,no,southwest,2585.269
19,male,20.3,0,no,southwest,1242.26
39,male,35.3,2,yes,southwest,40103.89
53,male,24.32,0,no,northwest,9863.4718
33,female,18.5,1,no,southwest,4766.022
53,male,26.41,2,no,northeast,11244.3769
42,male,26.125,2,no,northeast,7729.64575
40,male,41.69,0,no,southeast,5438.7491
47,female,24.1,1,no,southwest,26236.57997
27,male,31.13,1,yes,southeast,34806.4677
21,male,27.36,0,no,northeast,2104.1134
47,male,36.2,1,no,southwest,8068.185
20,male,32.395,1,no,northwest,2362.22905
24,male,23.655,0,no,northwest,2352.96845
27,female,34.8,1,no,southwest,3577.999
26,female,40.185,0,no,northwest,3201.24515
53,female,32.3,2,no,northeast,29186.48236
41,male,35.75,1,yes,southeast,40273.6455
56,male,33.725,0,no,northwest,10976.24575
23,female,39.27,2,no,southeast,3500.6123
21,female,34.87,0,no,southeast,2020.5523
50,female,44.745,0,no,northeast,9541.69555
53,male,41.47,0,no,southeast,9504.3103
34,female,26.41,1,no,northwest,5385.3379
47,female,29.545,1,no,northwest,8930.93455
33,female,32.9,2,no,southwest,5375.038
51,female,38.06,0,yes,southeast,44400.4064
49,male,28.69,3,no,northwest,10264.4421
31,female,30.495,3,no,northeast,6113.23105
36,female,27.74,0,no,northeast,5469.0066
18,male,35.2,1,no,southeast,1727.54
50,female,23.54,2,no,southeast,10107.2206
43,female,30.685,2,no,northwest,8310.83915
20,male,40.47,0,no,northeast,1984.4533
24,female,22.6,0,no,southwest,2457.502
60,male,28.9,0,no,southwest,12146.971
49,female,22.61,1,no,northwest,9566.9909
60,male,24.32,1,no,northwest,13112.6048
51,female,36.67,2,no,northwest,10848.1343
58,female,33.44,0,no,northwest,12231.6136
51,female,40.66,0,no,northeast,9875.6804
53,male,36.6,3,no,southwest,11264.541
62,male,37.4,0,no,southwest,12979.358
19,male,35.4,0,no,southwest,1263.249
50,female,27.075,1,no,northeast,10106.13425
30,female,39.05,3,yes,southeast,40932.4295
41,male,28.405,1,no,northwest,6664.68595
29,female,21.755,1,yes,northeast,16657.71745
18,female,40.28,0,no,northeast,2217.6012
41,female,36.08,1,no,southeast,6781.3542
35,male,24.42,3,yes,southeast,19361.9988
53,male,21.4,1,no,southwest,10065.413
24,female,30.1,3,no,southwest,4234.927
48,female,27.265,1,no,northeast,9447.25035
59,female,32.1,3,no,southwest,14007.222
49,female,34.77,1,no,northwest,9583.8933
37,female,38.39,0,yes,southeast,40419.0191
26,male,23.7,2,no,southwest,3484.331
23,male,31.73,3,yes,northeast,36189.1017
29,male,35.5,2,yes,southwest,44585.45587
45,male,24.035,2,no,northeast,8604.48365
27,male,29.15,0,yes,southeast,18246.4955
53,male,34.105,0,yes,northeast,43254.41795
31,female,26.62,0,no,southeast,3757.8448
50,male,26.41,0,no,northwest,8827.2099
50,female,30.115,1,no,northwest,9910.35985
34,male,27,2,no,southwest,11737.84884
19,male,21.755,0,no,northwest,1627.28245
47,female,36,1,no,southwest,8556.907
28,male,30.875,0,no,northwest,3062.50825
37,female,26.4,0,yes,southeast,19539.243
21,male,28.975,0,no,northwest,1906.35825
64,male,37.905,0,no,northwest,14210.53595
58,female,22.77,0,no,southeast,11833.7823
24,male,33.63,4,no,northeast,17128.42608
31,male,27.645,2,no,northeast,5031.26955
39,female,22.8,3,no,northeast,7985.815
47,female,27.83,0,yes,southeast,23065.4207
30,male,37.43,3,no,northeast,5428.7277
18,male,38.17,0,yes,southeast,36307.7983
22,female,34.58,2,no,northeast,3925.7582
23,male,35.2,1,no,southwest,2416.955
33,male,27.1,1,yes,southwest,19040.876
27,male,26.03,0,no,northeast,3070.8087
45,female,25.175,2,no,northeast,9095.06825
57,female,31.825,0,no,northwest,11842.62375
47,male,32.3,1,no,southwest,8062.764
42,female,29,1,no,southwest,7050.642
64,female,39.7,0,no,southwest,14319.031
38,female,19.475,2,no,northwest,6933.24225
61,male,36.1,3,no,southwest,27941.28758
53,female,26.7,2,no,southwest,11150.78
44,female,36.48,0,no,northeast,12797.20962
19,female,28.88,0,yes,northwest,17748.5062
41,male,34.2,2,no,northwest,7261.741
51,male,33.33,3,no,southeast,10560.4917
40,male,32.3,2,no,northwest,6986.697
45,male,39.805,0,no,northeast,7448.40395
35,male,34.32,3,no,southeast,5934.3798
53,male,28.88,0,no,northwest,9869.8102
30,male,24.4,3,yes,southwest,18259.216
18,male,41.14,0,no,southeast,1146.7966
51,male,35.97,1,no,southeast,9386.1613
50,female,27.6,1,yes,southwest,24520.264
31,female,29.26,1,no,southeast,4350.5144
35,female,27.7,3,no,southwest,6414.178
60,male,36.955,0,no,northeast,12741.16745
21,male,36.86,0,no,northwest,1917.3184
29,male,22.515,3,no,northeast,5209.57885
62,female,29.92,0,no,southeast,13457.9608
39,female,41.8,0,no,southeast,5662.225
19,male,27.6,0,no,southwest,1252.407
22,female,23.18,0,no,northeast,2731.9122
53,male,20.9,0,yes,southeast,21195.818
39,female,31.92,2,no,northwest,7209.4918
27,male,28.5,0,yes,northwest,18310.742
30,male,44.22,2,no,southeast,4266.1658
30,female,22.895,1,no,northeast,4719.52405
58,female,33.1,0,no,southwest,11848.141
33,male,24.795,0,yes,northeast,17904.52705
42,female,26.18,1,no,southeast,7046.7222
64,female,35.97,0,no,southeast,14313.8463
21,male,22.3,1,no,southwest,2103.08
18,female,42.24,0,yes,southeast,38792.6856
23,male,26.51,0,no,southeast,1815.8759
45,female,35.815,0,no,northwest,7731.85785
40,female,41.42,1,no,northwest,28476.73499
19,female,36.575,0,no,northwest,2136.88225
18,male,30.14,0,no,southeast,1131.5066
25,male,25.84,1,no,northeast,3309.7926
46,female,30.8,3,no,southwest,9414.92
33,female,42.94,3,no,northwest,6360.9936
54,male,21.01,2,no,southeast,11013.7119
28,male,22.515,2,no,northeast,4428.88785
36,male,34.43,2,no,southeast,5584.3057
20,female,31.46,0,no,southeast,1877.9294
24,female,24.225,0,no,northwest,2842.76075
23,male,37.1,3,no,southwest,3597.596
47,female,26.125,1,yes,northeast,23401.30575
33,female,35.53,0,yes,northwest,55135.40209
45,male,33.7,1,no,southwest,7445.918
26,male,17.67,0,no,northwest,2680.9493
18,female,31.13,0,no,southeast,1621.8827
44,female,29.81,2,no,southeast,8219.2039
60,male,24.32,0,no,northwest,12523.6048
64,female,31.825,2,no,northeast,16069.08475
56,male,31.79,2,yes,southeast,43813.8661
36,male,28.025,1,yes,northeast,20773.62775
41,male,30.78,3,yes,northeast,39597.4072
39,male,21.85,1,no,northwest,6117.4945
63,male,33.1,0,no,southwest,13393.756
36,female,25.84,0,no,northwest,5266.3656
28,female,23.845,2,no,northwest,4719.73655
58,male,34.39,0,no,northwest,11743.9341
36,male,33.82,1,no,northwest,5377.4578
42,male,35.97,2,no,southeast,7160.3303
36,male,31.5,0,no,southwest,4402.233
56,female,28.31,0,no,northeast,11657.7189
35,female,23.465,2,no,northeast,6402.29135
59,female,31.35,0,no,northwest,12622.1795
21,male,31.1,0,no,southwest,1526.312
59,male,24.7,0,no,northeast,12323.936
23,female,32.78,2,yes,southeast,36021.0112
57,female,29.81,0,yes,southeast,27533.9129
53,male,30.495,0,no,northeast,10072.05505
60,female,32.45,0,yes,southeast,45008.9555
51,female,34.2,1,no,southwest,9872.701
23,male,50.38,1,no,southeast,2438.0552
27,female,24.1,0,no,southwest,2974.126
55,male,32.775,0,no,northwest,10601.63225
37,female,30.78,0,yes,northeast,37270.1512
61,male,32.3,2,no,northwest,14119.62
46,female,35.53,0,yes,northeast,42111.6647
53,female,23.75,2,no,northeast,11729.6795
49,female,23.845,3,yes,northeast,24106.91255
20,female,29.6,0,no,southwest,1875.344
48,female,33.11,0,yes,southeast,40974.1649
25,male,24.13,0,yes,northwest,15817.9857
25,female,32.23,1,no,southeast,18218.16139
57,male,28.1,0,no,southwest,10965.446
37,female,47.6,2,yes,southwest,46113.511
38,female,28,3,no,southwest,7151.092
55,female,33.535,2,no,northwest,12269.68865
36,female,19.855,0,no,northeast,5458.04645
51,male,25.4,0,no,southwest,8782.469
40,male,29.9,2,no,southwest,6600.361
18,male,37.29,0,no,southeast,1141.4451
57,male,43.7,1,no,southwest,11576.13
61,male,23.655,0,no,northeast,13129.60345
25,female,24.3,3,no,southwest,4391.652
50,male,36.2,0,no,southwest,8457.818
26,female,29.48,1,no,southeast,3392.3652
42,male,24.86,0,no,southeast,5966.8874
43,male,30.1,1,no,southwest,6849.026
44,male,21.85,3,no,northeast,8891.1395
23,female,28.12,0,no,northwest,2690.1138
49,female,27.1,1,no,southwest,26140.3603
33,male,33.44,5,no,southeast,6653.7886
41,male,28.8,1,no,southwest,6282.235
37,female,29.5,2,no,southwest,6311.952
22,male,34.8,3,no,southwest,3443.064
23,male,27.36,1,no,northwest,2789.0574
21,female,22.135,0,no,northeast,2585.85065
51,female,37.05,3,yes,northeast,46255.1125
25,male,26.695,4,no,northwest,4877.98105
32,male,28.93,1,yes,southeast,19719.6947
57,male,28.975,0,yes,northeast,27218.43725
36,female,30.02,0,no,northwest,5272.1758
22,male,39.5,0,no,southwest,1682.597
57,male,33.63,1,no,northwest,11945.1327
64,female,26.885,0,yes,northwest,29330.98315
36,female,29.04,4,no,southeast,7243.8136
54,male,24.035,0,no,northeast,10422.91665
47,male,38.94,2,yes,southeast,44202.6536
62,male,32.11,0,no,northeast,13555.0049
61,female,44,0,no,southwest,13063.883
43,female,20.045,2,yes,northeast,19798.05455
19,male,25.555,1,no,northwest,2221.56445
18,female,40.26,0,no,southeast,1634.5734
19,female,22.515,0,no,northwest,2117.33885
49,male,22.515,0,no,northeast,8688.85885
60,male,40.92,0,yes,southeast,48673.5588
26,male,27.265,3,no,northeast,4661.28635
49,male,36.85,0,no,southeast,8125.7845
60,female,35.1,0,no,southwest,12644.589
26,female,29.355,2,no,northeast,4564.19145
27,male,32.585,3,no,northeast,4846.92015
44,female,32.34,1,no,southeast,7633.7206
63,male,39.8,3,no,southwest,15170.069
32,female,24.6,0,yes,southwest,17496.306
22,male,28.31,1,no,northwest,2639.0429
18,male,31.73,0,yes,northeast,33732.6867
59,female,26.695,3,no,northwest,14382.70905
44,female,27.5,1,no,southwest,7626.993
33,male,24.605,2,no,northwest,5257.50795
24,female,33.99,0,no,southeast,2473.3341
43,female,26.885,0,yes,northwest,21774.32215
45,male,22.895,0,yes,northeast,35069.37452
61,female,28.2,0,no,southwest,13041.921
35,female,34.21,1,no,southeast,5245.2269
62,female,25,0,no,southwest,13451.122
62,female,33.2,0,no,southwest,13462.52
38,male,31,1,no,southwest,5488.262
34,male,35.815,0,no,northwest,4320.41085
43,male,23.2,0,no,southwest,6250.435
50,male,32.11,2,no,northeast,25333.33284
19,female,23.4,2,no,southwest,2913.569
57,female,20.1,1,no,southwest,12032.326
62,female,39.16,0,no,southeast,13470.8044
41,male,34.21,1,no,southeast,6289.7549
26,male,46.53,1,no,southeast,2927.0647
39,female,32.5,1,no,southwest,6238.298
46,male,25.8,5,no,southwest,10096.97
45,female,35.3,0,no,southwest,7348.142
32,male,37.18,2,no,southeast,4673.3922
59,female,27.5,0,no,southwest,12233.828
44,male,29.735,2,no,northeast,32108.66282
39,female,24.225,5,no,northwest,8965.79575
18,male,26.18,2,no,southeast,2304.0022
53,male,29.48,0,no,southeast,9487.6442
18,male,23.21,0,no,southeast,1121.8739
50,female,46.09,1,no,southeast,9549.5651
18,female,40.185,0,no,northeast,2217.46915
19,male,22.61,0,no,northwest,1628.4709
62,male,39.93,0,no,southeast,12982.8747
56,female,35.8,1,no,southwest,11674.13
42,male,35.8,2,no,southwest,7160.094
37,male,34.2,1,yes,northeast,39047.285
42,male,31.255,0,no,northwest,6358.77645
25,male,29.7,3,yes,southwest,19933.458
57,male,18.335,0,no,northeast,11534.87265
51,male,42.9,2,yes,southeast,47462.894
30,female,28.405,1,no,northwest,4527.18295
44,male,30.2,2,yes,southwest,38998.546
34,male,27.835,1,yes,northwest,20009.63365
31,male,39.49,1,no,southeast,3875.7341
54,male,30.8,1,yes,southeast,41999.52
24,male,26.79,1,no,northwest,12609.88702
43,male,34.96,1,yes,northeast,41034.2214
48,male,36.67,1,no,northwest,28468.91901
19,female,39.615,1,no,northwest,2730.10785
29,female,25.9,0,no,southwest,3353.284
63,female,35.2,1,no,southeast,14474.675
46,male,24.795,3,no,northeast,9500.57305
52,male,36.765,2,no,northwest,26467.09737
35,male,27.1,1,no,southwest,4746.344
51,male,24.795,2,yes,northwest,23967.38305
44,male,25.365,1,no,northwest,7518.02535
21,male,25.745,2,no,northeast,3279.86855
39,female,34.32,5,no,southeast,8596.8278
50,female,28.16,3,no,southeast,10702.6424
34,female,23.56,0,no,northeast,4992.3764
22,female,20.235,0,no,northwest,2527.81865
19,female,40.5,0,no,southwest,1759.338
26,male,35.42,0,no,southeast,2322.6218
29,male,22.895,0,yes,northeast,16138.76205
48,male,40.15,0,no,southeast,7804.1605
26,male,29.15,1,no,southeast,2902.9065
45,female,39.995,3,no,northeast,9704.66805
36,female,29.92,0,no,southeast,4889.0368
54,male,25.46,1,no,northeast,25517.11363
34,male,21.375,0,no,northeast,4500.33925
31,male,25.9,3,yes,southwest,19199.944
27,female,30.59,1,no,northeast,16796.41194
20,male,30.115,5,no,northeast,4915.05985
44,female,25.8,1,no,southwest,7624.63
43,male,30.115,3,no,northwest,8410.04685
45,female,27.645,1,no,northwest,28340.18885
34,male,34.675,0,no,northeast,4518.82625
24,female,20.52,0,yes,northeast,14571.8908
26,female,19.8,1,no,southwest,3378.91
38,female,27.835,2,no,northeast,7144.86265
50,female,31.6,2,no,southwest,10118.424
38,male,28.27,1,no,southeast,5484.4673
27,female,20.045,3,yes,northwest,16420.49455
39,female,23.275,3,no,northeast,7986.47525
39,female,34.1,3,no,southwest,7418.522
63,female,36.85,0,no,southeast,13887.9685
33,female,36.29,3,no,northeast,6551.7501
36,female,26.885,0,no,northwest,5267.81815
30,male,22.99,2,yes,northwest,17361.7661
24,male,32.7,0,yes,southwest,34472.841
24,male,25.8,0,no,southwest,1972.95
48,male,29.6,0,no,southwest,21232.18226
47,male,19.19,1,no,northeast,8627.5411
29,male,31.73,2,no,northwest,4433.3877
28,male,29.26,2,no,northeast,4438.2634
47,male,28.215,3,yes,northwest,24915.22085
25,male,24.985,2,no,northeast,23241.47453
51,male,27.74,1,no,northeast,9957.7216
48,female,22.8,0,no,southwest,8269.044
43,male,20.13,2,yes,southeast,18767.7377
61,female,33.33,4,no,southeast,36580.28216
48,male,32.3,1,no,northwest,8765.249
38,female,27.6,0,no,southwest,5383.536
59,male,25.46,0,no,northwest,12124.9924
19,female,24.605,1,no,northwest,2709.24395
26,female,34.2,2,no,southwest,3987.926
54,female,35.815,3,no,northwest,12495.29085
21,female,32.68,2,no,northwest,26018.95052
51,male,37,0,no,southwest,8798.593
22,female,31.02,3,yes,southeast,35595.5898
47,male,36.08,1,yes,southeast,42211.1382
18,male,23.32,1,no,southeast,1711.0268
47,female,45.32,1,no,southeast,8569.8618
21,female,34.6,0,no,southwest,2020.177
19,male,26.03,1,yes,northwest,16450.8947
23,male,18.715,0,no,northwest,21595.38229
54,male,31.6,0,no,southwest,9850.432
37,female,17.29,2,no,northeast,6877.9801
46,female,23.655,1,yes,northwest,21677.28345
55,female,35.2,0,yes,southeast,44423.803
30,female,27.93,0,no,northeast,4137.5227
18,male,21.565,0,yes,northeast,13747.87235
61,male,38.38,0,no,northwest,12950.0712
54,female,23,3,no,southwest,12094.478
22,male,37.07,2,yes,southeast,37484.4493
45,female,30.495,1,yes,northwest,39725.51805
22,male,28.88,0,no,northeast,2250.8352
19,male,27.265,2,no,northwest,22493.65964
35,female,28.025,0,yes,northwest,20234.85475
18,male,23.085,0,no,northeast,1704.70015
20,male,30.685,0,yes,northeast,33475.81715
28,female,25.8,0,no,southwest,3161.454
55,male,35.245,1,no,northeast,11394.06555
43,female,24.7,2,yes,northwest,21880.82
43,female,25.08,0,no,northeast,7325.0482
22,male,52.58,1,yes,southeast,44501.3982
25,female,22.515,1,no,northwest,3594.17085
49,male,30.9,0,yes,southwest,39727.614
44,female,36.955,1,no,northwest,8023.13545
64,male,26.41,0,no,northeast,14394.5579
49,male,29.83,1,no,northeast,9288.0267
47,male,29.8,3,yes,southwest,25309.489
27,female,21.47,0,no,northwest,3353.4703
55,male,27.645,0,no,northwest,10594.50155
48,female,28.9,0,no,southwest,8277.523
45,female,31.79,0,no,southeast,17929.30337
24,female,39.49,0,no,southeast,2480.9791
32,male,33.82,1,no,northwest,4462.7218
24,male,32.01,0,no,southeast,1981.5819
57,male,27.94,1,no,southeast,11554.2236
59,male,41.14,1,yes,southeast,48970.2476
36,male,28.595,3,no,northwest,6548.19505
29,female,25.6,4,no,southwest,5708.867
42,female,25.3,1,no,southwest,7045.499
48,male,37.29,2,no,southeast,8978.1851
39,male,42.655,0,no,northeast,5757.41345
63,male,21.66,1,no,northwest,14349.8544
54,female,31.9,1,no,southeast,10928.849
37,male,37.07,1,yes,southeast,39871.7043
63,male,31.445,0,no,northeast,13974.45555
21,male,31.255,0,no,northwest,1909.52745
54,female,28.88,2,no,northeast,12096.6512
60,female,18.335,0,no,northeast,13204.28565
32,female,29.59,1,no,southeast,4562.8421
47,female,32,1,no,southwest,8551.347
21,male,26.03,0,no,northeast,2102.2647
28,male,31.68,0,yes,southeast,34672.1472
63,male,33.66,3,no,southeast,15161.5344
18,male,21.78,2,no,southeast,11884.04858
32,male,27.835,1,no,northwest,4454.40265
38,male,19.95,1,no,northwest,5855.9025
32,male,31.5,1,no,southwest,4076.497
62,female,30.495,2,no,northwest,15019.76005
39,female,18.3,5,yes,southwest,19023.26
55,male,28.975,0,no,northeast,10796.35025
57,male,31.54,0,no,northwest,11353.2276
52,male,47.74,1,no,southeast,9748.9106
56,male,22.1,0,no,southwest,10577.087
47,male,36.19,0,yes,southeast,41676.0811
55,female,29.83,0,no,northeast,11286.5387
23,male,32.7,3,no,southwest,3591.48
22,female,30.4,0,yes,northwest,33907.548
50,female,33.7,4,no,southwest,11299.343
18,female,31.35,4,no,northeast,4561.1885
51,female,34.96,2,yes,northeast,44641.1974
22,male,33.77,0,no,southeast,1674.6323
52,female,30.875,0,no,northeast,23045.56616
25,female,33.99,1,no,southeast,3227.1211
33,female,19.095,2,yes,northeast,16776.30405
53,male,28.6,3,no,southwest,11253.421
29,male,38.94,1,no,southeast,3471.4096
58,male,36.08,0,no,southeast,11363.2832
37,male,29.8,0,no,southwest,20420.60465
54,female,31.24,0,no,southeast,10338.9316
49,female,29.925,0,no,northwest,8988.15875
50,female,26.22,2,no,northwest,10493.9458
26,male,30,1,no,southwest,2904.088
45,male,20.35,3,no,southeast,8605.3615
54,female,32.3,1,no,northeast,11512.405
38,male,38.39,3,yes,southeast,41949.2441
48,female,25.85,3,yes,southeast,24180.9335
28,female,26.315,3,no,northwest,5312.16985
23,male,24.51,0,no,northeast,2396.0959
55,male,32.67,1,no,southeast,10807.4863
41,male,29.64,5,no,northeast,9222.4026
25,male,33.33,2,yes,southeast,36124.5737
33,male,35.75,1,yes,southeast,38282.7495
30,female,19.95,3,no,northwest,5693.4305
23,female,31.4,0,yes,southwest,34166.273
46,male,38.17,2,no,southeast,8347.1643
53,female,36.86,3,yes,northwest,46661.4424
27,female,32.395,1,no,northeast,18903.49141
23,female,42.75,1,yes,northeast,40904.1995
63,female,25.08,0,no,northwest,14254.6082
55,male,29.9,0,no,southwest,10214.636
35,female,35.86,2,no,southeast,5836.5204
34,male,32.8,1,no,southwest,14358.36437
19,female,18.6,0,no,southwest,1728.897
39,female,23.87,5,no,southeast,8582.3023
27,male,45.9,2,no,southwest,3693.428
57,male,40.28,0,no,northeast,20709.02034
52,female,18.335,0,no,northwest,9991.03765
28,male,33.82,0,no,northwest,19673.33573
50,female,28.12,3,no,northwest,11085.5868
44,female,25,1,no,southwest,7623.518
26,female,22.23,0,no,northwest,3176.2877
33,male,30.25,0,no,southeast,3704.3545
19,female,32.49,0,yes,northwest,36898.73308
50,male,37.07,1,no,southeast,9048.0273
41,female,32.6,3,no,southwest,7954.517
52,female,24.86,0,no,southeast,27117.99378
39,male,32.34,2,no,southeast,6338.0756
50,male,32.3,2,no,southwest,9630.397
52,male,32.775,3,no,northwest,11289.10925
60,male,32.8,0,yes,southwest,52590.82939
20,female,31.92,0,no,northwest,2261.5688
55,male,21.5,1,no,southwest,10791.96
42,male,34.1,0,no,southwest,5979.731
18,female,30.305,0,no,northeast,2203.73595
58,female,36.48,0,no,northwest,12235.8392
43,female,32.56,3,yes,southeast,40941.2854
35,female,35.815,1,no,northwest,5630.45785
48,female,27.93,4,no,northwest,11015.1747
36,female,22.135,3,no,northeast,7228.21565
19,male,44.88,0,yes,southeast,39722.7462
23,female,23.18,2,no,northwest,14426.07385
20,female,30.59,0,no,northeast,2459.7201
32,female,41.1,0,no,southwest,3989.841
43,female,34.58,1,no,northwest,7727.2532
34,male,42.13,2,no,southeast,5124.1887
30,male,38.83,1,no,southeast,18963.17192
18,female,28.215,0,no,northeast,2200.83085
41,female,28.31,1,no,northwest,7153.5539
35,female,26.125,0,no,northeast,5227.98875
57,male,40.37,0,no,southeast,10982.5013
29,female,24.6,2,no,southwest,4529.477
32,male,35.2,2,no,southwest,4670.64
37,female,34.105,1,no,northwest,6112.35295
18,male,27.36,1,yes,northeast,17178.6824
43,female,26.7,2,yes,southwest,22478.6
56,female,41.91,0,no,southeast,11093.6229
38,male,29.26,2,no,northwest,6457.8434
29,male,32.11,2,no,northwest,4433.9159
22,female,27.1,0,no,southwest,2154.361
52,female,24.13,1,yes,northwest,23887.6627
40,female,27.4,1,no,southwest,6496.886
23,female,34.865,0,no,northeast,2899.48935
31,male,29.81,0,yes,southeast,19350.3689
42,female,41.325,1,no,northeast,7650.77375
24,female,29.925,0,no,northwest,2850.68375
25,female,30.3,0,no,southwest,2632.992
48,female,27.36,1,no,northeast,9447.3824
23,female,28.49,1,yes,southeast,18328.2381
45,male,23.56,2,no,northeast,8603.8234
20,male,35.625,3,yes,northwest,37465.34375
62,female,32.68,0,no,northwest,13844.7972
43,female,25.27,1,yes,northeast,21771.3423
23,female,28,0,no,southwest,13126.67745
31,female,32.775,2,no,northwest,5327.40025
41,female,21.755,1,no,northeast,13725.47184
58,female,32.395,1,no,northeast,13019.16105
48,female,36.575,0,no,northwest,8671.19125
31,female,21.755,0,no,northwest,4134.08245
19,female,27.93,3,no,northwest,18838.70366
19,female,30.02,0,yes,northwest,33307.5508
41,male,33.55,0,no,southeast,5699.8375
40,male,29.355,1,no,northwest,6393.60345
31,female,25.8,2,no,southwest,4934.705
37,male,24.32,2,no,northwest,6198.7518
46,male,40.375,2,no,northwest,8733.22925
22,male,32.11,0,no,northwest,2055.3249
51,male,32.3,1,no,northeast,9964.06
18,female,27.28,3,yes,southeast,18223.4512
35,male,17.86,1,no,northwest,5116.5004
59,female,34.8,2,no,southwest,36910.60803
36,male,33.4,2,yes,southwest,38415.474
37,female,25.555,1,yes,northeast,20296.86345
59,male,37.1,1,no,southwest,12347.172
36,male,30.875,1,no,northwest,5373.36425
39,male,34.1,2,no,southeast,23563.01618
18,male,21.47,0,no,northeast,1702.4553
52,female,33.3,2,no,southwest,10806.839
27,female,31.255,1,no,northwest,3956.07145
18,male,39.14,0,no,northeast,12890.05765
40,male,25.08,0,no,southeast,5415.6612
29,male,37.29,2,no,southeast,4058.1161
46,female,34.6,1,yes,southwest,41661.602
38,female,30.21,3,no,northwest,7537.1639
30,female,21.945,1,no,northeast,4718.20355
40,male,24.97,2,no,southeast,6593.5083
50,male,25.3,0,no,southeast,8442.667
20,female,24.42,0,yes,southeast,26125.67477
41,male,23.94,1,no,northeast,6858.4796
33,female,39.82,1,no,southeast,4795.6568
38,male,16.815,2,no,northeast,6640.54485
42,male,37.18,2,no,southeast,7162.0122
56,male,34.43,0,no,southeast,10594.2257
58,male,30.305,0,no,northeast,11938.25595
52,male,34.485,3,yes,northwest,60021.39897
20,female,21.8,0,yes,southwest,20167.33603
54,female,24.605,3,no,northwest,12479.70895
58,male,23.3,0,no,southwest,11345.519
45,female,27.83,2,no,southeast,8515.7587
26,male,31.065,0,no,northwest,2699.56835
63,female,21.66,0,no,northeast,14449.8544
58,female,28.215,0,no,northwest,12224.35085
37,male,22.705,3,no,northeast,6985.50695
25,female,42.13,1,no,southeast,3238.4357
52,male,41.8,2,yes,southeast,47269.854
64,male,36.96,2,yes,southeast,49577.6624
22,female,21.28,3,no,northwest,4296.2712
28,female,33.11,0,no,southeast,3171.6149
18,male,33.33,0,no,southeast,1135.9407
28,male,24.3,5,no,southwest,5615.369
45,female,25.7,3,no,southwest,9101.798
33,male,29.4,4,no,southwest,6059.173
18,female,39.82,0,no,southeast,1633.9618
32,male,33.63,1,yes,northeast,37607.5277
24,male,29.83,0,yes,northeast,18648.4217
19,male,19.8,0,no,southwest,1241.565
20,male,27.3,0,yes,southwest,16232.847
40,female,29.3,4,no,southwest,15828.82173
34,female,27.72,0,no,southeast,4415.1588
42,female,37.9,0,no,southwest,6474.013
51,female,36.385,3,no,northwest,11436.73815
54,female,27.645,1,no,northwest,11305.93455
55,male,37.715,3,no,northwest,30063.58055
52,female,23.18,0,no,northeast,10197.7722
32,female,20.52,0,no,northeast,4544.2348
28,male,37.1,1,no,southwest,3277.161
41,female,28.05,1,no,southeast,6770.1925
43,female,29.9,1,no,southwest,7337.748
49,female,33.345,2,no,northeast,10370.91255
64,male,23.76,0,yes,southeast,26926.5144
55,female,30.5,0,no,southwest,10704.47
24,male,31.065,0,yes,northeast,34254.05335
20,female,33.3,0,no,southwest,1880.487
45,male,27.5,3,no,southwest,8615.3
26,male,33.915,1,no,northwest,3292.52985
25,female,34.485,0,no,northwest,3021.80915
43,male,25.52,5,no,southeast,14478.33015
35,male,27.61,1,no,southeast,4747.0529
26,male,27.06,0,yes,southeast,17043.3414
57,male,23.7,0,no,southwest,10959.33
22,female,30.4,0,no,northeast,2741.948
32,female,29.735,0,no,northwest,4357.04365
39,male,29.925,1,yes,northeast,22462.04375
25,female,26.79,2,no,northwest,4189.1131
48,female,33.33,0,no,southeast,8283.6807
47,female,27.645,2,yes,northwest,24535.69855
18,female,21.66,0,yes,northeast,14283.4594
18,male,30.03,1,no,southeast,1720.3537
61,male,36.3,1,yes,southwest,47403.88
47,female,24.32,0,no,northeast,8534.6718
28,female,17.29,0,no,northeast,3732.6251
36,female,25.9,1,no,southwest,5472.449
20,male,39.4,2,yes,southwest,38344.566
44,male,34.32,1,no,southeast,7147.4728
38,female,19.95,2,no,northeast,7133.9025
19,male,34.9,0,yes,southwest,34828.654
21,male,23.21,0,no,southeast,1515.3449
46,male,25.745,3,no,northwest,9301.89355
58,male,25.175,0,no,northeast,11931.12525
20,male,22,1,no,southwest,1964.78
18,male,26.125,0,no,northeast,1708.92575
28,female,26.51,2,no,southeast,4340.4409
33,male,27.455,2,no,northwest,5261.46945
19,female,25.745,1,no,northwest,2710.82855
45,male,30.36,0,yes,southeast,62592.87309
62,male,30.875,3,yes,northwest,46718.16325
25,female,20.8,1,no,southwest,3208.787
43,male,27.8,0,yes,southwest,37829.7242
42,male,24.605,2,yes,northeast,21259.37795
24,female,27.72,0,no,southeast,2464.6188
29,female,21.85,0,yes,northeast,16115.3045
32,male,28.12,4,yes,northwest,21472.4788
25,female,30.2,0,yes,southwest,33900.653
41,male,32.2,2,no,southwest,6875.961
42,male,26.315,1,no,northwest,6940.90985
33,female,26.695,0,no,northwest,4571.41305
34,male,42.9,1,no,southwest,4536.259
19,female,34.7,2,yes,southwest,36397.576
30,female,23.655,3,yes,northwest,18765.87545
18,male,28.31,1,no,northeast,11272.33139
19,female,20.6,0,no,southwest,1731.677
18,male,53.13,0,no,southeast,1163.4627
35,male,39.71,4,no,northeast,19496.71917
39,female,26.315,2,no,northwest,7201.70085
31,male,31.065,3,no,northwest,5425.02335
62,male,26.695,0,yes,northeast,28101.33305
62,male,38.83,0,no,southeast,12981.3457
42,female,40.37,2,yes,southeast,43896.3763
31,male,25.935,1,no,northwest,4239.89265
61,male,33.535,0,no,northeast,13143.33665
42,female,32.87,0,no,northeast,7050.0213
51,male,30.03,1,no,southeast,9377.9047
23,female,24.225,2,no,northeast,22395.74424
52,male,38.6,2,no,southwest,10325.206
57,female,25.74,2,no,southeast,12629.1656
23,female,33.4,0,no,southwest,10795.93733
52,female,44.7,3,no,southwest,11411.685
50,male,30.97,3,no,northwest,10600.5483
18,female,31.92,0,no,northeast,2205.9808
18,female,36.85,0,no,southeast,1629.8335
21,female,25.8,0,no,southwest,2007.945
61,female,29.07,0,yes,northwest,29141.3603

三、模型构建

        我们定义六个维度X1到X6,分别代表age到region。其中给Xn设置一个βn作为模型变量。定义Y表示charges。

四、使用R语言求解模型

        我们先准备好insurance.csv数据文件放入RStudio工作空间中。打开RStudio。

        编辑代码如下:

insurance <- read.csv("insurance.csv", stringsAsFactors = TRUE)
str(insurance)

#既然因变量是charges,我们就来看一下它是如何分布的
summary(insurance$charges)
hist(insurance$charges)

table(insurance$region)
cor(insurance[c("age","bmi","children","charges")])
pairs(insurance[c("age","bmi","children","charges")])

library("psych")
pairs.panels(insurance[c("age","bmi","children","charges")])

ins_model <- lm(charges ~ age + children + bmi + sex + smoker + region, data=insurance)
ins_model <- lm(charges ~ . , data=insurance)
ins_model
summary(ins_model)

insurance$age2 <- insurance$age^2
insurance$bmi30 <- ifelse(insurance$bmi >= 30, 1, 0)

ins_models <- lm(charges ~ age + age2 + children + bmi + sex + bmi30*smoker + region , data=insurance)
summary(ins_models)

五、代码分析

1、读取文件

         执行下方代码,读取历史数据文件。

         insurance <- read.csv("insurance.csv", stringsAsFactors = TRUE)

        结果如下图,我们已经将insurance.csv内容读取到了变量insurance中。

        

2、转换数据类型

        执行下方命令将insurance中数据转换为因子类型。

        str(insurance)

        执行后结果如下

       

3、 分析报销情况

        执行下方命令分析报销情况

        summary(insurance$charges)

        执行后结果如下图

       

        其中红框所示为执行结果,其由左至右依次显示最小值数、1/4位数、中位数、平均值、3/4位数、最大数。

4、查看柱状图

        执行下方命令查看柱状图

        hist(insurance$charges)

        执行后结果如下图

       

        我们可以看到红框所示为对报销情况统计的柱状图。

5、查看地区分布

       执行下方命令,查看地区分布情况

        table(insurance$region)

        执行结果如下图

       

       我们可以看出,东北、戏本、东南、西南人数样本分布还是比较均匀的。

6、求相关系数

        执行下方命令,查看维度之间相关系数

        cor(insurance[c("age","bmi","children","charges")])

        执行结果如下图

       

         从图示表中可以看到年龄、肥胖系数、孩子数量、报销费用之间的相关系数

7、获取散点矩阵图

        执行下方命令,查看维度之间的散点矩阵图

        pairs(insurance[c("age","bmi","children","charges")])

        执行结果如下图

8、引入第三方软件包,求解相关系数及其散点矩阵图

        执行下方操作

        8.1、如下图引入第三方软件包

        8.2、执行下方命令

        library("psych")
        pairs.panels(insurance[c("age","bmi","children","charges")])

       

        简单分析一下图中数据,

        以左上到右下为中轴线,上半部分为各个维度之间的相关系数。相关系数越趋近于1代表越正相关,越趋近于-1代表越负相关,越趋近于0代表不相关。因此我们可以利用相关系数进行降维,将一些不相关的维度剔除。

        由上图可以看出年龄、肥胖指数与保费成正相关,分别为0.3和0.2。这也符合我们的预期,年龄越大、肥胖指数越高,医院花销就越高。

8.3、执行下方命令

        ins_model <- lm(charges ~ age + children + bmi + sex + smoker + region, data=insurance)

        或

        ins_model <- lm(charges ~ . , data=insurance)
        得到下图所示结果,其中coefficients就是系数。这样看起来不太直观,我们可以按照8.3步将ins_model打印出来。

8.4、打印ins_model

        ins_model

        下图中就很明显的显示了各个维度的系数。其中age=256.9表示年龄每增长1岁,每年就要多支出256.9的医疗费;sexmale=-131.3表示male要比female少交131.3的医疗费;bmi=339.2表示肥胖指数每增加一个点就要多交339.2的医疗费;children475.5表示孩子数量每增加一个每年就多支出475.5的医疗费;smokeryes=23848.5表示抽烟的要比不抽烟的多支出23848.5的医疗费;regionnorthwest、regionsoutheast、regionsouthwest是与southwest比较而言的,与sexmale类似。

        那么问题来了,为什么sex、smoker和region被区分开了,其余维度没有被区分开。其实因为之前我们定义数据时将sex、smoker和region定义成了因子类型,其余都是数值类型。

 

8.5、打印模型统计摘要

        summary(ins_model)

8.6、模型优化

        为了使数据更好的回归线性,我们可以在模型数据中新增两个列,其中age2值为age的平方,bmi30代表肥胖指数是否大于30(大于30才算真正的肥胖,低于30成为不肥胖)

        insurance$age2 <- insurance$age^2

        insurance$bmi30 <- ifelse(insurance$bmi >= 30, 1, 0)

8.7、运算模型

        ins_models <- lm(charges ~ age + age2 + children + bmi + sex + bmi30*smoker + region , data=insurance)

        这里引入了我们的age2和bim30,这称之为升维度。但是为什么要用bmi30*smoker呢,因为在很了解数据的前提下,我们知道肥胖且抽烟会导致医疗费用支出增大,单一的一项并没有很明显的影响。因此就使用了bmi30*smoker。

8.8、打印优化后模型统计摘要

        summary(ins_models)

        从下图可以看出升维的age2和bmi30相关性很大,这也证实了本次模型优化是成功的。

 

       

没有更多推荐了,返回首页