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. IndexedDB基本概念

    控制台 IndexedDB下为数据库 数据库下为表,表内容展现为主键值和其余值,其中其余值包括索引和其他任意字段,以对象形式表现 表下为索引字段表,用来展现拥有同一种索引字段的所有数据(有多少种索引就 ...

  2. Notepad++ 个人洁癖

    插件: JSON Viewer 可以以树的形式查看JSON,同时可以格式化JSON,增加缩进. NppExport 可以高亮复制 下载地址: https://github.com/chcg/NPP_E ...

  3. pytest学习8-运行上次执行失败的用例

    该插件提供了两个命令行选项,用于重新运行上次pytest调用的失败: --lf,--last-failed- 只重新运行上次失败的用例,如果没有失败则全部运行 --ff,--failed-first- ...

  4. WSO2 ESB XML定义语法(3)

    6.Property Mediator 通过Synapse调解的每条消息都可以具有一组关联的属性.Synapse引擎和底层传输在处理的每条消息上设置了许多属性,用户可以操纵这些属性来修改消息流的运行时 ...

  5. createElement(九)

    Vue.js 利用 createElement 方法创建 VNode,它定义在 src/core/vdom/create-elemenet.js 中: // wrapper function for ...

  6. python3练习100题——037

    原题链接:http://www.runoob.com/python/python-exercise-example37.html 题目:对10个数进行排序. 程序分析:可以利用选择法,即从后9个比较过 ...

  7. C 库函数 - strcpy()

    描述 C 库函数 char *strcpy(char *dest, const char *src) 把 src 所指向的字符串复制到 dest. 需要注意的是如果目标数组 dest 不够大,而源字符 ...

  8. python的selenium实现自动登陆

    知道思想,参考其他文档,python的request模块和selenium模块都可以实现get_cookie()和 add_cookie()的功能. 由于现在在学习selenium自动化测试,我选用s ...

  9. 【Python】遍历循环

  10. oracle数据库操作 接口封装

    1.如下 using Oracle.ManagedDataAccess.Client; using System; using System.Collections.Generic; using Sy ...