当前位置:网站首页>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
边栏推荐
- Keeping alive to realize MySQL automatic failover
- m进制数str转n进制数
- 【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛
- 莫队学习笔记(一)
- 服务器内存故障预测居然可以这样做!
- 【信息系统项目管理师】初见高项系列精华汇总
- [information system project manager] summary of essence of high-level series for the first time
- The use of MySQL in nodejs
- Show default image when wechat applet image cannot be displayed
- E. Two Small Strings
猜你喜欢
Mqtt x cli officially released: powerful and easy-to-use mqtt 5.0 command line tool
Fiddler packet capturing tool for mobile packet capturing
苹果独占鳌头,三星大举复兴,国产手机在高端市场颗粒无收
Principle analysis and source code interpretation of service discovery
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
【Datawhale】【机器学习】糖尿病遗传风险检测挑战赛
MySQL 5.7.25 source code installation record
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
2019 ICPC Asia Yinchuan Regional(水题题解)
Interview shock 68: why does TCP need three handshakes?
随机推荐
万字详解“用知识图谱驱动企业业绩增长”
R language ggplot2 visualization: align the legend title to the middle of the legend box in ggplot2 (default left alignment, align legend title to middle of legend)
(1) Hand eye calibration of face scanner and manipulator (eye on hand)
Login module use case writing
Mo team learning notes (I)
The problem of accessing certsrv after configuring ADCs
In Net 6.0
regular expression
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res
Leetcode 504. 七进制数
网络流学习笔记
Transform between tree and array in JS (hide the children field if the child node of the tree is empty)
Network flow learning notes
JS 连等赋值操作
Rowselection emptying in a-table
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
Double authentication of server and client
Qt随手笔记(三)在vs中使用QtCharts画折线图
开发转测试:从0开始的6年自动化之路...