-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathmldata.html
280 lines (241 loc) · 15.1 KB
/
mldata.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
<!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>Downloading datasets from the mldata.org repository — scikit-learn 0.15-git 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" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.15-git',
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-git documentation" href="../index.html" />
<link rel="next" title="The Olivetti faces dataset" href="olivetti_faces.html" />
<link rel="prev" title="The Labeled Faces in the Wild face recognition dataset" href="labeled_faces.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="https://scikit-learn.org/stable/datasets/mldata.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="../../stable/index.html">Home</a></li>
<li><a href="../../stable/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.15 (stable)</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/dev/documentation.html">Development</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 rellarge">
<!-- rellinks[1:] is an ugly hack to avoid link to module
index -->
<div class="rellink">
<a href="labeled_faces.html"
accesskey="P">Previous
<br/>
<span class="smallrellink">
The Labeled Face...
</span>
<span class="hiddenrellink">
The Labeled Faces in the Wild face recognition dataset
</span>
</a>
</div>
<div class="spacer">
</div>
<div class="rellink">
<a href="olivetti_faces.html"
accesskey="N">Next
<br/>
<span class="smallrellink">
The Olivetti fac...
</span>
<span class="hiddenrellink">
The Olivetti faces dataset
</span>
</a>
</div>
<!-- Ad a link to the 'up' page -->
</div>
<p class="doc-version">This documentation is for scikit-learn <strong>version 0.15-git</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="#">Downloading datasets from the mldata.org repository</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="downloading-datasets-from-the-mldata-org-repository">
<span id="mldata"></span><h1>Downloading datasets from the mldata.org repository<a class="headerlink" href="#downloading-datasets-from-the-mldata-org-repository" title="Permalink to this headline">¶</a></h1>
<p><a class="reference external" href="http://mldata.org">mldata.org</a> is a public repository for machine learning
data, supported by the <a class="reference external" href="http://www.pascal-network.org">PASCAL network</a> .</p>
<p>The <tt class="docutils literal"><span class="pre">sklearn.datasets</span></tt> package is able to directly download data
sets from the repository using the function <tt class="docutils literal"><span class="pre">fetch_mldata(dataname)</span></tt>.</p>
<p>For example, to download the MNIST digit recognition database:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">sklearn.datasets</span> <span class="kn">import</span> <span class="n">fetch_mldata</span>
<span class="gp">>>> </span><span class="n">mnist</span> <span class="o">=</span> <span class="n">fetch_mldata</span><span class="p">(</span><span class="s">'MNIST original'</span><span class="p">,</span> <span class="n">data_home</span><span class="o">=</span><span class="n">custom_data_home</span><span class="p">)</span>
</pre></div>
</div>
<p>The MNIST database contains a total of 70000 examples of handwritten digits
of size 28x28 pixels, labeled from 0 to 9:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mnist</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(70000, 784)</span>
<span class="gp">>>> </span><span class="n">mnist</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(70000,)</span>
<span class="gp">>>> </span><span class="n">np</span><span class="o">.</span><span class="n">unique</span><span class="p">(</span><span class="n">mnist</span><span class="o">.</span><span class="n">target</span><span class="p">)</span>
<span class="go">array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])</span>
</pre></div>
</div>
<p>After the first download, the dataset is cached locally in the path
specified by the <tt class="docutils literal"><span class="pre">data_home</span></tt> keyword argument, which defaults to
<tt class="docutils literal"><span class="pre">~/scikit_learn_data/</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">custom_data_home</span><span class="p">,</span> <span class="s">'mldata'</span><span class="p">))</span>
<span class="go">['mnist-original.mat']</span>
</pre></div>
</div>
<p>Data sets in <a class="reference external" href="http://mldata.org">mldata.org</a> do not adhere to a strict
naming or formatting convention. <tt class="docutils literal"><span class="pre">fetch_mldata</span></tt> is able to make sense
of the most common cases, but allows to tailor the defaults to individual
datasets:</p>
<ul>
<li><p class="first">The data arrays in <a class="reference external" href="http://mldata.org">mldata.org</a> are most often
shaped as <tt class="docutils literal"><span class="pre">(n_features,</span> <span class="pre">n_samples)</span></tt>. This is the opposite of the
<tt class="docutils literal"><span class="pre">scikit-learn</span></tt> convention, so <tt class="docutils literal"><span class="pre">fetch_mldata</span></tt> transposes the matrix
by default. The <tt class="docutils literal"><span class="pre">transpose_data</span></tt> keyword controls this behavior:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">iris</span> <span class="o">=</span> <span class="n">fetch_mldata</span><span class="p">(</span><span class="s">'iris'</span><span class="p">,</span> <span class="n">data_home</span><span class="o">=</span><span class="n">custom_data_home</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">iris</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(150, 4)</span>
<span class="gp">>>> </span><span class="n">iris</span> <span class="o">=</span> <span class="n">fetch_mldata</span><span class="p">(</span><span class="s">'iris'</span><span class="p">,</span> <span class="n">transpose_data</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">data_home</span><span class="o">=</span><span class="n">custom_data_home</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">iris</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span>
<span class="go">(4, 150)</span>
</pre></div>
</div>
</li>
<li><p class="first">For datasets with multiple columns, <tt class="docutils literal"><span class="pre">fetch_mldata</span></tt> tries to identify
the target and data columns and rename them to <tt class="docutils literal"><span class="pre">target</span></tt> and <tt class="docutils literal"><span class="pre">data</span></tt>.
This is done by looking for arrays named <tt class="docutils literal"><span class="pre">label</span></tt> and <tt class="docutils literal"><span class="pre">data</span></tt> in the
dataset, and failing that by choosing the first array to be <tt class="docutils literal"><span class="pre">target</span></tt>
and the second to be <tt class="docutils literal"><span class="pre">data</span></tt>. This behavior can be changed with the
<tt class="docutils literal"><span class="pre">target_name</span></tt> and <tt class="docutils literal"><span class="pre">data_name</span></tt> keywords, setting them to a specific
name or index number (the name and order of the columns in the datasets
can be found at its <a class="reference external" href="http://mldata.org">mldata.org</a> under the tab “Data”:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">iris2</span> <span class="o">=</span> <span class="n">fetch_mldata</span><span class="p">(</span><span class="s">'datasets-UCI iris'</span><span class="p">,</span> <span class="n">target_name</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">data_name</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">data_home</span><span class="o">=</span><span class="n">custom_data_home</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">iris3</span> <span class="o">=</span> <span class="n">fetch_mldata</span><span class="p">(</span><span class="s">'datasets-UCI iris'</span><span class="p">,</span> <span class="n">target_name</span><span class="o">=</span><span class="s">'class'</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">data_name</span><span class="o">=</span><span class="s">'double0'</span><span class="p">,</span> <span class="n">data_home</span><span class="o">=</span><span class="n">custom_data_home</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<div class="footer">
© 2010 - 2014, scikit-learn developers (BSD License).
<a href="../_sources/datasets/mldata.txt" rel="nofollow">Show this page source</a>
</div>
<div class="rel rellarge">
<div class="buttonPrevious">
<a href="labeled_faces.html">Previous
</a>
</div>
<div class="buttonNext">
<a href="olivetti_faces.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>
<script src="https://scikit-learn.org/versionwarning.js"></script>
</body>
</html>