资源简介
使用python实现多元线性回归,内容包含数据源及代码实现
代码片段和文件信息
import numpy as np
import random
# m denotes the number of examples here not the number of features
def gradientDescent(x y theta alpha m numIterations):
xTrans = x.transpose()
for i in range(0 numIterations):
hypothesis = np.dot(x theta)
loss = hypothesis - y
# avg cost per example (the 2 in 2*m doesn‘t really matter here.
# But to be consistent with the gradient I include it)
cost = np.sum(loss ** 2) / (2 * m)
print(“Iteration %d | Cost: %f“ % (i cost))
# avg gradient per example
gradient = np.dot(xTrans loss) / m
# update
theta = theta - alpha * gradient
return theta
def genData(numPoints bias variance):
x = np.zeros(shape=(numPoints 2))
y = np.zeros(shape=numPoints)
# basically a straight line
for i in range(0 numPoints):
# bias feature
x[i][0] = 1
x[i][1] = i
# our target variable
y[i] = (i + bias) + random.uniform(0 1) * variance
return x y
# gen 100 points with a bias of 25 and 10 variance as a bit of noise
x y = genData(100 25 10)
m n = np.shape(x)
numIterations= 100000
alpha = 0.0005
theta = np.ones(n)
theta = gradientDescent(x y theta alpha m numIterations)
print(theta)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-06-18 14:24 MultipleLinearRegression-master\
目录 0 2015-06-18 14:24 MultipleLinearRegression-master\.ipynb_checkpoints\
文件 575 2015-06-18 14:24 MultipleLinearRegression-master\.ipynb_checkpoints\Unti
文件 558 2015-06-18 14:24 MultipleLinearRegression-master\.ipynb_checkpoints\Unti
文件 1042390 2015-06-18 14:24 MultipleLinearRegression-master\East_Africa.pdf
文件 19227 2015-06-18 14:24 MultipleLinearRegression-master\East_Africa.txt
文件 159147 2015-06-18 14:24 MultipleLinearRegression-master\Multiple Linear Regression.pdf
文件 0 2015-06-18 14:24 MultipleLinearRegression-master\README.md
文件 600 2015-06-18 14:24 MultipleLinearRegression-master\Unti
文件 558 2015-06-18 14:24 MultipleLinearRegression-master\Unti
文件 635483 2015-06-18 14:24 MultipleLinearRegression-master\data-text.csv
文件 299008 2015-06-18 14:24 MultipleLinearRegression-master\education.csv
文件 2699586 2015-06-18 14:24 MultipleLinearRegression-master\education_stuff.csv
文件 1279 2015-06-18 14:24 MultipleLinearRegression-master\gradient_descent.py
文件 261 2015-06-18 14:24 MultipleLinearRegression-master\intro_pandas.py
文件 237 2015-06-18 14:24 MultipleLinearRegression-master\intro_pandas.py~
文件 137415 2015-06-18 14:24 MultipleLinearRegression-master\life_exp.csv
文件 660 2015-06-18 14:24 MultipleLinearRegression-master\linreg.py
文件 214 2015-06-18 14:24 MultipleLinearRegression-master\linreg.py~
文件 8176 2015-06-18 14:24 MultipleLinearRegression-master\new.csv
文件 578 2015-06-18 14:24 MultipleLinearRegression-master\regexing.py
文件 373 2015-06-18 14:24 MultipleLinearRegression-master\regexing.py~
文件 207 2015-06-18 14:24 MultipleLinearRegression-master\testingCorrelation.py
文件 40 2015-06-18 14:24 MultipleLinearRegression-master\testingCorrelation.py~
文件 288 2015-06-18 14:24 MultipleLinearRegression-master\testingHomoskedasticity.py
文件 152 2015-06-18 14:24 MultipleLinearRegression-master\testingHomoskedasticity.py~
文件 224 2015-06-18 14:24 MultipleLinearRegression-master\testingNormality.py
文件 64 2015-06-18 14:24 MultipleLinearRegression-master\testingNormality.py~
文件 8534 2015-06-18 14:24 MultipleLinearRegression-master\trafficking_data.csv
相关资源
- seleniumwebdriverpython第三版.pdf
- IEDriverServer_64位操作系统,支持selen
- 编写高质量代码:改善Python程序的91个
- 基于python的新冠疫情数据分析.zip
- python 机器学习 scikit-learn 手册 高清完
- 深度学习入门:基于 Python 的理论与实
- python数学实验与建模程序及数据.zip
- python 金融大数据分析代码与数据
- Python编程入门经典源代码
- python自动登陆该网站并网站内容
- 泰坦尼克号0.81准确率python源代码.py
- python随机子空间法.py
- opencv_python-3.4.5 contrib-cp37-cp37m-win_amd
- Python-一个非常简单的BiLSTMCRF模型用于
- Python-Tensorflow仿AlphaGo框架实现的AI围棋
- opencv-contrib_python-3.4.2.16-cp37-amd64.zip
- Python语言在Abaqus中的应用高清版pdf
- 数据结构与算法:Python语言实现课后
- python3.6 绿色版
- 基于python的道路视频车道线检测
- win7,64位,python3.5.2下的安装包:nu
- 基于Python3 tkinterGUI界面实现读取本地
- Python实现购物评论文本情感分析操作
- Python中HHT(希尔伯特-黄变换)以及其
- Python 3.8.1 32位安装包.zip
- OpenCV+3计算机视觉++Python语言实现 高清
- matlab代码转换为python代码
- python实现hmm
- Python-GUI-PyQ5总概述.xmind
- 基于python实现的BS架构FTP服务器程序
评论
共有 条评论