predacc.h

来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C头文件 代码 · 共 124 行

H
124
字号
// --------------------------------------------------------
// This demo file is dedicated to the Public Domain. See:
// http://creativecommons.org/licenses/publicdomain
// --------------------------------------------------------

#ifndef __PREDACC_H__
#define __PREDACC_H__

#include "Gui.h"

class GArffRelation;
class GArffData;
class GSupervisedLearner;
class GPointerArray;
class PredAccController;


class PredAccDialog : public GWidgetDialog
{
protected:
	PredAccController* m_pController;
	GWidgetImageButton* m_pButtonManual;
	GWidgetListBox* m_pAlgorithmList;
	GWidgetListBox* m_pTestTechniqueList;
	GWidgetTextLabel* m_pTextBoxLabel;
	GWidgetTextBox* m_pTextBox;
	GPointerArray* m_pFiles;
	GWidgetTextLabel* m_pTitle;
	GArffRelation* m_pRelation;
	GWidgetGrid* m_pTrainingData;
	GWidgetGrid* m_pTestData;
	GWidgetTextButton* m_pShuffleButton1;
	GWidgetTextButton* m_pShuffleButton2;
	GWidgetFileSystemBrowser* m_pFileSystemBrowser1;
	GWidgetFileSystemBrowser* m_pFileSystemBrowser2;
	GWidgetTextButton* m_pBeginButton;
	int m_nTestTechnique;
	double m_dTrainingPercent;

public:
	PredAccDialog(PredAccController* pController, int w, int h);
	virtual ~PredAccDialog();

	void SetTrainingSet(GArffRelation* pRelation, GArffData* pTrainingSet);
	void SetTestSet(GArffRelation* pRelation, GArffData* pTestSet);
	virtual void OnSelectFilename(GWidgetFileSystemBrowser* pBrowser, const char* szFilename);
	virtual void OnChangeListSelection(GWidgetListBox* pListBox);
	virtual void OnReleaseImageButton(GWidgetImageButton* pButton);
	virtual void OnReleaseTextButton(GWidgetTextButton* pButton);
};








class PredAccView : public ViewBase
{
protected:
	PredAccDialog* m_pDialog;

public:
	PredAccView(PredAccController* pController);
	virtual ~PredAccView();

	virtual void OnChar(char c);
	virtual void OnMouseDown(int nButton, int x, int y);
	virtual void OnMouseUp(int nButton, int x, int y);
	virtual bool OnMousePos(int x, int y);

	void SetTrainingSet(GArffRelation* pRelation, GArffData* pTrainingSet);
	void SetTestSet(GArffRelation* pRelation, GArffData* pTestSet);

protected:
	virtual void Draw(SDL_Surface *pScreen);
};












class PredAccController : public ControllerBase
{
protected:
	PredAccView* m_pPredAccView;
	GArffRelation* m_pRelation;
	GArffData* m_pTrainingSet;
	GArffData* m_pTestSet;
	GSupervisedLearner* m_pLearner;

public:
	PredAccController();
	virtual ~PredAccController();

	void RunModal();
	void HandleKeyPress(SDLKey eKey, SDLMod mod);
	void HandleMouseClick();
	void LoadTrainingSet(const char* szFilename);
	void LoadTestSet(const char* szFilename);
	void LoadAndSplitTrainingSet(const char* szFilename, double dTestPercent);
	void ShuffleTrainingSet();
	void ShuffleTestSet();
	void TrainAndTestSingleSet(int nAlgorithm);
	void TrainAndTest(int nAlgorithm);
	void DoNFoldCrossValidation(int nAlgorithm, int nParts);
	void Train(int nAlgorithm, GArffRelation* pRelation, GArffData* pTrainingSet);
	void Test(int nAlgorithm, GArffData* pTestSet);

protected:
	GSupervisedLearner* MakeLearner(int nAlgorithm, GArffRelation* pRelation);
};

#endif // __PREDACC_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?