BayesNetworkDialog.ui.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <qlabel.h>
00014 #include <qtable.h>
00015 #include "Util/log.H"
00016
00017 void BayesNetworkDialog::init( Bayes &bayesNet )
00018 {
00019 itsBayesNet = &bayesNet;
00020 setupTab();
00021
00022
00023 itsBayesNet->import("fv.txt");
00024
00025 }
00026
00027
00028 void BayesNetworkDialog::update()
00029 {
00030
00031 }
00032
00033
00034 void BayesNetworkDialog::setupTab()
00035 {
00036 static bool setupTab = true;
00037
00038 if (setupTab)
00039 {
00040
00041 QWidget *page = tabWidget->page(0);
00042 tabWidget->removePage(page);
00043
00044
00045 QWidget* statTab = new QWidget(tabWidget);
00046 QVBoxLayout* tabLayout = new QVBoxLayout(statTab, 11, 6);
00047 for (uint i=0; i<itsBayesNet->getNumClasses(); i++)
00048 {
00049 QString stat = QString("Class %1: freq %L2 Prior %L3")
00050 .arg(i)
00051 .arg(itsBayesNet->getClassFreq(i))
00052 .arg(itsBayesNet->getClassProb(i));
00053
00054 QLabel *label = new QLabel(stat, statTab, QString("stat Label %1").arg(i));
00055 label->setFont(QFont("Times", 20));
00056 tabLayout->addWidget(label);
00057 }
00058 tabWidget->insertTab(statTab,QString("Stats"));
00059
00060
00061
00062 QWidget *changeParamTab = new QWidget(tabWidget);
00063 QVBoxLayout* classLayout = new QVBoxLayout(changeParamTab, 11, 6);
00064
00065 for(uint cls=0; cls<itsBayesNet->getNumClasses(); cls++)
00066 {
00067 QString className = QString("%1:%L2").arg(cls).arg(itsBayesNet->getClassName(cls));
00068 QLabel *label = new QLabel(className, changeParamTab, className);
00069
00070 classLayout->addWidget(label);
00071
00072 QTable *paramTable = new QTable(changeParamTab, "paramTable");
00073 paramTable->setNumRows(2);
00074 paramTable->setNumCols(itsBayesNet->getNumFeatures());
00075
00076
00077 for(uint fv=0; fv<itsBayesNet->getNumFeatures(); fv++)
00078 {
00079 paramTable->setText(0, fv, QString("%L1").arg(itsBayesNet->getMean(cls, fv)));
00080 paramTable->setText(1, fv, QString("%L1").arg(itsBayesNet->getStdevSq(cls, fv)));
00081 }
00082
00083 classLayout->addWidget(paramTable);
00084 }
00085
00086 tabWidget->insertTab(changeParamTab,QString("Param Change"));
00087
00088
00089 #ifdef INVT_HAVE_QWT
00090
00091
00092 QStringList colorNames = QColor::colorNames();
00093
00094
00095 for (uint i=0; i<itsBayesNet->getNumFeatures(); i++)
00096 {
00097 QWidget* tab = new QWidget(tabWidget);
00098 QHBoxLayout* tabLayout = new QHBoxLayout(tab, 11, 6);
00099
00100 QString title(itsBayesNet->getFeatureName(i));
00101 QwtPlot *qwtPlot = new QwtPlot(title, tab);
00102
00103 qwtPlot->setAutoReplot(true);
00104 for (uint cls=0; cls<itsBayesNet->getNumClasses(); cls++)
00105 {
00106 LFATAL("FIXME: I need to be updated to latest qwt");
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 }
00128 tabLayout->addWidget(qwtPlot);
00129 tabWidget->insertTab(tab,QString("Normal Dist %1").arg(i) );
00130
00131 setupTab = false;
00132 qwtPlot->replot();
00133 qwtPlot->show();
00134 }
00135
00136 #else
00137 printf("Need the qwtPlot widget for graphs!!!\n");
00138 #endif
00139 }
00140 }