from sklearn.preprocessing import OneHotEncoder

#数据预处理二元化OneHotEncoder模型
def test_OneHotEncoder():
X=[[1,2,3,4,5],
[5,4,3,2,1],
[3,3,3,3,3,],
[1,1,1,1,1]]
print("before transform:",X)
encoder=OneHotEncoder(sparse=False)
encoder.fit(X)
print("active_features_:",encoder.active_features_)
print("feature_indices_:",encoder.feature_indices_)
print("n_values_:",encoder.n_values_)
print("after transform:",encoder.transform([[1,2,3,4,5]])) # 调用 test_OneHotEncoder
test_OneHotEncoder()

吴裕雄 python 机器学习——数据预处理二元化OneHotEncoder模型的更多相关文章

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

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

  2. 吴裕雄 python 机器学习——数据预处理包裹式特征选取模型

    from sklearn.svm import LinearSVC from sklearn.datasets import load_iris from sklearn.feature_select ...

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

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

  4. 吴裕雄 python 机器学习——数据预处理嵌入式特征选择

    import numpy as np import matplotlib.pyplot as plt from sklearn.svm import LinearSVC from sklearn.li ...

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. 数据预处理 | 通过 Z-Score 方法判断异常值

    判断异常值方法:Z-Score 计算公式 Z = (X-μ)/σ 其中μ为总体平均值,X-μ为离均差,σ表示标准差.z的绝对值表示在标准差范围内的原始分数与总体均值之间的距离.当原始分数低于平均值时, ...

  2. [ZJOI2008] 生日聚会 - dp

    共有\(n\)个男孩与\(m\)个女孩打算坐成一排.对于任意连续的一段,男孩与女孩的数目之差不超过 \(k\).求方案数. \(n,m \leq 150, k \leq 20\) Solution 设 ...

  3. navicat 连接报2059错误

    原因 navicat不支持mysql新版本的加密规则,mysql8 之前的版本中加密规则是mysql_native_password, mysql8之后,加密规则是caching_sha2_passw ...

  4. 2018中国大学生程序设计竞赛 - 网络选拔赛---Find Integer!--hdu6441

    问题传送门:https://vjudge.net/contest/320779#problem/D 介绍一个名词:奇偶数列法则 Key part: #include<iostream> # ...

  5. AntDesign(React)学习-7 Menu添加事件

    今天花了大半天时间从老家回到工作地,路上因为肺炎封堵挺厉害,希望国家挺过这个难关,要不大家都失业可就惨了,上一篇做了一个展示数据的demo,这一篇研究antd Menu item点击事件 1.还是先看 ...

  6. Spring作用域和BeenFactory

    1.Spring Bean实例作用域: ① singleton:   IOC容器仅创建一个Bean实例,IOC容器每次返回的是同一个Bean实例. ② prototype:   IOC容器可以创建多个 ...

  7. 利用Marshal来管理非托管资源

    void MarshalChartDemo() { string name = "xuwei"; IntPtr pName = Marshal.AllocHGlobal(name. ...

  8. Jmeter-几种脚本录制方式

    一.使用代理服务器进行录制 1.创建线程组 2.创建http代理服务器 分组解释 不对样本分组:所有请求全部罗列 在组件添加分隔:加入一个虚拟的以分割线命名的动作 每个组放入一个新的控制器:执行时按控 ...

  9. Win10激活工具 —— HWIDGen的使用方法

    一:引言 众所周知,Windows系统在安装完成之后,第一步就是激活系统,网上的一些激活方法大多数都是KMS激活,激活持续时间为半年. 因此,我找到了一个可以永久激活的工具:HWIDGen,它可以数字 ...

  10. 继 “多闪”后“飞聊”再被diss?其实社交还能这么玩

    近日头条低调上线了新的社交APP——飞聊,目前在AppStore社交排行榜第7位.但很多人使用了之后都觉得新产品的各个功能都让人想起其他的产品.兴趣小组让人想到豆瓣的兴趣小组,生活动态让人想到微博动态 ...