当前位置:网站首页>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
边栏推荐
- Principle analysis and source code interpretation of service discovery
- 一种分布式深度学习编程新范式:Global Tensor
- Modern medicine in the era of "Internet +"
- Solve NPM -v sudden failure and no response
- Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
- IIS website configuration
- 面试突击68:为什么 TCP 需要 3 次握手?
- 解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
- [information system project manager] summary of essence of high-level series for the first time
- 2021年山东省中职组“网络空间安全”B模块windows渗透(解析)
猜你喜欢

Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken

R语言ggplot2可视化: 将图例标题(legend title)对齐到ggplot2中图例框的中间(默认左对齐、align legend title to middle of legend)

Installation and use of cocoapods

Xiaobai makes a wave of deep copy and shallow copy

Spolicy request case

Fiddler packet capturing tool for mobile packet capturing

高斯消元求解矩阵的逆(gauss)

Development to testing: a six-year road to automation starting from 0

Login module use case writing

CSV data file settings of JMeter configuration components
随机推荐
Installation and use of cocoapods
M-ary number STR to n-ary number
Double authentication of server and client
MySQL 5.7.25 source code installation record
2022 zhongkepan cloud - server internal information acquisition and analysis flag
Uni app learning summary
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
PHP one-time request lifecycle
Fiddler packet capturing tool for mobile packet capturing
解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
小白搞一波深拷贝 浅拷贝
JS table auto cycle scrolling, mouse move in pause
Rowselection emptying in a-table
在同一conda环境下先装Pytroch后装TensorFlow
Solve proxyerror: CONDA cannot proceed due to an error in your proxy configuration
What is the principle of reflection mechanism?
Explain automatic packing and unpacking?
高斯消元求解矩阵的逆(gauss)
I finished watching this video on my knees at station B
In Net 6.0