zoukankan      html  css  js  c++  java
  • Graphlab Linear Regression --House Price Predict

    Graphlab:一个基于图像处理模型的开源图计算框架,GraphLab是面向机器学习的流处理并行框架

    Graphlab 安装: Python必须是64位 , virtualenv 可以不装,Graphlab  安装在python安装所在的路径我这是在D盘

    以下code运行在ipython notebook上

    code :

    import graphlab
    sales = graphlab.SFrame('D:Studypythonspydepyodpshome_datahome_data.gl')
    print sales.head(10)

    graphlab.canvas.set_target('ipynb')
    sales.show(view = 'Scatter Plot',x = 'sqft_living',y = 'price')

    #将数据分成训练和测试两部分

    training_data,test_data = sales.random_split(.8,seed = 0)

    #features是变量,选取比较单一的变量做线性规划

    sqft_model = graphlab.linear_regression.create(training_data,target = 'price',features = ['sqft_living'])

    #对单一变量建立的模型进行评测

    print test_data['price'].mean()

    print sqft_model.evaluate(test_data)

    #显示模型效果

    import matplotlib.pyplot as plt
    %matplotlib inline

    plt.plot(test_data['sqft_living'],test_data['price'],'.',test_data['sqft_living'],sqft_model.predict(test_data),'-')

    #建立新的变量元素

    my_features = ['bedrooms','bathrooms','sqft_living','sqft_lot','floors','zipcode']
    sales[my_features].show()

    sales.show(view = 'BoxWhisker Plot', x = 'zipcode' ,y= 'price')

    #由多元素建立的新模型

    my_features_model = graphlab.linear_regression.create(training_data,target = 'price',features = my_features

    #显示新模型效果评估

    print sqft_model.evaluate(test_data)
    print my_features_model.evaluate(test_data)

    #两个模型显示对比

    plt.plot(test_data['sqft_living'],test_data['price'],'.',test_data['sqft_living'],sqft_model.predict(test_data),
    '-',test_data['sqft_living'],my_features_model.predict(test_data),'*')

  • 相关阅读:
    vue-cli+typescript 搭建
    es6基础知识
    上机作业六 磁盘管理综合测试2019 7 31
    上机作业五 磁盘配额 2019 7 2
    上机作业四 磁盘管理 2019 7 31
    上机作业三 账号管理2019 7 31
    上机作业 2 2019/7/26
    Linux系统管理06--磁盘管理
    Linux系统管理05--权限及归属管理
    chapter06-07磁盘管理
  • 原文地址:https://www.cnblogs.com/lxxlovekang/p/5859400.html
Copyright © 2011-2022 走看看