机器学习经典算法
文章平均质量分 73
chatgpt写代码
coding
展开
-
机器学习入门-决策树与随机森林
熵信息的计算比基尼系数稍慢scikit-learn中默认为基尼系数。大多数时候没有特别效果优势CART - Classification And Regression Tree非参数学习容易产生过拟合import numpy as npimport matplotlib.pyplot as pltfrom sklearn import datasetsX, y = dataset...原创 2020-03-28 21:28:34 · 671 阅读 · 0 评论 -
机器学习入门-评价标准
文章目录线性回归交叉验证使用岭回归LASSO RegressionOvR 和 OvOPrecision-Recall 曲线线性回归import numpy as np import matplotlib.pyplot as pltx = np.random.uniform(-3, 3, size=100)X = x.reshape(-1, 1)y = 0.5 * x**2 + x +...原创 2020-03-28 21:11:58 · 320 阅读 · 0 评论 -
机器学习基础--KNN算法,万事开头难-1
算法设计流程图1.建立KNN模型import numpy as npfrom math import sqrtfrom collections import Counterdef kNN_classify(k, X_train, y_train, x): assert 1 <= k <= X_train.shape[0], "k must be valid" ...原创 2019-05-29 18:42:30 · 212 阅读 · 0 评论 -
KNN算法2-性能测试与超参数的寻找
scikit-learn中的accuracy_scorefrom sklearn.model_selection import train_test_splitX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=666)from sklearn.neighbors impo...原创 2019-05-29 20:40:15 · 163 阅读 · 0 评论 -
KNN算法3-归一化
1.数据归一化处理仅仅适合数据有明显边界的数据import numpy as npimport matplotlib.pyplot as pltx = np.random.randint(0, 100, 100)(x - np.min(x)) / (np.max(x) - np.min(x))矩阵X = np.random.randint(0, 100, (50, 2))X[:,...原创 2019-05-29 21:16:50 · 691 阅读 · 0 评论 -
KNN—数据归一化scale
import numpy as npclass StandardScaler: def __init__(self): self.mean_ = None self.scale_ = None def fit(self, X): """根据训练数据集X获得数据的均值和方差""" assert X.ndim =...原创 2019-05-29 21:46:17 · 583 阅读 · 0 评论