机器学习算法之六:5分钟上手Logistic Regression
来源:互联网 发布:大数据安全管理办法 编辑:程序博客网 时间:2024/03/29 23:45
1.案例:这个数据用针对房屋售价的结果。如下CSV档(6.Logistic_Regression.csv),两个栏位各代表面积与售价。
2.问题:现在有一面积为700,请问预估可能的售价是多少?
3.数据文档:6.Logistic_Regression.csv,内容如下。
4.Sampe code:
#encoding: utf-8import matplotlib.pyplot as pltimport numpy as npimport pandas as pdfrom sklearn import linear_model#----取得输入资料def get_data(file_name):data = pd.read_csv(file_name)X_parameter = []Y_parameter = []for single_square_feet ,single_price_value in zip(data['square_feet'],data['price']):X_parameter.append([float(single_square_feet)])Y_parameter.append(float(single_price_value))return X_parameter,Y_parameter#----设定回归分析的函数与设定值def linear_model_main(X_parameters,Y_parameters,predict_value):regr = linear_model.LinearRegression()regr.fit(X_parameters, Y_parameters)predict_outcome = regr.predict(predict_value)predictions = {}predictions['intercept'] = regr.intercept_predictions['coefficient'] = regr.coef_predictions['predicted_value'] = predict_outcomereturn predictions#----取得资料X,Y = get_data("6.Logistic_Regression.csv")#----设定输入值(面积)predictvalue = 700#----输出预测值result = linear_model_main(X,Y,predictvalue)print u"预测的价格为: ", result['predicted_value']
5.结果:
预测的价格为: [ 21915.42553191]
1 0
- 机器学习算法之六:5分钟上手Logistic Regression
- 机器学习算法之五:5分钟上手Linear Regression
- 机器学习之logistic Regression
- 机器学习之Logistic regression
- 机器学习算法之Logistic Regression算法实现
- 机器学习算法之二:5分钟上手K-Means
- 机器学习算法之三:5分钟上手Bayes
- 机器学习算法之四:5分钟上手Decision Tree
- 机器学习算法之七:5分钟上手SVM
- 机器学习算法之: 逻辑回归 logistic regression (LR)
- 使用Python完成机器学习算法之Logistic Regression
- (转载)【机器学习算法系列之二】浅析Logistic Regression
- 机器学习算法之逻辑回归(Logistic Regression)
- 机器学习 Logistic Regression
- 机器学习 logistic regression
- 机器学习-Logistic Regression
- 机器学习-Logistic Regression
- 机器学习(二)之Logistic Regression
- 并发与并行
- 在天涯、猫眼关于读经和汉服的论战
- hadoop权威指南读书总结
- hihocoder 1238 实时查询树的所有节点对距离和
- 太监式爱国 —— 忠君爱国主义(转载)
- 机器学习算法之六:5分钟上手Logistic Regression
- 爬虫的基础邹形
- 学习笔记之——自定义Dialog仿ios弹出底部菜单
- 单击AutoCompleteTextView后自动提示,无需输入字符,提示信息通过SQLite查询获得
- 多尔衮是清初开国头号美男
- java.lang.IllegalStateException: Fragment already active,Fragment.setArguments()问题
- SystemBarTintManager.java
- A004-数据对齐的原因
- iOS - 工程引入doubango (idoubs编译)