![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
机器学习
文章平均质量分 74
Dcy_ASK
预测未来最好的方式是创造
展开
-
(洞见趋势)数据探索--找出规律揭示奥秘
文章目录1.数据集1.1 数据集介绍1.2 导入必要的工具包1.3 数据读取2.数据探索2.1 查看标签的分布情况2.2 查看缺失值2.3 查看特征数据类型2.4 异常点检测2.5 相关性检验2.6 年龄对还款的影响(探索)2.7 外部数据源文章正文1.1 数据集介绍本次使用的数据集来源于Kaggle平台,由home credict提供,该公司的服务致力于向无银行账户的人群提供信贷。我们只用到以下数据集:application_train/application_t.原创 2021-02-17 14:20:44 · 1141 阅读 · 1 评论 -
模型训练之决策树、随机森林、提升树
本节内容包括:树模型的sklearn使用:Decision TreeRandom ForestGBDT分类评价指标说明:AccuracyTPR和FPRROC曲线PR曲线APF1 score交叉验证:k折交叉验证留一交叉验证超参搜索:网格搜索随机搜索hyperopt自动化搜索...原创 2021-02-15 12:45:06 · 1107 阅读 · 0 评论 -
(深度好文)欠拟合与过拟合解释实例--多项式拟合
欠拟合与过拟合解释实例–多项式拟合1.导入必要的模块import numpy as npimport pandas as pdimport matplotlib.pyplot as plt2.生成数据2.1构建数据生成函数def data_generator(samples,random_seed=0): np.random.seed(random_seed)# 设置随机种子 X=np.random.uniform(-5,5,size=samples)# 从-5到5中随机抽取100个实数原创 2021-02-14 20:32:19 · 924 阅读 · 6 评论 -
Logistic回归的sklearn实现
@[TOC]Logistic回归的sklearn实现导入必要的模块生成数据模型搭建模型训练模型预测查看logistic回归模型画出预测曲线计算评价指标accuracy1.导入必要的模块import numpy as npimport pandas as pdimport matplotlib.pyplot as plt2.生成数据2.1定义数据生成函数def create_data(data_num=100): np.random.seed(21) x1=原创 2021-02-14 12:17:59 · 3512 阅读 · 1 评论 -
线性回归的sklearn实现
线性回归sklearn实现1.导入必要的模块2.构建数据集3.数据划分4.模型搭建5.模型训练6.模型预测7.查看线性回归模型8.计算评价指标MSE线性回归sklearn的实现# 安装sklearn!pip3 install sklearn# 1.导入必要的模块import numpy as npimport pandas as pdimport matplotlib.pyplot as plt2.构建数据集x=np.array([50,30,15,40,55,20,45,原创 2021-02-13 14:14:42 · 237 阅读 · 0 评论 -
ValueError: Invalid parameter
老规矩,先上源代码:from sklearn.model_selection import GridSearchCVparam_grid =[ {'n_eatimatiors':[3,10,30],'max_features':[2,4,6,8]}, {'bootstrap':[False],'n_estimators':[3,10],'max_features':[2,3,4]},]forest_reg=RandomForestRegressor(random_state=42)原创 2020-10-22 06:06:55 · 8068 阅读 · 2 评论 -
TypeError: DataFrameSelector() takes no arguments
先看源代码的构建:这里有3个步骤,第一步:先获取到housing_num的列名,通过list方法# 对housing_num取list得到列名、对housing_num通过list()方法,得到列名num_attribs=list(housing_num)num_attribs第二步:将DataFrame转换为ndarray,需要构建class# dataFrame->series->ndarrayclass DataFrameSelector(BaseEstimator,Tra原创 2020-10-21 08:19:38 · 1102 阅读 · 3 评论 -
AttributeError: ‘numpy.ndarray‘ object has no attribute ‘fit‘
AttributeError: ‘numpy.ndarray’ object has no attribute ‘fit’源代码运行如下:from sklearn.pipeline import Pipelinefrom sklearn.preprocessing import StandardScalernum_pipeline = Pipeline([ ('imputer',SimpleImputer(strategy="median")), ('attribs_adder',原创 2020-10-21 05:45:41 · 8118 阅读 · 3 评论 -
Cannot use median strategy with non-numeric data: could not convert string to float: ‘<1
创建一个imputer实例, 指定你要用属性中的中位数替代该属性的缺失值,再使用fit()方法将imputer实例适配到训练集,实现代码如下:from sklearn.impute import SimpleImputerimputer = SimpleImputer(strategy='median')imputer.fit(housing)运行结果如下:ValueError: Cannot use median strategy with non-numeric data:could n原创 2020-10-19 05:54:10 · 3760 阅读 · 0 评论 -
cannot import name ‘Imputer‘ from ‘sklearn.preprocessing‘
创建一个imputer实例,指定要用属性中的XXX(中位数,平均数等)替代该属性中的缺失值,在sklearn中调用imputer方法,调用操作如下:from sklearn.preprocessing import Imputer as SimpleImputerimputer = SimpleImputer(strategy='median')运行后的结果:ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing原创 2020-10-19 05:35:07 · 7160 阅读 · 2 评论