lyingloong
lyingloong
全部文章
分类
归档
标签
去牛客网
登录
/
注册
lyingloong的博客
全部文章
(共7篇)
题解 | 异常值与缺失值
import numpy as np def preprocess_data(): n = int(input().strip()) data = np.array([float(input().strip()) for _ in range(n)]) mean = np.m...
2026-04-16
0
16
题解 | 特征扩展实现
归一化和标准化 def feature_scaling(data): mean = np.mean(data, axis = 0) std = np.std(data, axis = 0) standardized_data = (data - mean) / std ...
2026-04-16
0
15
题解 | 使用梯度下降的线性回归
梯度公式: import numpy as np def linear_regression_gradient_descent(X, y, alpha, iterations): h, w = X.shape theta = np.zeros((w, 1)) for _ in...
2026-04-16
0
17
题解 | 使用正规方程的线性回归
正规方程公式:使用np.linalg.inv求逆 import numpy as np def linear_regression_normal_equation(X: list[list[float]], y: list[float]) -> list[float]: X = np....
2026-04-16
0
16
题解 | 重塑矩阵
列表转为np.array再使用reshape即可 from typing import List, Tuple, Union import numpy as np def reshape_matrix(a: List[List[Union[int, float]]], new_shape: Tup...
2026-04-16
0
19
题解 | 矩阵转置
from typing import List, Union def transpose_matrix(a: List[List[Union[int, float]]]) -> List[List[Union[int, float]]]: res = [] width = l...
2026-04-16
0
15
题解 | 矩阵和向量的点积
def matrix_vector_dot_product(matrix, vector): ans = [] v_len = len(vector) m_width = len(matrix[0]) if v_len != m_width: retu...
2026-04-16
0
14