列独热编码器
该文件是TPOT库的一部分。
当前版本的TPOT是由以下人员在Cedars-Sinai开发的: - Pedro Henrique Ribeiro (https://github.com/perib, https://www.linkedin.com/in/pedro-ribeiro/) - Anil Saini (anil.saini@cshs.org) - Jose Hernandez (jgh9094@gmail.com) - Jay Moran (jay.moran@cshs.org) - Nicholas Matsumoto (nicholas.matsumoto@cshs.org) - Hyunjun Choi (hyunjun.choi@cshs.org) - Miguel E. Hernandez (miguel.e.hernandez@cshs.org) - Jason Moore (moorejh28@gmail.com)
TPOT的原始版本主要由宾夕法尼亚大学的以下人员开发: - Randal S. Olson (rso@randalolson.com) - Weixuan Fu (weixuanf@upenn.edu) - Daniel Angell (dpa34@drexel.edu) - Jason Moore (moorejh28@gmail.com) - 以及许多慷慨的开源贡献者
TPOT 是免费软件:您可以根据自由软件基金会发布的 GNU 宽通用公共许可证的条款重新分发和/或修改它,许可证的版本可以是第 3 版,或者(根据您的选择)任何以后的版本。
TPOT 的发布是希望它能有用, 但没有任何保证;甚至没有对 适销性或特定用途适用性的暗示保证。更多详情请参阅 GNU 较宽松通用公共许可证。
您应该已经收到了一份GNU较宽松通用公共许可证的副本,随TPOT一起提供。如果没有,请参见http://www.gnu.org/licenses/。
ColumnOneHotEncoder
¶
基类:BaseEstimator, TransformerMixin
Source code in tpot2/builtin_modules/column_one_hot_encoder.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
__init__(columns='auto', drop=None, handle_unknown='infrequent_if_exist', sparse_output=False, min_frequency=None, max_categories=None)
¶
OneHotEncoder 的包装器,允许对 DataFrame 或 np 数组中的特定列进行 onehot 编码。
参数:
| 名称 | 类型 | 描述 | 默认值 |
|---|---|---|---|
columns |
(str, list)
|
确定使用sklearn.preprocessing.OneHotEncoder进行独热编码的列。 - 'auto' : 根据具有少于10个唯一值的列自动选择分类特征 - 'categorical' : 自动选择分类特征 - 'numeric' : 自动选择数值特征 - 'all' : 选择所有特征 - list : 选择列的列表 |
'auto'
|
drop |
参见 sklearn.preprocessing.OneHotEncoder
|
|
None
|
handle_unknown |
参见 sklearn.preprocessing.OneHotEncoder
|
|
None
|
sparse_output |
参见 sklearn.preprocessing.OneHotEncoder
|
|
None
|
min_frequency |
参见 sklearn.preprocessing.OneHotEncoder
|
|
None
|
max_categories |
see sklearn.preprocessing.OneHotEncoder
|
|
None
|
Source code in tpot2/builtin_modules/column_one_hot_encoder.py
fit(X, y=None)
¶
将OneHotEncoder适配到X,然后转换X。
等同于 self.fit(X).transform(X),但更方便且更高效。有关参数请参见 fit,有关返回值请参见 transform。
参数:
| 名称 | 类型 | 描述 | 默认值 |
|---|---|---|---|
X |
array-like or sparse matrix, shape=(n_samples, n_features)
|
密集数组或稀疏矩阵。 |
必填 |
y |
特征标签 |
None
|
Source code in tpot2/builtin_modules/column_one_hot_encoder.py
transform(X)
¶
使用独热编码转换X。
参数:
| 名称 | 类型 | 描述 | 默认值 |
|---|---|---|---|
X |
array-like or sparse matrix, shape=(n_samples, n_features)
|
密集数组或稀疏矩阵。 |
required |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
X_out |
sparse matrix if sparse=True else a 2-d array, dtype=int
|
转换后的输入。 |