from sklearn.svm import LinearSVC
from sklearn.pipeline import Pipeline
from sklearn import neighbors, datasets
from sklearn.datasets import load_digits
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split def load_diabetes():
#使用 scikit-learn 自带的一个糖尿病病人的数据集
diabetes = datasets.load_diabetes()
# 拆分成训练集和测试集,测试集大小为原始数据集大小的 1/4
return train_test_split(diabetes.data,diabetes.target,test_size=0.25,random_state=0) #数据预处理流水线Pipeline模型
def test_Pipeline(X_train,X_test,y_train,y_test):
steps=[("Linear_SVM",LinearSVC(C=1,penalty='l1',dual=False)),("LogisticRegression",LogisticRegression(C=1))]
pipeline=Pipeline(steps)
pipeline.fit(X_train,y_train)
print("Named steps:",pipeline.named_steps)
print("Pipeline Score:",pipeline.score(X_test,y_test)) # 获取分类数据
X_train,X_test,y_train,y_test=load_diabetes()
# 调用 test_Pipeline
test_Pipeline(X_train,X_test,y_train,y_test)

吴裕雄 python 机器学习——数据预处理流水线Pipeline模型的更多相关文章

  1. 吴裕雄 python 机器学习——数据预处理正则化Normalizer模型

    from sklearn.preprocessing import Normalizer #数据预处理正则化Normalizer模型 def test_Normalizer(): X=[[1,2,3, ...

  2. 吴裕雄 python 机器学习——数据预处理标准化MaxAbsScaler模型

    from sklearn.preprocessing import MaxAbsScaler #数据预处理标准化MaxAbsScaler模型 def test_MaxAbsScaler(): X=[[ ...

  3. 吴裕雄 python 机器学习——数据预处理标准化StandardScaler模型

    from sklearn.preprocessing import StandardScaler #数据预处理标准化StandardScaler模型 def test_StandardScaler() ...

  4. 吴裕雄 python 机器学习——数据预处理标准化MinMaxScaler模型

    from sklearn.preprocessing import MinMaxScaler #数据预处理标准化MinMaxScaler模型 def test_MinMaxScaler(): X=[[ ...

  5. 吴裕雄 python 机器学习——数据预处理字典学习模型

    from sklearn.decomposition import DictionaryLearning #数据预处理字典学习DictionaryLearning模型 def test_Diction ...

  6. 吴裕雄 python 机器学习——数据预处理过滤式特征选取SelectPercentile模型

    from sklearn.feature_selection import SelectPercentile,f_classif #数据预处理过滤式特征选取SelectPercentile模型 def ...

  7. 吴裕雄 python 机器学习——数据预处理过滤式特征选取VarianceThreshold模型

    from sklearn.feature_selection import VarianceThreshold #数据预处理过滤式特征选取VarianceThreshold模型 def test_Va ...

  8. 吴裕雄 python 机器学习——数据预处理二元化OneHotEncoder模型

    from sklearn.preprocessing import OneHotEncoder #数据预处理二元化OneHotEncoder模型 def test_OneHotEncoder(): X ...

  9. 吴裕雄 python 机器学习——数据预处理二元化Binarizer模型

    from sklearn.preprocessing import Binarizer #数据预处理二元化Binarizer模型 def test_Binarizer(): X=[[1,2,3,4,5 ...

随机推荐

  1. 题解 【洛谷P1332】血色先锋队

    题面:https://www.luogu.org/problemnew/show/P1332 很容易看出,这是一个典型的广度优先搜索,也就是众多OIer口中的bfs. 先给各位普及一下bfs(部分来自 ...

  2. 记录 shell学习过程(6)while 以及 while的嵌套 以及 until

    while中的5种条件 1.数学比较 read -p "Num :" num1 ] do echo 'greater' sleep done 2.字符串比较 read -p &qu ...

  3. [Codechef - AASHRAM] Gaithonde Leaves Aashram - 线段树,DFS序

    [Codechef - AASHRAM] Gaithonde Leaves Aashram Description 给出一棵树,树的"N"节点根植于节点1,每个节点'u'与权重a[ ...

  4. ORA_12514:TNS:listener does not currently know of service requested in connect descriptor

    问题描述 ORA_12514:TNS:listener does not currently know of service requested in connect descriptor 解决方式 ...

  5. k线生成模块

    1.支持任意周期K线. 2.支持K线偏移. 3.支持指数.主力. 4.支持文华商品指数. 默认支持的是:5秒.1分钟.3分钟.5分钟.日线. 时间:2010年到现在. 数据如下: 5秒线,大宗商品指数 ...

  6. mysql update某个字段替换成某个值

    UPDATE xc_admin_vehicle SET brandid= REPLACE(brandid, 19, 54) UPDATE xc_admin_models SET bid= REPLAC ...

  7. rancher说明为什么需要按照指定版本安装以及rancher和节点linux环境配置-docker指定版本安装

    rancher说明为什么需要按照指定版本安装以及rancher和节点linux环境配置-docker指定版本安装 待办 https://blog.csdn.net/CSDN_duomaomao/art ...

  8. centos7 命令 对比 cenots6 命令

    1)  列出所有service开机启动项 centos 7 systemctl list-unit-files |grep enabled centos 6 chkconfig --list|grep ...

  9. docker dial unix /var/run/docker.sock: connect: permission denied

    Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker. ...

  10. 从ICG cell 在 library 中的定义说起

    如Coding 时需要考虑什么样的代码风格会使gating 的效率更高:综合时需要特别设置要插入的gating 类型,每个gating 的fanout 范围,是否可以跨层次,是否需要做physical ...