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. 前后端分离开发,跨域时jsessionid每次请求都变化的问题解决方法

    本解决方法的使用前提是,前端开发使用的是vue,后端使用java(SpringMVC) 在前后端分离开发过程中,可能会出现因跨域而导致每次请求的jsessionid不一致的情况 解决方法: 前端:要在 ...

  2. ssh排错思路

    telnet远程22端口refused 先netstat  -utnlp  看一下22端口监听状态(一般都不在监听) 然后systemctl  restart sshd 如果有报错,执行sshd  - ...

  3. ubuntu set up 1 - 网络

    r2v has to be replaced.. 1. 官网下载zip版本,下载安装脚本 https://www.r2v.com/chapter_00/install.html https://ins ...

  4. LED Holiday Light -holiday Light Inspection Implementation Recommendations

    China LED Holiday Light Factory & Ninghai County Haohua Electronic Appliance Co., Ltd. pointed o ...

  5. ASP.NET MVC 简介(附VS2019和VSCode版示例)

    MVC可以理解为一种思想,应用在web应用程序的架构上. ASP.NET MVC的核心类是实现了IHttpHandler接口的MVCHandler,它的底层仍然是HttpHandler.HttpReq ...

  6. PP: Multilevel wavelet decomposition network for interpretable time series analysis

    Problem: the important frequency information is lack of effective modelling. ?? what is frequency in ...

  7. nginx 无法启动:bind() to 0.0.0.0:443 failed

    bind to 0.0.0.0:443 failed.其实就是443端口被其它程序占用,要结束占用443端口导致nginx不能启动的应用. CMD: 1.查看所有程序使用的端口 netstat -ao ...

  8. 心里没点B树,怎能吃透数据库索引底层原理?

    二叉树(Binary Search Trees) 二叉树是每个结点最多有两个子树的树结构.通常子树被称作“左子树”(Left Subtree)和“右子树”(Right Subtree).二叉树常被用于 ...

  9. 使用node搭建静态资源服务器

    安装 npm install yumu-static-server -g 使用 shift+鼠标右键  在此处打开Powershell 窗口 server # 会在当前目录下启动一个静态资源服务器,默 ...

  10. 白面系列 kafka

    kafka是一个分布式发布订阅消息系统,也可叫做MQ系统,MQ是Message Queue,消息队列. 通俗点,生产者往队列里写消息,消费者从队列里读.专业点,Producer通过TCP协议发送消息到 ...