当前位置:网站首页>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
边栏推荐
- 高斯消元
- Fuzzy PID control of motor speed
- 分布式网络通信框架:本地服务怎么发布成RPC服务
- Cloud native (36) | introduction and installation of harbor in kubernetes
- Vectortilelayer replacement style
- JS judge the data types object.prototype.tostring.call and typeof
- Wechat applet learning notes 1
- 2022 zhongkepan cloud - server internal information acquisition and analysis flag
- Principle analysis and source code interpretation of service discovery
- IIS website configuration
猜你喜欢

Due to fierce competition in the new market, China Mobile was forced to launch a restrictive ultra-low price 5g package

解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.

MQTT X CLI 正式发布:强大易用的 MQTT 5.0 命令行工具

Interview shock 68: why does TCP need three handshakes?

I finished watching this video on my knees at station B

SSG framework Gatsby accesses the database and displays it on the page

asp. Net using redis cache

AR model in MATLAB for short-term traffic flow prediction

Docker configuring MySQL Cluster

开发转测试:从0开始的6年自动化之路...
随机推荐
asp. Net using redis cache
万字详解“用知识图谱驱动企业业绩增长”
高斯消元求解异或线性方程组
Interpretation of the standard of software programming level examination for teenagers_ second level
The use of MySQL in nodejs
Phpexcel export Emoji symbol error
Wechat applet learning notes 2
Basic knowledge of website design
Tableviewcell highly adaptive
Apple dominates, Samsung revives, and domestic mobile phones fail in the high-end market
WARNING: [pool www] server reached pm. max_ children setting (5), consider raising it
面试突击68:为什么 TCP 需要 3 次握手?
Customize permission validation in blazor
Use of tabbarcontroller
图解用户登录验证流程,写得太好了!
Usage of the formatter attribute of El table
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
Production of a-modal drag function in antui
挡不住了,纯国产PC已就位,美国的软硬件体系垄断正式被破
苹果独占鳌头,三星大举复兴,国产手机在高端市场颗粒无收