当前位置:网站首页>Wu Enda linear regression of machine learning
Wu Enda linear regression of machine learning
2022-07-26 09:55:00 【Alex Su (*^▽^*)】
It mainly records the process of practicing code after class
Based on this
One . Simple exercises
Output identity matrix
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
a = np.eye(5)
print(a)
Two . Drawing of data
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
path = 'C:/Users/szuacm/Desktop/ machine learning / data /1.txt'
data = pd.read_csv(path, header= 0, names = ['Population', 'Profit'])
print(data)
data.plot(kind='scatter', x='Population', y='Profit', figsize=(12,8))
plt.show()
3、 ... and . Code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def computecost(x, y, theta):
t = np.power(x * theta.T - y, 2)
return sum(t) / (2 * len(x))
path = 'in.txt'
data = pd.read_csv(path, header = None, names = ['Population', 'Profit'])
data.insert(0, 'Ones', 1)
cols = data.shape[1]
x = data.iloc[:, 0:cols - 1]
y = data.iloc[:, cols - 1:cols]
x = np.matrix(x.values)
y = np.matrix(y.values)
theta = np.matrix([0, 0])
print(x.shape, theta.shape, y.shape)
print(computecost(x, y, theta))
## Change the data again The data is wrong
边栏推荐
- POJ 1012 Joseph
- Flutter event distribution
- [MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
- Keeping alive to realize MySQL automatic failover
- Node 内存溢出及V8垃圾回收机制
- Applet record
- Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
- 面试突击68:为什么 TCP 需要 3 次握手?
- js 表格自动循环滚动,鼠标移入暂停
- PHP one-time request lifecycle
猜你喜欢
[fluorescent character effect]
Interview shock 68: why does TCP need three handshakes?
Server and client dual authentication (2)
Uni app learning summary
解决npm -v突然失效 无反应
论文笔记(SESSION-BASED RECOMMENDATIONS WITHRECURRENT NEURAL NETWORKS)
服务发现原理分析与源码解读
Logical architecture of MySQL
Node 内存溢出及V8垃圾回收机制
2019 ICPC Asia Yinchuan regional (water problem solution)
随机推荐
[datawhale] [machine learning] Diabetes genetic risk detection challenge
E. Two Small Strings
Modern medicine in the era of "Internet +"
CSV data file settings of JMeter configuration components
莫队学习笔记(一)
EOJ 2020 1月月赛 E数的变换
Applet record
PMM (percona monitoring and management) installation record
IIS error prompt after installing Serv-U: hresult:0x80070020
Leetcode 504. 七进制数
论文笔记(SESSION-BASED RECOMMENDATIONS WITHRECURRENT NEURAL NETWORKS)
高斯消元的应用
SSG framework Gatsby accesses the database and displays it on the page
服务器内存故障预测居然可以这样做!
JS 连等赋值操作
JS continuous assignment operation
编写一个在bash / shell 和 PowerShell中均可运行的脚本
Fiddler download and installation
Wechat H5 payment on WAP, for non wechat browsers
Use of tabbarcontroller