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. K3/Cloud树形单据体的rowId赋值

    RowId是树形单据体独有的,同一单据体中不能重复,用如下语句取. System.Guid.NewGuid().ToString() 同时FGROUP也需要重新设置,值可以和FSeq一样.

  2. SSM开发基于Java EE在线图书销售系统

           SSM(Spring+Spring MVC+MyBatis)开发基于Java EE在线图书销售系统  网站成功建立和运行很大部分取决于网站开发前的规划,因此为了在网站建立过程中避免一些不 ...

  3. 解决ERROR 1130: Host 'x.x.x.x' is not allowed to connect to this MariaDB server 方法

    问题描述 在使用SQLyog操作Linux上的MariaDB时候,会出现如下错误: 解决方法 改表法 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电 ...

  4. Flink流处理(五)- 状态与一致性模型

    状态(State)与一致性模型 接下来我们转向另一个在流处理中十分重要的点:状态(state).状态在数据处理中是无处不在的.为了产生一个结果,函数一般会聚合某个时间段内(或是一定数量的)events ...

  5. oracle使用resultMap实现高级结果映射

    resultMap的属性: 1.属性 id:resultMap的唯一标识.type:resulMap的映射结果类型(一般为Java实体类).2.子节点 id:一般对应数据库的主键 id,设置此项可以提 ...

  6. 2019-2020-2 20174314王方正 《网络对抗》 Exp0 Kali安装

    本博旨记录安装Kali的具体步骤. 一.Vmware的安装 略. 二.Vmware的配置 选择[文件]-[新建虚拟机]. 出现新建虚拟机导向,按照以下图示配置每一步.

  7. codeforces Make The Fence Great Again(dp)

    题目链接:http://codeforces.com/contest/1221/problem/D 题目要求ai ! = ai-1,草纸上推理一下可以发现每一个栅栏可以升高的高度无非就是 +0,+1, ...

  8. 记一次使用正则表达式+foreach控制器调试

    使用forEach控制器时,变量为上一个请求返回的参数(通过正则表达式提取),设置好控制器的起始值后发现每次都是只执行一个,然后开始怀疑人生,百度了各种材料,最后还是决心好好的观察自己每一步是不是错了 ...

  9. 计算几何-HPI

    This article is made by Jason-Cow.Welcome to reprint.But please post the article's address.   在线笛卡尔坐 ...

  10. 生成树计数 lighting 最终决定用这个模板! (有逆元的模板)

    #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> # ...