ML之DT:基于DT决策树算法(对比是否经特征筛选FS处理)对Titanic(泰坦尼克号)数据集进行二分类预测
ML之DT:基于DT决策树算法(对比是否经特征筛选FS处理)对Titanic(泰坦尼克号)数据集进行二分类预测
目录
输出结果
设计思路
核心代码
输出结果
初步处理后的 X_train: (984, 474) (0, 0) 31.19418104265403 (0, 78) 1.0 (0, 82) 1.0 (0, 366) 1.0 (0, 391) 1.0 (0, 435) 1.0 (0, 437) 1.0 (0, 473) 1.0 (1, 0) 31.19418104265403 (1, 73) 1.0 (1, 79) 1.0 (1, 296) 1.0 (1, 389) 1.0 (1, 397) 1.0 (1, 436) 1.0 (1, 446) 1.0 (2, 0) 31.19418104265403 (2, 78) 1.0 (2, 82) 1.0 (2, 366) 1.0 (2, 391) 1.0 (2, 435) 1.0 (2, 437) 1.0 (2, 473) 1.0 (3, 0) 32.0 : : (980, 473) 1.0 (981, 0) 12.0 (981, 73) 1.0 (981, 81) 1.0 (981, 84) 1.0 (981, 390) 1.0 (981, 435) 1.0 (981, 436) 1.0 (981, 473) 1.0 (982, 0) 18.0 (982, 78) 1.0 (982, 81) 1.0 (982, 277) 1.0 (982, 390) 1.0 (982, 435) 1.0 (982, 437) 1.0 (982, 473) 1.0 (983, 0) 31.19418104265403 (983, 78) 1.0 (983, 82) 1.0 (983, 366) 1.0 (983, 391) 1.0 (983, 435) 1.0 (983, 436) 1.0 (983, 473) 1.0 |
经过FS处理后的 X_train_fs: (984, 94) (0, 93) 1.0 (0, 85) 1.0 (0, 83) 1.0 (0, 76) 1.0 (0, 71) 1.0 (0, 27) 1.0 (0, 24) 1.0 (0, 0) 31.19418104265403 (1, 84) 1.0 (1, 74) 1.0 (1, 63) 1.0 (1, 25) 1.0 (1, 19) 1.0 (1, 0) 31.19418104265403 (2, 93) 1.0 (2, 85) 1.0 (2, 83) 1.0 (2, 76) 1.0 (2, 71) 1.0 (2, 27) 1.0 (2, 24) 1.0 (2, 0) 31.19418104265403 (3, 93) 1.0 (3, 85) 1.0 (3, 83) 1.0 : : (980, 24) 1.0 (980, 0) 31.19418104265403 (981, 93) 1.0 (981, 84) 1.0 (981, 83) 1.0 (981, 75) 1.0 (981, 28) 1.0 (981, 26) 1.0 (981, 19) 1.0 (981, 0) 12.0 (982, 93) 1.0 (982, 85) 1.0 (982, 83) 1.0 (982, 75) 1.0 (982, 26) 1.0 (982, 24) 1.0 (982, 0) 18.0 (983, 93) 1.0 (983, 84) 1.0 (983, 83) 1.0 (983, 76) 1.0 (983, 71) 1.0 (983, 27) 1.0 (983, 24) 1.0 (983, 0) 31.19418104265403 |
设计思路
核心代码
class SelectPercentile Found at: sklearn.feature_selection.univariate_selectionclass SelectPercentile(_BaseFilter):"""Select features according to a percentile of the highest scores.Read more in the :ref:`User Guide <univariate_feature_selection>`.Parameters----------score_func : callableFunction taking two arrays X and y, and returning a pair of arrays(scores, pvalues) or a single array with scores.Default is f_classif (see below "See also"). The default function onlyworks with classification tasks.percentile : int, optional, default=10Percent of features to keep.Attributes----------scores_ : array-like, shape=(n_features,)Scores of features.pvalues_ : array-like, shape=(n_features,)p-values of feature scores, None if `score_func` returned only scores.Notes-----Ties between features with equal scores will be broken in an unspecifiedway.See also--------f_classif: ANOVA F-value between label/feature for classification tasks.mutual_info_classif: Mutual information for a discrete target.chi2: Chi-squared stats of non-negative features for classification tasks.f_regression: F-value between label/feature for regression tasks.mutual_info_regression: Mutual information for a continuous target.SelectKBest: Select features based on the k highest scores.SelectFpr: Select features based on a false positive rate test.SelectFdr: Select features based on an estimated false discovery rate.SelectFwe: Select features based on family-wise error rate.GenericUnivariateSelect: Univariate feature selector with configurable mode."""def __init__(self, score_func=f_classif, percentile=10):super(SelectPercentile, self).__init__(score_func)self.percentile = percentiledef _check_params(self, X, y):if not 0 <= self.percentile <= 100:raise ValueError("percentile should be >=0, <=100; got %r" % self.percentile)def _get_support_mask(self):check_is_fitted(self, 'scores_')# Cater for NaNsif self.percentile == 100:return np.ones(len(self.scores_), dtype=np.bool)elif self.percentile == 0:return np.zeros(len(self.scores_), dtype=np.bool)scores = _clean_nans(self.scores_)treshold = stats.scoreatpercentile(scores, 100 - self.percentile)mask = scores > tresholdties = np.where(scores == treshold)[0]if len(ties):max_feats = int(len(scores) * self.percentile / 100)kept_ties = ties[:max_feats - mask.sum()]mask[kept_ties] = Truereturn mask
ML之DT:基于DT决策树算法(对比是否经特征筛选FS处理)对Titanic(泰坦尼克号)数据集进行二分类预测相关推荐
- ML之DT:基于DT决策树算法(交叉验证FS+for遍历最佳FS)对Titanic(泰坦尼克号)数据集进行二分类预测
ML之DT:基于DT决策树算法(交叉验证FS+for遍历最佳FS)对Titanic(泰坦尼克号)数据集进行二分类预测 目录 输出结果 设计思路 核心代码 输出结果 设计思路 核心代码 fs = fea ...
- ML之RFXGBoost:基于RF/XGBoost(均+5f-CrVa)算法对Titanic(泰坦尼克号)数据集进行二分类预测(乘客是否生还)
ML之RF&XGBoost:基于RF/XGBoost(均+5f-CrVa)算法对Titanic(泰坦尼克号)数据集进行二分类预测(乘客是否生还) 目录 输出结果 比赛结果 设计思路 核心代码 ...
- ML之RFXGBoost:分别基于RF随机森林、XGBoost算法对Titanic(泰坦尼克号)数据集进行二分类预测(乘客是否生还)
ML之RF&XGBoost:分别基于RF随机森林.XGBoost算法对Titanic(泰坦尼克号)数据集进行二分类预测(乘客是否生还) 目录 输出结果 设计思路 核心代码 输出结果 设计思路 ...
- ML之catboost:基于自带Pool数据集实现二分类预测
ML之catboost:基于自带Pool数据集实现二分类预测 基于自带Pool数据集实现二分类预测 输出结果 Learning rate set to 0.5 0: learn: 0.9886498 ...
- DL之GD:利用LogisticGD算法(梯度下降)依次基于一次函数和二次函数分布的数据集实现二分类预测(超平面可视化)
DL之GD:利用LogisticGD算法(梯度下降)依次基于一次函数和二次函数分布的数据集实现二分类预测(超平面可视化) 目录 利用LogisticGD算法(梯度下降)依次基于一次函数和二次函数分布的 ...
- ML之xgboost:利用xgboost算法对breast_cancer数据集实现二分类预测并进行graphviz二叉树节点图可视化
ML之xgboost:利用xgboost算法对breast_cancer数据集实现二分类预测并进行graphviz二叉树节点图可视化 目录 实现结果 实现代码 实现结果
- ML之LoRBaggingRF:依次利用LoR、Bagging、RF算法对titanic(泰坦尼克号)数据集 (Kaggle经典案例)获救人员进行二分类预测(最全)
ML之LoR&Bagging&RF:依次利用LoR.Bagging.RF算法对titanic(泰坦尼克号)数据集 (Kaggle经典案例)获救人员进行二分类预测 目录 输出结果 设计思 ...
- EL之DTRFGBT:基于三种算法(DT、RF、GBT)对泰坦尼克号乘客数据集进行二分类(是否获救)预测并对比各自性能
EL之DT&RF&GBT:基于三种算法(DT.RF.GBT)对泰坦尼克号乘客数据集进行二分类(是否获救)预测并对比各自性能 目录 输出结果 设计思路 核心代码 输出结果 设计思路 核 ...
- ML之DT:基于DT算法对泰坦尼克号乘客数据集进行二分类(是否获救)预测
ML之DT:基于DT算法对泰坦尼克号乘客数据集进行二分类(是否获救)预测 目录 输出结果 设计思路 核心代码 输出结果 设计思路 核心代码 X_train, X_test, y_train, y_te ...
最新文章
- 【Sql Server】DateBase-子查询
- 高通首次推出AI引擎 打包所有软硬件算力
- HashMap根据value值排序
- STL 容器 与 数据结构
- 使用 JavaScript 进行 Base64 编码与解码
- SpringCloud 搭建项目环境、创建 Dept 微服务、客户端调用微服务
- python3键盘事件_python+selenium3 鼠标事件和键盘事件
- IOS UI 第三篇:基本UI
- 数据科学 IPython 笔记本 8.15 Matplotlib 中的三维绘图
- 音乐标签编辑器 Meta 2.0.0 for Mac
- Docker教程小白实操入门(12)--如何使用build指令根据Dockerfile文件构建一个镜像
- 超码、候选码、主码 与 外码
- Gdiplus的使用 gdi+
- c4dr20怎么安装oc渲染器怎么安装_C4D R20 Octane渲染器
- LCD液晶屏的通讯模式
- html中div排版布局
- COB-ID的简单理解分析
- 怎么学python入门?python新手学习路线
- 视频剪辑技巧,教你视频画面用图片进行遮挡的方法
- App过工信部第三方审核注意要点