当前位置:网站首页>吴恩达机器学习之线性回归
吴恩达机器学习之线性回归
2022-07-26 09:20:00 【Alex Su (*^▽^*)】
主要记录自己的课后实践代码的过程
基于这个
一.简单的练习
输出单位矩阵
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
a = np.eye(5)
print(a)
二.数据的绘制
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
path = 'C:/Users/szuacm/Desktop/机器学习/数据/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()
三.代码
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))
##数据再改一下 数据不对
边栏推荐
- jvm命令归纳
- Order based evaluation index (especially for recommendation system and multi label learning)
- Unity topdown character movement control
- Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
- What are CSDN spaces represented by
- CF1481C Fence Painting
- 【无标题】
- JS - DataTables control on the number of displays per page
- [online problem] timeout waiting for connection from pool problem troubleshooting
- Horizontal comparison of the data of the top ten blue chip NFTs in the past half year
猜你喜欢

Babbitt | metauniverse daily must read: does the future of metauniverse belong to large technology companies or to the decentralized Web3 world

Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing

Polynomial open root

JS output diamond on the console

STM32+MFRC522完成IC卡号读取、密码修改、数据读写

Zipkin installation and use

Li Mu D2L (V) -- multilayer perceptron

李沐d2l(四)---Softmax回归

【Mysql】Mysql锁详解(三)

2022 chemical automation control instrument operation certificate test question simulation test platform operation
随机推荐
2022茶艺师(中级)特种作业证考试题库模拟考试平台操作
力扣——二叉树剪枝
volatile 靠的是MESI协议解决可见性问题?(上)
论文笔记: 知识图谱 KGAT (未完暂存)
Unity topdown character movement control
Error: Cannot find module ‘umi‘ 问题处理
Cat installation and use
arcgis的基本使用4
ZXing简化版,转载
【ARKit、RealityKit】把图片转为3D模型
Datax的学习笔记
CF1481C Fence Painting
Qtcreator reports an error: you need to set an executable in the custom run configuration
神经网络与深度学习-6- 支持向量机1 -PyTorch
李沐d2l(五)---多层感知机
[use of final keyword]
JS closure: binding of functions to their lexical environment
tornado之多进程服务
JVM触发minor gc的条件
Summary of common activation functions for deep learning