手写线性回归模型
关于手写线性回归模型的一些知识。理论推导部分相信大家都比较熟悉了,主要关注numpy实现部分。
下面是代码:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 27 11:54:18 2020
@author: Lenovo
"""
import numpy as np
def linear_loss(X, y, w, b):
num_train = X.shape[0]
# 模型公式
y_hat = np.dot(X, w)
转载
2020-06-27 13:53:44 ·
475 阅读 ·
0 评论