主成分分析: 降低特征维度的方法. 不会抛弃某一列特征, 而是利用线性代数的计算,将某一维度特征投影到其他维度上去, 尽量小的损失被投影的维度特征 api使用: estimator = PCA(n_components=20) pca_x_train = estimator.fit_transform(x_train) pca_x_test = estimator.transform(x_test) 分别使用支持向量机进行学习降维前后的数据再预测 该数据集源自网上 https://archive…
特征提取: 特征降维的手段 抛弃对结果没有联系的特征 抛弃对结果联系较少的特征 以这种方式,降低维度 数据集的特征过多,有些对结果没有任何关系,这个时候,将没有关系的特征删除,反而能获得更好的预测结果 下面使用决策树,预测泰坦尼克号幸存情况,对不同百分比的筛选特征,进行学习和预测,比较准确率 python3学习使用api 使用到联网的数据集,我已经下载到本地,可以到我的git中下载数据集 git: https://github.com/linyi0604/MachineLearning 代码:…
目录 PCA思想 问题形式化表述 PCA之协方差矩阵 协方差定义 矩阵-特征值 PCA运算步骤 PCA理论解释 最大方差理论 性质 参数k的选取 数据重建 主观理解 应用 代码示例 PCA思想 PCA主要用于数据降维,是一种无监督学习方法.主成分分析利用正交变换将可能存在相关性的原始属性转换成一组线性无关的新属性,并通过选择重要的新属性实现降维.由一系列特征组成的多维向量,其中某些元素本身没有区分性,比如某个元素在所有样本中都相等,或者彼此差距不大,那么那个元素对于区分的贡献度小.我们的目的即为…
同为降维工具,二者的主要区别在于, 所在的包不同(也即机制和原理不同) from sklearn.decomposition import PCA from sklearn.manifold import TSNE 因为原理不同,导致,tsne 保留下的属性信息,更具代表性,也即最能体现样本间的差异: TSNE 运行极慢,PCA 则相对较快: 因此更为一般的处理,尤其在展示(可视化)高维数据时,常常先用 PCA 进行降维,再使用 tsne: data_pca = PCA(n_components…
python3 学习api的使用 git: https://github.com/linyi0604/MachineLearning 代码: from sklearn.datasets import load_boston from sklearn.cross_validation import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.tree import DecisionTr…
python3学习使用api 线性回归,和 随机参数回归 git: https://github.com/linyi0604/MachineLearning from sklearn.datasets import load_boston from sklearn.cross_validation import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model i…
使用python3 学习了决策树分类器的api 涉及到 特征的提取,数据类型保留,分类类型抽取出来新的类型 需要网上下载数据集,我把他们下载到了本地, 可以到我的git下载代码和数据集: https://github.com/linyi0604/MachineLearning import pandas as pd from sklearn.cross_validation import train_test_split from sklearn.feature_extraction impor…
使用python语言 学习k近邻分类器的api 欢迎来到我的git查看源代码: https://github.com/linyi0604/MachineLearning from sklearn.datasets import load_iris from sklearn.cross_validation import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.neighbors…
常用数据结构 1.list 列表 有序集合 classmates = ['Michael', 'Bob', 'Tracy'] len(classmates) classmates[0] len(classmates) - 1 classmates[-1] classmates[-2] classmates.append('Adam') classmates.insert(1, 'Jack') classmates.pop() classmates.pop(1) s = ['python', 'j…
2.特征工程 2.1 数据集 2.1.1 可用数据集 Kaggle网址:https://www.kaggle.com/datasets UCI数据集网址: http://archive.ics.uci.edu/ml/ scikit-learn网址:http://scikit-learn.org/stable/datasets/index.html#datasets 2.1.2 安装scikit-learn工具 pip3 install Scikit-learn==0.19.1 安装好之后可以通过…