⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 batchclassifier.cpp

📁 粗糙集应用软件
💻 CPP
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........: 960619
// Description...:
// Revisions.....:
//===================================================================

#include <stdafx.h> // Precompiled headers.
#include <copyright.h>

#include <kernel/algorithms/batchclassifier.h>
#include <kernel/algorithms/classifier.h>
#include <kernel/algorithms/keyword.h>

#include <kernel/structures/structure.h>
#include <kernel/structures/decisiontable.h>
#include <kernel/structures/informationvector.h>
#include <kernel/structures/classification.h>
#include <kernel/structures/batchclassification.h>
#include <kernel/structures/roccurve.h>
#include <kernel/structures/calibrationcurve.h>
#include <kernel/structures/dictionary.h>
#include <kernel/structures/attribute.h>

#include <kernel/basic/vector.h>
#include <kernel/basic/algorithm.h>
#include <kernel/basic/message.h>

#include <kernel/utilities/creator.h>
#include <kernel/utilities/mathkit.h>
#include <kernel/utilities/iokit.h>

#include <kernel/system/fstream.h>

#include <common/objectmanager.h>

//-------------------------------------------------------------------
// Static variables (file scope).
//===================================================================

static Handle<Classification> static_fallback_classification_ = NULL;

//-------------------------------------------------------------------
// Static methods (file scope).
//===================================================================

//-------------------------------------------------------------------
// Method........: StaticInitializeFallbackClassification etc.
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....:
//===================================================================

static bool
StaticInitializeFallbackClassification(const BatchClassifier &batchclassifier, const DecisionTable &table, bool masked) {

	// Instantiate if needed.
	if (static_fallback_classification_ == NULL)
		static_fallback_classification_ = Creator::Classification();

	// Clear everything.
	static_fallback_classification_->Clear();

	// Get decision attribute.
	int decision_attribute = table.GetDecisionAttribute(masked);

	if (decision_attribute == Undefined::Integer())
		return false;

	// Set classification decision attribute.
	static_fallback_classification_->SetDecisionAttribute(decision_attribute);

	// Determine fallback class.
	int fallback = table.GetDictionaryEntry(decision_attribute, batchclassifier.GetFallbackClass(), masked);

	if (fallback == Undefined::Integer() && batchclassifier.GetFallbackClass().IsInteger())
		fallback = batchclassifier.GetFallbackClass().GetInteger();

	// Determine fallback certainty.
	float certainty = batchclassifier.GetFallbackCertainty();

	// Fill fallback classification structure.
	static_fallback_classification_->InsertDecisionValue(fallback, certainty, 0);

	return true;

}

static Handle<Classification>
StaticGetFallbackClassification() {
	return static_fallback_classification_;
}

static void
StaticSetFallbackClassification(Handle<Classification> classification) {
	static_fallback_classification_ = classification;
}

static int
StaticGetDecisionClass(const String &name, const DecisionTable &table, bool masked) {

	if (name == Undefined::String())
		return Undefined::Integer();

	// Get decision attribute index.
	int decision_attribute = table.GetDecisionAttribute(masked);

	if (decision_attribute == Undefined::Integer())
		return Undefined::Integer();

	// Determine decision class.
	int decision_class = table.GetDictionaryEntry(decision_attribute, name, masked);

	if (decision_class == Undefined::Integer() && name.IsInteger())
		decision_class = name.GetInteger();

	return decision_class;

}

//-------------------------------------------------------------------
// Methods for class BatchClassifier.
//===================================================================

//-------------------------------------------------------------------
// Constructors/destructor.
//===================================================================

BatchClassifier::BatchClassifier() {

	AssignFallback(false);
	SetFallbackClass(Undefined::String());
	SetFallbackCertainty(1.0);

	SetMultipleStrategy(MULTIPLE_BEST);
	SetPriorityClass(Undefined::String());
	SetPriorityThreshold(0.0);

	LogDetails(false);
	SetLogFilename(Undefined::String());
	VerboseLog(true);

	GenerateROC(false);
	SetROCClass(Undefined::String());
	SetROCFilename(Undefined::String());

	ReturnROCDetails(false);

	GenerateCalibration(false);
	SetCalibrationClass(Undefined::String());
	SetCalibrationFilename(Undefined::String());
	SetNoCalibrationGroups(10);

}

BatchClassifier::~BatchClassifier() {
}

//-------------------------------------------------------------------
// Methods inherited from Identifier.
//===================================================================

IMPLEMENTIDMETHODS(BatchClassifier, BATCHCLASSIFIER, Algorithm)

//-------------------------------------------------------------------
// Methods inherited from Algorithm.
//===================================================================

//-------------------------------------------------------------------
// Method........: GetParameters
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......:
// Revisions.....: A

⌨️ 快捷键说明

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