メインコンテンツ

view

説明

view(tree) は、分類木モデル tree のテキスト説明を返します。

view(tree,Mode=mode) は、表示モードを指定します。"graph" または "text" のいずれかです。

すべて折りたたむ

学習済み分類木をテキストおよびグラフィックスで表示します。

フィッシャーのアヤメのデータ セットを読み込みます。

load fisheriris

すべての測定値を使用して分類木に学習させます。

Mdl = fitctree(meas,species);

学習済み分類木をテキストで表示します。

view(Mdl)
Decision tree for classification
1  if x3<2.45 then node 2 elseif x3>=2.45 then node 3 else setosa
2  class = setosa
3  if x4<1.75 then node 4 elseif x4>=1.75 then node 5 else versicolor
4  if x3<4.95 then node 6 elseif x3>=4.95 then node 7 else versicolor
5  class = virginica
6  if x4<1.65 then node 8 elseif x4>=1.65 then node 9 else versicolor
7  class = virginica
8  class = versicolor
9  class = virginica

学習済み分類木をグラフィックスで表示します。

view(Mdl,Mode="graph");

Figure Classification tree viewer contains an axes object and other objects of type uimenu, uicontrol. The axes object contains 18 objects of type line, text. One or more of the lines displays its values using only markers

フィッシャーのアヤメのデータ セットを読み込みます。

load fisheriris

すべての測定値を使用して 100 本の分類木の bag を成長させます。

rng(1) % For reproducibility
Mdl = TreeBagger(100,meas,species);

または、fitcensembleを使用して分類木の bag を成長させることもできます。

MdlTreeBaggerモデル オブジェクトです。Mdl.Trees は、100 本の学習済み分類木の bag を 100 行 1 列の cell 配列に格納します。つまり、Mdl.Trees の各セルに CompactClassificationTree モデル オブジェクトが格納されます。

bag 内の 10 番目の分類木のグラフを表示します。

Tree10 = Mdl.Trees{10};
view(Tree10,Mode="graph");

Figure Classification tree viewer contains an axes object and other objects of type uimenu, uicontrol. The axes object contains 27 objects of type line, text. One or more of the lines displays its values using only markers

既定の設定では、bag of trees に対して木を深く成長させます。

フィッシャーのアヤメのデータ セットを読み込みます。

load fisheriris

すべての測定値を使用して 100 本の分類木のアンサンブルをブースティングします。弱学習器として木の切り株を指定します。

t = templateTree('MaxNumSplits',1);
Mdl = fitcensemble(meas,species,'Method','AdaBoostM2','Learners',t);

MdlClassificationEnsembleモデル オブジェクトです。Mdl.Trained は、100 本の学習済み分類木のアンサンブルを 100 行 1 列の cell 配列に格納します。つまり、Mdl.Trained の各セルに CompactClassificationTree モデル オブジェクトが格納されます。

アンサンブル内の 10 番目の分類木のグラフを表示します。

Tree10 = Mdl.Trained{10};
view(Tree10,'Mode','graph');

Figure Classification tree viewer contains an axes object and other objects of type uimenu, uicontrol. The axes object contains 9 objects of type line, text. One or more of the lines displays its values using only markers

アンサンブルの弱学習器として切り株を指定したため、グラフは木の切り株を示します。ただし、この動作は fitcensemble の既定の設定ではありません。既定の設定では、fitcensemble は木のブースティング アンサンブルに対して浅い木を成長させます。つまり、'Learners'templateTree('MaxNumSplits',10) になります。

入力引数

すべて折りたたむ

学習済みの分類木。fitctree で学習させた ClassificationTree モデル オブジェクト、または compact で作成した CompactClassificationTree モデル オブジェクトとして指定します。

tree の表示。"text" または "graph" として指定します。"text" の場合、tree について記述する出力がコマンド ウィンドウに表示されます。"graph" の場合、tree を表示するユーザー インターフェイスが開きます。これには、木を照会するためのコントロールが含まれています。

データ型: char | string

ヒント

木のアンサンブルの木 t を表示するには、次のコードのいずれかを入力します。

view(Ens.Trained{t})
view(Bag.Trees{t})

  • Ens は、fitcensemble によって返された完全なアンサンブルまたは compact によって返されたコンパクトなアンサンブルです。

  • Bag は、TreeBagger によって返された完全な bag of trees または compact によって返されたコンパクトな bag of trees です。

コマンド ウィンドウで tree を保存するには、関数 findall および setdiff を使用して Figure のハンドルを取得し、関数 saveas を使用して tree を保存します。

before = findall(groot,Type="figure"); % Find all figures
view(Mdl,Mode="graph")
after = findall(groot,Type="figure");
h = setdiff(after,before); % Get the figure handle of the tree viewer
saveas(h,"a.png")

拡張機能

すべて展開する

バージョン履歴

R2011a で導入