摘要: from sklearn.metrics import roc_curve,auc from sklearn.ensemble import RandomForestClassifier import matplotlib.pyplot as plt from sklearn.model_selec 阅读全文
posted @ 2019-02-21 13:48 The_Chain 阅读(7178) 评论(0) 推荐(0) 编辑
摘要: 1,去除线性共线性,使变量数据稀疏。 共线性检测: 1,VIF(方差膨胀因子),1/(1-R**2)以10为分界点,(0-10)不存在多重共线性问题,>10存在多重共线性问题。 (vif包建议5以上则存在共线性问题) from statsmodels.stats.outliers_influence 阅读全文
posted @ 2019-02-21 12:58 The_Chain 阅读(827) 评论(0) 推荐(0) 编辑
摘要: import stmplib from email.mime.text import MIMEText from email.Header import Header mailhost='stmp.qq.com' #设置服务器 mailuser='XXXXXXX@foxmail.com' #使用时亲 阅读全文
posted @ 2018-11-13 10:48 The_Chain 阅读(190) 评论(0) 推荐(0) 编辑
摘要: import pandas as pd import numpy as np d=np.array(range(10)).reshape(2,5) data=pd.DataFrame(d) data.columns=['a','b'] data['test']=['m1901\t','m1902\t 阅读全文
posted @ 2018-09-18 14:53 The_Chain 阅读(339) 评论(0) 推荐(0) 编辑
摘要: import re s='='金'' #只保留金这个字 s=re.sub(r'\W','',s) #去掉金字 s=re.sub(r'\w','',s) 阅读全文
posted @ 2018-08-01 16:25 The_Chain 阅读(445) 评论(0) 推荐(0) 编辑
摘要: #决策树算法的原理是一系列if_else的逻辑迭代。适用于对数据进行分类和回归,优点是对于数据的本身要求不高,直观容易理解,缺点是容易过拟合和泛化能力不强。对于回归而言,不能外推。 from sklearn.tree import DecisionTreeClassifier import matp 阅读全文
posted @ 2018-07-19 13:35 The_Chain 阅读(4475) 评论(0) 推荐(0) 编辑
摘要: #和随机森林一样,基于决策树,采用连续的方式构建树,深度很小max_depth<5.重要的参数n_estimate和learning_rate,这两个参数的y作用在于对模型过拟合化得调整,从而提高模型得泛化能力。 from sklearn.ensemble import GradientBoosti 阅读全文
posted @ 2018-07-14 19:09 The_Chain 阅读(514) 评论(0) 推荐(0) 编辑
摘要: #随机森林是集成学习的一种,基本的原理是在决策树的原理上加上随意boosting根据多种树的结果进行平均而得到回归,分类问题进行投票 在进行随机森林模型时需要对数据进行自采样从而达到与原数据集相同的数据, from sklearn.ensemble import RandomForestClassi 阅读全文
posted @ 2018-07-14 18:50 The_Chain 阅读(877) 评论(0) 推荐(0) 编辑
摘要: #k近邻法算法原理,根据训练集数据,对于新数据进行数据的定位,n_neighbors参数=[1,3,6,9.....],参数越小则模型的复杂度越高。参数越多则决策边界越平滑。(基于python机器学习基础教程) from sklearn.neighbors import KNeighborsClas 阅读全文
posted @ 2018-07-13 10:46 The_Chain 阅读(232) 评论(0) 推荐(0) 编辑
摘要: #岭回归主要是弥补在数据中出现异常值时,提高线性模型的稳定性,即鲁棒性robust import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model impo 阅读全文
posted @ 2018-07-09 14:15 The_Chain 阅读(352) 评论(0) 推荐(0) 编辑