ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
IrisClassDatasets.hh
[詳解]
1
9//
10// Copyright (C) 2011-2020 Yokokura, Yuki
11// This program is free software;
12// you can redistribute it and/or modify it under the terms of the FreeBSD License.
13// For details, see the License.txt file.
14
15#ifndef IRISCLASSDATASETS
16#define IRISCLASSDATASETS
17
18#include <cassert>
19#include <array>
20#include "Matrix.hh"
21#include "Shuffle.hh"
22#include "BatchProcessor.hh"
23
24// ARCS組込み用マクロ
25#ifdef ARCS_IN
26 // ARCSに組み込まれる場合
27 #include "ARCSassert.hh"
28 #include "ARCSeventlog.hh"
29#else
30 // ARCSに組み込まれない場合
31 #define arcs_assert(a) (assert(a))
32 #define PassedLog()
33 #define EventLog(a)
34 #define EventLogVar(a)
35#endif
36
37namespace ARCS { // ARCS名前空間
40template <size_t M>
42 public:
43 // データセット情報の定義
44 static constexpr size_t D = 150;
45 static constexpr size_t N = 4;
46 static constexpr size_t C = 3;
47 static constexpr size_t FinalMinbatNum = D/M - 1;
48
49 // アヤメの分類の定義
52
55 : MeasuredData(), ClassData(), Shfl()
56 {
57 PassedLog();
58 MeasuredData.LoadArray(IrisMeasurement); // 計測データを行列として読み込み
59 ClassData.LoadArray(IrisClassification); // 分類データを行列として読み込み
60 ShuffleDatasets(); // シャッフルの実行
61 }
62
70
75
77 void DispMeasuredData(void){
78 printf("\nIris Mesurement Data:\n");
79 PrintMatrix(MeasuredData, "% 3.1f");
80 }
81
83 void DispClassData(void){
84 printf("\nIris Classification Data:\n");
85 PrintMatrix(ClassData, "% 1.0f");
86 }
87
91 void GetMeasuredBatchData(const size_t i, Matrix<M,N>& Y){
92 arcs_assert(i <= FinalMinbatNum); // ミニバッチ番号の範囲チェック
93 Y = BatchProcessor::GetMiniBatchData<N,D,M>(MeasuredData, i); // データセットを切り出してミニバッチにする
94 }
95
99 void GetClassBatchData(const size_t i, Matrix<M,C>& y){
100 arcs_assert(i <= FinalMinbatNum); // ミニバッチ番号の範囲チェック
101 y = BatchProcessor::GetMiniBatchData<C,D,M>(ClassData, i); // データセットを切り出してミニバッチにする
102 }
103
105 void ShuffleDatasets(void){
106 Shfl.ShuffleMatrixRow(MeasuredData, ClassData); // シャッフルの実行
107 }
108
109 private:
110 IrisClassDatasets(const IrisClassDatasets&) = delete;
111 const IrisClassDatasets& operator=(const IrisClassDatasets&) = delete;
112 Shuffle Shfl;
113
116 static constexpr std::array<std::array<double, N>, D> IrisMeasurement = {{
117 {5.1,3.5,1.4,0.2},
118 {4.9,3.0,1.4,0.2},
119 {4.7,3.2,1.3,0.2},
120 {4.6,3.1,1.5,0.2},
121 {5.0,3.6,1.4,0.2},
122 {5.4,3.9,1.7,0.4},
123 {4.6,3.4,1.4,0.3},
124 {5.0,3.4,1.5,0.2},
125 {4.4,2.9,1.4,0.2},
126 {4.9,3.1,1.5,0.1},
127 {5.4,3.7,1.5,0.2},
128 {4.8,3.4,1.6,0.2},
129 {4.8,3.0,1.4,0.1},
130 {4.3,3.0,1.1,0.1},
131 {5.8,4.0,1.2,0.2},
132 {5.7,4.4,1.5,0.4},
133 {5.4,3.9,1.3,0.4},
134 {5.1,3.5,1.4,0.3},
135 {5.7,3.8,1.7,0.3},
136 {5.1,3.8,1.5,0.3},
137 {5.4,3.4,1.7,0.2},
138 {5.1,3.7,1.5,0.4},
139 {4.6,3.6,1.0,0.2},
140 {5.1,3.3,1.7,0.5},
141 {4.8,3.4,1.9,0.2},
142 {5.0,3.0,1.6,0.2},
143 {5.0,3.4,1.6,0.4},
144 {5.2,3.5,1.5,0.2},
145 {5.2,3.4,1.4,0.2},
146 {4.7,3.2,1.6,0.2},
147 {4.8,3.1,1.6,0.2},
148 {5.4,3.4,1.5,0.4},
149 {5.2,4.1,1.5,0.1},
150 {5.5,4.2,1.4,0.2},
151 {4.9,3.1,1.5,0.1},
152 {5.0,3.2,1.2,0.2},
153 {5.5,3.5,1.3,0.2},
154 {4.9,3.1,1.5,0.1},
155 {4.4,3.0,1.3,0.2},
156 {5.1,3.4,1.5,0.2},
157 {5.0,3.5,1.3,0.3},
158 {4.5,2.3,1.3,0.3},
159 {4.4,3.2,1.3,0.2},
160 {5.0,3.5,1.6,0.6},
161 {5.1,3.8,1.9,0.4},
162 {4.8,3.0,1.4,0.3},
163 {5.1,3.8,1.6,0.2},
164 {4.6,3.2,1.4,0.2},
165 {5.3,3.7,1.5,0.2},
166 {5.0,3.3,1.4,0.2},
167 {7.0,3.2,4.7,1.4},
168 {6.4,3.2,4.5,1.5},
169 {6.9,3.1,4.9,1.5},
170 {5.5,2.3,4.0,1.3},
171 {6.5,2.8,4.6,1.5},
172 {5.7,2.8,4.5,1.3},
173 {6.3,3.3,4.7,1.6},
174 {4.9,2.4,3.3,1.0},
175 {6.6,2.9,4.6,1.3},
176 {5.2,2.7,3.9,1.4},
177 {5.0,2.0,3.5,1.0},
178 {5.9,3.0,4.2,1.5},
179 {6.0,2.2,4.0,1.0},
180 {6.1,2.9,4.7,1.4},
181 {5.6,2.9,3.6,1.3},
182 {6.7,3.1,4.4,1.4},
183 {5.6,3.0,4.5,1.5},
184 {5.8,2.7,4.1,1.0},
185 {6.2,2.2,4.5,1.5},
186 {5.6,2.5,3.9,1.1},
187 {5.9,3.2,4.8,1.8},
188 {6.1,2.8,4.0,1.3},
189 {6.3,2.5,4.9,1.5},
190 {6.1,2.8,4.7,1.2},
191 {6.4,2.9,4.3,1.3},
192 {6.6,3.0,4.4,1.4},
193 {6.8,2.8,4.8,1.4},
194 {6.7,3.0,5.0,1.7},
195 {6.0,2.9,4.5,1.5},
196 {5.7,2.6,3.5,1.0},
197 {5.5,2.4,3.8,1.1},
198 {5.5,2.4,3.7,1.0},
199 {5.8,2.7,3.9,1.2},
200 {6.0,2.7,5.1,1.6},
201 {5.4,3.0,4.5,1.5},
202 {6.0,3.4,4.5,1.6},
203 {6.7,3.1,4.7,1.5},
204 {6.3,2.3,4.4,1.3},
205 {5.6,3.0,4.1,1.3},
206 {5.5,2.5,4.0,1.3},
207 {5.5,2.6,4.4,1.2},
208 {6.1,3.0,4.6,1.4},
209 {5.8,2.6,4.0,1.2},
210 {5.0,2.3,3.3,1.0},
211 {5.6,2.7,4.2,1.3},
212 {5.7,3.0,4.2,1.2},
213 {5.7,2.9,4.2,1.3},
214 {6.2,2.9,4.3,1.3},
215 {5.1,2.5,3.0,1.1},
216 {5.7,2.8,4.1,1.3},
217 {6.3,3.3,6.0,2.5},
218 {5.8,2.7,5.1,1.9},
219 {7.1,3.0,5.9,2.1},
220 {6.3,2.9,5.6,1.8},
221 {6.5,3.0,5.8,2.2},
222 {7.6,3.0,6.6,2.1},
223 {4.9,2.5,4.5,1.7},
224 {7.3,2.9,6.3,1.8},
225 {6.7,2.5,5.8,1.8},
226 {7.2,3.6,6.1,2.5},
227 {6.5,3.2,5.1,2.0},
228 {6.4,2.7,5.3,1.9},
229 {6.8,3.0,5.5,2.1},
230 {5.7,2.5,5.0,2.0},
231 {5.8,2.8,5.1,2.4},
232 {6.4,3.2,5.3,2.3},
233 {6.5,3.0,5.5,1.8},
234 {7.7,3.8,6.7,2.2},
235 {7.7,2.6,6.9,2.3},
236 {6.0,2.2,5.0,1.5},
237 {6.9,3.2,5.7,2.3},
238 {5.6,2.8,4.9,2.0},
239 {7.7,2.8,6.7,2.0},
240 {6.3,2.7,4.9,1.8},
241 {6.7,3.3,5.7,2.1},
242 {7.2,3.2,6.0,1.8},
243 {6.2,2.8,4.8,1.8},
244 {6.1,3.0,4.9,1.8},
245 {6.4,2.8,5.6,2.1},
246 {7.2,3.0,5.8,1.6},
247 {7.4,2.8,6.1,1.9},
248 {7.9,3.8,6.4,2.0},
249 {6.4,2.8,5.6,2.2},
250 {6.3,2.8,5.1,1.5},
251 {6.1,2.6,5.6,1.4},
252 {7.7,3.0,6.1,2.3},
253 {6.3,3.4,5.6,2.4},
254 {6.4,3.1,5.5,1.8},
255 {6.0,3.0,4.8,1.8},
256 {6.9,3.1,5.4,2.1},
257 {6.7,3.1,5.6,2.4},
258 {6.9,3.1,5.1,2.3},
259 {5.8,2.7,5.1,1.9},
260 {6.8,3.2,5.9,2.3},
261 {6.7,3.3,5.7,2.5},
262 {6.7,3.0,5.2,2.3},
263 {6.3,2.5,5.0,1.9},
264 {6.5,3.0,5.2,2.0},
265 {6.2,3.4,5.4,2.3},
266 {5.9,3.0,5.1,1.8}
267 }};
268
270 static constexpr std::array<std::array<double, C>, D> IrisClassification = {{
271 {1,0,0},// IRIS_SETOSA
272 {1,0,0},// IRIS_SETOSA
273 {1,0,0},// IRIS_SETOSA
274 {1,0,0},// IRIS_SETOSA
275 {1,0,0},// IRIS_SETOSA
276 {1,0,0},// IRIS_SETOSA
277 {1,0,0},// IRIS_SETOSA
278 {1,0,0},// IRIS_SETOSA
279 {1,0,0},// IRIS_SETOSA
280 {1,0,0},// IRIS_SETOSA
281 {1,0,0},// IRIS_SETOSA
282 {1,0,0},// IRIS_SETOSA
283 {1,0,0},// IRIS_SETOSA
284 {1,0,0},// IRIS_SETOSA
285 {1,0,0},// IRIS_SETOSA
286 {1,0,0},// IRIS_SETOSA
287 {1,0,0},// IRIS_SETOSA
288 {1,0,0},// IRIS_SETOSA
289 {1,0,0},// IRIS_SETOSA
290 {1,0,0},// IRIS_SETOSA
291 {1,0,0},// IRIS_SETOSA
292 {1,0,0},// IRIS_SETOSA
293 {1,0,0},// IRIS_SETOSA
294 {1,0,0},// IRIS_SETOSA
295 {1,0,0},// IRIS_SETOSA
296 {1,0,0},// IRIS_SETOSA
297 {1,0,0},// IRIS_SETOSA
298 {1,0,0},// IRIS_SETOSA
299 {1,0,0},// IRIS_SETOSA
300 {1,0,0},// IRIS_SETOSA
301 {1,0,0},// IRIS_SETOSA
302 {1,0,0},// IRIS_SETOSA
303 {1,0,0},// IRIS_SETOSA
304 {1,0,0},// IRIS_SETOSA
305 {1,0,0},// IRIS_SETOSA
306 {1,0,0},// IRIS_SETOSA
307 {1,0,0},// IRIS_SETOSA
308 {1,0,0},// IRIS_SETOSA
309 {1,0,0},// IRIS_SETOSA
310 {1,0,0},// IRIS_SETOSA
311 {1,0,0},// IRIS_SETOSA
312 {1,0,0},// IRIS_SETOSA
313 {1,0,0},// IRIS_SETOSA
314 {1,0,0},// IRIS_SETOSA
315 {1,0,0},// IRIS_SETOSA
316 {1,0,0},// IRIS_SETOSA
317 {1,0,0},// IRIS_SETOSA
318 {1,0,0},// IRIS_SETOSA
319 {1,0,0},// IRIS_SETOSA
320 {1,0,0},// IRIS_SETOSA
321 {0,1,0},// IRIS_VERSICOLOR
322 {0,1,0},// IRIS_VERSICOLOR
323 {0,1,0},// IRIS_VERSICOLOR
324 {0,1,0},// IRIS_VERSICOLOR
325 {0,1,0},// IRIS_VERSICOLOR
326 {0,1,0},// IRIS_VERSICOLOR
327 {0,1,0},// IRIS_VERSICOLOR
328 {0,1,0},// IRIS_VERSICOLOR
329 {0,1,0},// IRIS_VERSICOLOR
330 {0,1,0},// IRIS_VERSICOLOR
331 {0,1,0},// IRIS_VERSICOLOR
332 {0,1,0},// IRIS_VERSICOLOR
333 {0,1,0},// IRIS_VERSICOLOR
334 {0,1,0},// IRIS_VERSICOLOR
335 {0,1,0},// IRIS_VERSICOLOR
336 {0,1,0},// IRIS_VERSICOLOR
337 {0,1,0},// IRIS_VERSICOLOR
338 {0,1,0},// IRIS_VERSICOLOR
339 {0,1,0},// IRIS_VERSICOLOR
340 {0,1,0},// IRIS_VERSICOLOR
341 {0,1,0},// IRIS_VERSICOLOR
342 {0,1,0},// IRIS_VERSICOLOR
343 {0,1,0},// IRIS_VERSICOLOR
344 {0,1,0},// IRIS_VERSICOLOR
345 {0,1,0},// IRIS_VERSICOLOR
346 {0,1,0},// IRIS_VERSICOLOR
347 {0,1,0},// IRIS_VERSICOLOR
348 {0,1,0},// IRIS_VERSICOLOR
349 {0,1,0},// IRIS_VERSICOLOR
350 {0,1,0},// IRIS_VERSICOLOR
351 {0,1,0},// IRIS_VERSICOLOR
352 {0,1,0},// IRIS_VERSICOLOR
353 {0,1,0},// IRIS_VERSICOLOR
354 {0,1,0},// IRIS_VERSICOLOR
355 {0,1,0},// IRIS_VERSICOLOR
356 {0,1,0},// IRIS_VERSICOLOR
357 {0,1,0},// IRIS_VERSICOLOR
358 {0,1,0},// IRIS_VERSICOLOR
359 {0,1,0},// IRIS_VERSICOLOR
360 {0,1,0},// IRIS_VERSICOLOR
361 {0,1,0},// IRIS_VERSICOLOR
362 {0,1,0},// IRIS_VERSICOLOR
363 {0,1,0},// IRIS_VERSICOLOR
364 {0,1,0},// IRIS_VERSICOLOR
365 {0,1,0},// IRIS_VERSICOLOR
366 {0,1,0},// IRIS_VERSICOLOR
367 {0,1,0},// IRIS_VERSICOLOR
368 {0,1,0},// IRIS_VERSICOLOR
369 {0,1,0},// IRIS_VERSICOLOR
370 {0,1,0},// IRIS_VERSICOLOR
371 {0,0,1},// IRIS_VIRGINICA
372 {0,0,1},// IRIS_VIRGINICA
373 {0,0,1},// IRIS_VIRGINICA
374 {0,0,1},// IRIS_VIRGINICA
375 {0,0,1},// IRIS_VIRGINICA
376 {0,0,1},// IRIS_VIRGINICA
377 {0,0,1},// IRIS_VIRGINICA
378 {0,0,1},// IRIS_VIRGINICA
379 {0,0,1},// IRIS_VIRGINICA
380 {0,0,1},// IRIS_VIRGINICA
381 {0,0,1},// IRIS_VIRGINICA
382 {0,0,1},// IRIS_VIRGINICA
383 {0,0,1},// IRIS_VIRGINICA
384 {0,0,1},// IRIS_VIRGINICA
385 {0,0,1},// IRIS_VIRGINICA
386 {0,0,1},// IRIS_VIRGINICA
387 {0,0,1},// IRIS_VIRGINICA
388 {0,0,1},// IRIS_VIRGINICA
389 {0,0,1},// IRIS_VIRGINICA
390 {0,0,1},// IRIS_VIRGINICA
391 {0,0,1},// IRIS_VIRGINICA
392 {0,0,1},// IRIS_VIRGINICA
393 {0,0,1},// IRIS_VIRGINICA
394 {0,0,1},// IRIS_VIRGINICA
395 {0,0,1},// IRIS_VIRGINICA
396 {0,0,1},// IRIS_VIRGINICA
397 {0,0,1},// IRIS_VIRGINICA
398 {0,0,1},// IRIS_VIRGINICA
399 {0,0,1},// IRIS_VIRGINICA
400 {0,0,1},// IRIS_VIRGINICA
401 {0,0,1},// IRIS_VIRGINICA
402 {0,0,1},// IRIS_VIRGINICA
403 {0,0,1},// IRIS_VIRGINICA
404 {0,0,1},// IRIS_VIRGINICA
405 {0,0,1},// IRIS_VIRGINICA
406 {0,0,1},// IRIS_VIRGINICA
407 {0,0,1},// IRIS_VIRGINICA
408 {0,0,1},// IRIS_VIRGINICA
409 {0,0,1},// IRIS_VIRGINICA
410 {0,0,1},// IRIS_VIRGINICA
411 {0,0,1},// IRIS_VIRGINICA
412 {0,0,1},// IRIS_VIRGINICA
413 {0,0,1},// IRIS_VIRGINICA
414 {0,0,1},// IRIS_VIRGINICA
415 {0,0,1},// IRIS_VIRGINICA
416 {0,0,1},// IRIS_VIRGINICA
417 {0,0,1},// IRIS_VIRGINICA
418 {0,0,1},// IRIS_VIRGINICA
419 {0,0,1},// IRIS_VIRGINICA
420 {0,0,1} // IRIS_VIRGINICA
421 }};
422};
423}
424
425#endif
426
ARCS イベントログクラス
#define PassedLog()
イベントログ用マクロ(ファイルと行番号のみ記録版)
Definition ARCSeventlog.hh:26
ARCS用ASSERTクラス
#define arcs_assert(a)
ARCS用assertマクロ a : assert条件
Definition ARCSassert.hh:17
バッチ処理器クラス
行列/ベクトル計算クラス(テンプレート版)
#define PrintMatrix(a, b)
行列要素表示マクロ(フォーマット指定あり版)
Definition Matrix.hh:35
シャッフルクラス
static Matrix< M, N > GetMiniBatchData(const Matrix< N, D > &U, const size_t i)
i番目のミニバッチデータを取得する関数
Definition BatchProcessor.hh:44
機械学習試験用アヤメデータセットクラス(分類確率ベクトル版)
Definition IrisClassDatasets.hh:41
void GetClassBatchData(const size_t i, Matrix< M, C > &y)
i番目のミニバッチ分類データを取得する関数
Definition IrisClassDatasets.hh:99
IrisClassDatasets()
コンストラクタ
Definition IrisClassDatasets.hh:54
Matrix< C, D > ClassData
前処理済みのアヤメの分類データ
Definition IrisClassDatasets.hh:51
static constexpr size_t C
訓練データチャネル数
Definition IrisClassDatasets.hh:46
static constexpr size_t FinalMinbatNum
最後のミニバッチ番号
Definition IrisClassDatasets.hh:47
static constexpr size_t D
データセット数
Definition IrisClassDatasets.hh:44
void GetMeasuredBatchData(const size_t i, Matrix< M, N > &Y)
i番目のミニバッチ計測データを取得する関数
Definition IrisClassDatasets.hh:91
~IrisClassDatasets()
デストラクタ
Definition IrisClassDatasets.hh:72
Matrix< N, D > MeasuredData
前処理済みのアヤメの計測データ
Definition IrisClassDatasets.hh:50
void DispClassData(void)
分類データを表示する関数
Definition IrisClassDatasets.hh:83
void ShuffleDatasets(void)
データセットをシャッフルする関数
Definition IrisClassDatasets.hh:105
IrisClassDatasets(IrisClassDatasets &&r)
ムーブコンストラクタ
Definition IrisClassDatasets.hh:65
void DispMeasuredData(void)
計測データを表示する関数
Definition IrisClassDatasets.hh:77
static constexpr size_t N
計測データチャネル数
Definition IrisClassDatasets.hh:45
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
constexpr void LoadArray(const std::array< TT, MM > &Array)
1次元std::array配列を縦ベクトルとして読み込む関数
Definition Matrix.hh:424
シャッフルクラス
Definition Shuffle.hh:37
void ShuffleMatrixRow(Matrix< N, M > &U)
行列の行をランダムに入れ替える
Definition Shuffle.hh:62