-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata_transforms.html
377 lines (332 loc) · 19.4 KB
/
data_transforms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>4. Dataset transformations — scikit-learn 0.15.2 documentation</title>
<!-- htmltitle is before nature.css - we use this hack to load bootstrap first -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="_static/css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" href="_static/css/bootstrap-responsive.css"/>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/gallery.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.15.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/copybutton.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="author" title="About these documents" href="about.html" />
<link rel="top" title="scikit-learn 0.15.2 documentation" href="index.html" />
<link rel="up" title="<no title>" href="user_guide.html" />
<link rel="next" title="4.1. Pipeline and FeatureUnion: combining estimators" href="modules/pipeline.html" />
<link rel="prev" title="3.5. Validation curves: plotting scores to evaluate models" href="modules/learning_curve.html" />
<script type="text/javascript" src="_static/sidebar.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="_static/js/bootstrap.min.js" type="text/javascript"></script>
<link rel="canonical" href="http://scikit-learn.org/stable/data_transforms.html" />
<script type="text/javascript">
$("div.buttonNext, div.buttonPrevious").hover(
function () {
$(this).css('background-color', '#FF9C34');
},
function () {
$(this).css('background-color', '#A7D6E2');
}
);
var bodywrapper = $('.bodywrapper');
var sidebarbutton = $('#sidebarbutton');
sidebarbutton.css({'height': '900px'});
</script>
</head>
<body>
<div class="header-wrapper">
<div class="header">
<p class="logo"><a href="index.html">
<img src="_static/scikit-learn-logo-small.png" alt="Logo"/>
</a>
</p><div class="navbar">
<ul>
<li><a href="../dev/index.html">Home</a></li>
<li><a href="../dev/install.html">Installation</a></li>
<li class="btn-li"><div class="btn-group">
<a href="documentation.html">Documentation</a>
<a class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li class="link-title">Scikit-learn 0.16 (development)</li>
<li><a href="tutorial/index.html">Tutorials</a></li>
<li><a href="user_guide.html">User guide</a></li>
<li><a href="modules/classes.html">API</a></li>
<li><a href="faq.html">FAQ</a></li>
<li class="divider"></li>
<li><a href="http://scikit-learn.org/stable/documentation.html">Stable</a></li>
<li><a href="http://scikit-learn.org/0.14/">Scikit-learn 0.14</a></li>
<li><a href="http://scikit-learn.org/0.13/">Scikit-learn 0.13</a></li>
<li><a href="http://scikit-learn.org/0.12/">Scikit-learn 0.12</a></li>
<li><a href="http://scikit-learn.org/0.11/">Scikit-learn 0.11</a></li>
<li><a href="documentation.html">More versions...</a></li>
</ul>
</div>
</li>
<li><a href="auto_examples/index.html">Examples</a></li>
</ul>
<div class="search_form">
<div id="cse" style="width: 100%;"></div>
</div>
</div> <!-- end navbar --></div>
</div>
<!-- Github "fork me" ribbon -->
<a href="https://github.com/scikit-learn/scikit-learn">
<img class="fork-me"
style="position: absolute; top: 0; right: 0; border: 0;"
src="_static/img/forkme.png"
alt="Fork me on GitHub" />
</a>
<div class="content-wrapper">
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div class="rel">
<!-- rellinks[1:] is an ugly hack to avoid link to module
index -->
<div class="rellink">
<a href="modules/learning_curve.html"
accesskey="P">Previous
<br/>
<span class="smallrellink">
3.5. Validation ...
</span>
<span class="hiddenrellink">
3.5. Validation curves: plotting scores to evaluate models
</span>
</a>
</div>
<div class="spacer">
</div>
<div class="rellink">
<a href="modules/pipeline.html"
accesskey="N">Next
<br/>
<span class="smallrellink">
4.1. Pipeline an...
</span>
<span class="hiddenrellink">
4.1. Pipeline and FeatureUnion: combining estimators
</span>
</a>
</div>
<!-- Ad a link to the 'up' page -->
<div class="spacer">
</div>
<div class="rellink">
<a href="user_guide.html">
Up
<br/>
<span class="smallrellink">
<no title>
</span>
</a>
</div>
</div>
<p class="doc-version">This documentation is for scikit-learn <strong>version 0.15.2</strong> — <a href="http://scikit-learn.org/stable/support.html#documentation-resources">Other versions</a></p>
<p class="citing">If you use the software, please consider <a href="about.html#citing-scikit-learn">citing scikit-learn</a>.</p>
<ul>
<li><a class="reference internal" href="#">4. Dataset transformations</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<style type="text/css">
div.bodywrapper blockquote {
margin: 0 ;
}
div.toctree-wrapper ul {
margin-top: 0 ;
margin-bottom: 0 ;
padding-left: 10px ;
}
li.toctree-l1 {
padding: 0 0 0.5em 0 ;
list-style-type: none;
font-size: 150% ;
font-weight: bold;
}
li.toctree-l1 ul {
padding-left: 40px ;
}
li.toctree-l2 {
font-size: 70% ;
list-style-type: square;
font-weight: normal;
}
li.toctree-l3 {
font-size: 85% ;
list-style-type: circle;
font-weight: normal;
}
</style><div class="section" id="dataset-transformations">
<span id="data-transforms"></span><h1>4. Dataset transformations<a class="headerlink" href="#dataset-transformations" title="Permalink to this headline">¶</a></h1>
<p>scikit-learn provides a library of transformers, which may clean (see
<a class="reference internal" href="modules/preprocessing.html#preprocessing"><em>Preprocessing data</em></a>), reduce (see <a class="reference internal" href="modules/unsupervised_reduction.html#data-reduction"><em>Unsupervised dimensionality reduction</em></a>), expand (see
<a class="reference internal" href="modules/kernel_approximation.html#kernel-approximation"><em>Kernel Approximation</em></a>) or generate (see <a class="reference internal" href="modules/feature_extraction.html#feature-extraction"><em>Feature extraction</em></a>)
feature representations.</p>
<p>Like other estimators, these are represented by classes with <tt class="docutils literal"><span class="pre">fit</span></tt> method,
which learns model parameters (e.g. mean and standard deviation for
normalization) from a training set, and a <tt class="docutils literal"><span class="pre">transform</span></tt> method which applies
this transformation model to unseen data. <tt class="docutils literal"><span class="pre">fit_transform</span></tt> may be more
convenient and efficient for modelling and transforming the training data
simultaneously.</p>
<p>Combining such transformers, either in parallel or series is covered in
<a class="reference internal" href="modules/pipeline.html#combining-estimators"><em>Pipeline and FeatureUnion: combining estimators</em></a>. <a class="reference internal" href="modules/metrics.html#metrics"><em>Pairwise metrics, Affinities and Kernels</em></a> covers transforming feature
spaces into affinity matrices, while <a class="reference internal" href="modules/preprocessing_targets.html#preprocessing-targets"><em>Transforming the prediction target (y)</em></a> considers
transformations of the target space (e.g. categorical labels) for use in
scikit-learn.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="modules/pipeline.html">4.1. Pipeline and FeatureUnion: combining estimators</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/pipeline.html#pipeline-chaining-estimators">4.1.1. Pipeline: chaining estimators</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/pipeline.html#usage">4.1.1.1. Usage</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/pipeline.html#notes">4.1.1.2. Notes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules/pipeline.html#featureunion-composite-feature-spaces">4.1.2. FeatureUnion: composite feature spaces</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/pipeline.html#id1">4.1.2.1. Usage</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/feature_extraction.html">4.2. Feature extraction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/feature_extraction.html#loading-features-from-dicts">4.2.1. Loading features from dicts</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/feature_extraction.html#feature-hashing">4.2.2. Feature hashing</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#implementation-details">4.2.2.1. Implementation details</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules/feature_extraction.html#text-feature-extraction">4.2.3. Text feature extraction</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#the-bag-of-words-representation">4.2.3.1. The Bag of Words representation</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#sparsity">4.2.3.2. Sparsity</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#common-vectorizer-usage">4.2.3.3. Common Vectorizer usage</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#tfidf-term-weighting">4.2.3.4. Tf–idf term weighting</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#decoding-text-files">4.2.3.5. Decoding text files</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#applications-and-examples">4.2.3.6. Applications and examples</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#limitations-of-the-bag-of-words-representation">4.2.3.7. Limitations of the Bag of Words representation</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#vectorizing-a-large-text-corpus-with-the-hashing-trick">4.2.3.8. Vectorizing a large text corpus with the hashing trick</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#performing-out-of-core-scaling-with-hashingvectorizer">4.2.3.9. Performing out-of-core scaling with HashingVectorizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#customizing-the-vectorizer-classes">4.2.3.10. Customizing the vectorizer classes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules/feature_extraction.html#image-feature-extraction">4.2.4. Image feature extraction</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#patch-extraction">4.2.4.1. Patch extraction</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/feature_extraction.html#connectivity-graph-of-an-image">4.2.4.2. Connectivity graph of an image</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/preprocessing.html">4.3. Preprocessing data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing.html#standardization-or-mean-removal-and-variance-scaling">4.3.1. Standardization, or mean removal and variance scaling</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/preprocessing.html#scaling-features-to-a-range">4.3.1.1. Scaling features to a range</a></li>
<li class="toctree-l3"><a class="reference internal" href="modules/preprocessing.html#centering-kernel-matrices">4.3.1.2. Centering kernel matrices</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing.html#normalization">4.3.2. Normalization</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing.html#binarization">4.3.3. Binarization</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules/preprocessing.html#feature-binarization">4.3.3.1. Feature binarization</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing.html#encoding-categorical-features">4.3.4. Encoding categorical features</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing.html#imputation-of-missing-values">4.3.5. Imputation of missing values</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/unsupervised_reduction.html">4.4. Unsupervised dimensionality reduction</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/unsupervised_reduction.html#pca-principal-component-analysis">4.4.1. PCA: principal component analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/unsupervised_reduction.html#random-projections">4.4.2. Random projections</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/unsupervised_reduction.html#feature-agglomeration">4.4.3. Feature agglomeration</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/random_projection.html">4.5. Random Projection</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/random_projection.html#the-johnson-lindenstrauss-lemma">4.5.1. The Johnson-Lindenstrauss lemma</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/random_projection.html#gaussian-random-projection">4.5.2. Gaussian random projection</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/random_projection.html#sparse-random-projection">4.5.3. Sparse random projection</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/kernel_approximation.html">4.6. Kernel Approximation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/kernel_approximation.html#nystroem-method-for-kernel-approximation">4.6.1. Nystroem Method for Kernel Approximation</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/kernel_approximation.html#radial-basis-function-kernel">4.6.2. Radial Basis Function Kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/kernel_approximation.html#additive-chi-squared-kernel">4.6.3. Additive Chi Squared Kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/kernel_approximation.html#skewed-chi-squared-kernel">4.6.4. Skewed Chi Squared Kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/kernel_approximation.html#mathematical-details">4.6.5. Mathematical Details</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/metrics.html">4.7. Pairwise metrics, Affinities and Kernels</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/metrics.html#cosine-similarity">4.7.1. Cosine similarity</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/metrics.html#linear-kernel">4.7.2. Linear kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/metrics.html#polynomial-kernel">4.7.3. Polynomial kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/metrics.html#sigmoid-kernel">4.7.4. Sigmoid kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/metrics.html#rbf-kernel">4.7.5. RBF kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/metrics.html#chi-squared-kernel">4.7.6. Chi-squared kernel</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules/preprocessing_targets.html">4.8. Transforming the prediction target (<tt class="docutils literal"><span class="pre">y</span></tt>)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing_targets.html#label-binarization">4.8.1. Label binarization</a></li>
<li class="toctree-l2"><a class="reference internal" href="modules/preprocessing_targets.html#label-encoding">4.8.2. Label encoding</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<div class="footer">
© 2010 - 2014, scikit-learn developers (BSD License).
<a href="_sources/data_transforms.txt" rel="nofollow">Show this page source</a>
</div>
<div class="rel">
<div class="buttonPrevious">
<a href="modules/learning_curve.html">Previous
</a>
</div>
<div class="buttonNext">
<a href="modules/pipeline.html">Next
</a>
</div>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22606712-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript"> google.load('search', '1',
{language : 'en'}); google.setOnLoadCallback(function() {
var customSearchControl = new
google.search.CustomSearchControl('016639176250731907682:tjtqbvtvij0');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setAutoComplete(true);
customSearchControl.draw('cse', options); }, true);
</script>
</body>
</html>