MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_01D0291E.76C42C70" このドキュメントは単一ファイル Web ページ (Web アーカイブ ファイル) です。お使いのブラウザー、またはエディターは Web アーカイブ ファイルをサポートしていません。Windows? Internet Explorer? など、Web アーカイブをサポートするブラウザーをダウンロードしてください。 ------=_NextPart_01D0291E.76C42C70 Content-Location: file:///C:/B1341C78/db8.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="shift_jis"
データベース特論資料 8 (Advanced Database Exercise =
8)
2014年12月8日
概要 Abstract
今日の授業では、オブジェクト指向データベース管理システムZODB
のデータを使い、簡単なデータ解析の=
縁Kを行う
Tod=
ay's
class is exercise on data analysis using an object-oriented database manage=
ment
system 'ZODB'.
■
分類 (classification=
)
特徴空間中のベクトル集合 (a set of vector=
s in a
feature space) : {x1, x2, …, xn}
分類ラベル集合 (a set of
classification labels): {y1, y2, …, yn}
但し yi in {y1, y2, =
…,ym}
が与えられたとする. この授業で= ヘ、特徴空間中のベクトル集合と、分類ラベル集合とから、特徴空間中のベクトルを= 分類ラベルにマップする識別機 (classifier) を生成することを、分類 (classification) という。
In this class, "classification= " is to generate a classifier that maps a feature vector onto a classification label, and the classifier is genereted from a set of vectors in a feature s= pace and a set of classification labels)
例えば、iris データセッ= g(全部で150行)の0行目から148行目までの= fータを使い識別機を生成したとする。この識別機は、iris データセットの149行目のデー= ^にある特徴ベクトル「(5.9, 3, 5.1, 1.8)」を、分類ラベル "virginica" にマップできる識別機であることが期待できる。
図.= iris データセットの 0 行目から 148 行目までのデータ
■ 訓練データ (training data)
分類を行うための特徴空間中のベクトル集合と、分類ラベル集合のこ= とを訓練データ (training data)、訓練例 (training set) という。
■ 教師なしの分類
この授業では、特徴空間中のベクトル集合だけを使う(分類ラベル集= 合を使わない)ことで分類を行うことを教師なしの分類という。
分類: 特徴空間中のベクトル集合、分類ラベル集合を使う
教師なしの分類: 特徴空間中のベクトル集合だけを使う
■ <=
/span>ステップ1
(Step 1)
課題:以下の手順で Spyderの設定を行いなさい =
(Setup the Spyder software)
1.&n=
bsp;
Spyder の起動
(execute the Spyder)
&=
nbsp; &nbs=
p; &=
nbsp; &nbs=
p;
2.&n=
bsp;
Interpreters で =
span>「Open an IPython Console<=
/b>」を選ぶ. (Select Interpreters, and Select =
gOpen
an IPython console”)
3.&n=
bsp;
「IPy=
thon
console」をクリック. (Click “IPython console”)
■ <=
/span>ステップ2
(Step 2)
課題:以下の手順で ZODB データベースに接続しなさい=
u> (Connect to a ZODB
database)
◆
今日の授業では、ZOD=
B データベースファイル名は =
span>hoge7.fs
(The
ZODB database file name in the previous class was 'hoge7.fs'.
Let us use it again here)
2. IPython コンソールで、ZODBデータベースに接続し、変数= b>root にZOD= Bのルートオ= uジェクトを格納する
(connect to a ZODB database using I=
Python
console, and store the root object into the variable named root)
3.
iris_data の確認 Pr=
int
iris_data
■ <=
/span>ステップ
5 (Step 5)
■ <=
/span>ステップ3
(Step 3)
データフレームからの行の選択と列の選択)
1. =
loc を用いた行の選択.
0行目から10<=
/span>行目を選ぶ.
Select lines from 0 to 10 usi=
ng loc
2. =
列を選ぶ.
Select Columns.
(1)=
列
sepal_length, sepal_widthを選ぶ
(2)=
列
species を選ぶ
(3)=
今度は149
行目を選ぶ. S=
elect
line 149 using loc.
■ <=
/span>ステップ4
(Step 4)
分類する.この授業では=
b> Linear SVM =
を用いる.Linear SVM の詳細はこの授業では触れない。
Do
classification using SVM
1.
分類する。分類機は変数 classifier に格納される.
An classifier is stored into variable named 'classifier'
import sklear=
n
import sklear=
n.svm
C =3D 1.0
d =3D
root['iris_data']
X =3D d.loc[0=
:148,
['sepal_length', 'sepal_width', 'petal_length', 'petal_width']]
Y =3D d.loc[0=
:148,
['species']]
classifier =
=3D sklearn.svm.SVC(kernel=3D'linear',
C=3DC).fit(X, Y)
2.
分類機を使ってみる.Use the classifier
The
data is mapped onto 'virginica'.
■ <=
/span>ステップ5
(Step 5)
教師なしで分類する.この授業では k-Meansを用いる.k-Meansの詳細はこの授業では触れない。
Do
classification using k-Means
1. =
教師なしで分類する。分類機は変数 estimator に格納される. An
classifier is stored into variable named 'classifier'
2. =
分類機を見てみる
演習シート 8 (Exercises Sh=
eet
8) 2014/12/08
氏名 専攻 = 学生番号
Name = &nb= sp; Department &= nbsp; &nbs= p; Student number =
記入して提出しなさい Fill out and submit
Q1<= span style=3D'mso-spacerun:yes'> ステップ1は終わった= ゥ 終わっていないか? Did you finish = the step 1 ?
□ はい Yes = □ いいえ No
Q2<= span style=3D'mso-spacerun:yes'> ステップ2は終わった= ゥ 終わっていないか? Did you finish = the step 2 ?
□ はい Yes = □ いいえ No
Q3<= span style=3D'mso-spacerun:yes'> ステップ3は終わった= ゥ 終わっていないか? Did you finish = the step 3 ?
□ はい Yes = □ いいえ No
Q4<= span style=3D'mso-spacerun:yes'> ステップ4は終わった= ゥ 終わっていないか? Did you finish = the step 4 ?
□ はい Yes = □ いいえ No
Q5<= span style=3D'mso-spacerun:yes'> ステップ5は終わった= ゥ 終わっていないか? Did you finish = the step 5 ?
□ はい Yes = □ いいえ No