亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? naivebayesclassifier.cpp

?? 粗慥集成算法集合 ,并有詳細的文檔資料和測試數據處
?? CPP
字號:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================

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

#include <kernel/algorithms/naivebayesclassifier.h>
#include <kernel/algorithms/keyword.h>

#include <kernel/structures/informationvector.h>
#include <kernel/structures/classification.h>
#include <kernel/structures/decisiontable.h>
#include <kernel/structures/dictionary.h>
#include <kernel/structures/rules.h>

#include <kernel/utilities/creator.h>

//-------------------------------------------------------------------
// Methods for class NaiveBayesClassifier.
//===================================================================

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

NaiveBayesClassifier::NaiveBayesClassifier() {
	decision_attribute_ = Undefined::Integer();
}

NaiveBayesClassifier::~NaiveBayesClassifier() {
}

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

IMPLEMENTIDMETHODS(NaiveBayesClassifier, NAIVEBAYESCLASSIFIER, Classifier)

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

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

String
NaiveBayesClassifier::GetParameters() const {

	String parameters;

	parameters += Keyword::DecisionTable();
	parameters += Keyword::Assignment();

	if (GetDecisionTable() != NULL)
		parameters += GetDecisionTable()->GetName();
	else
		parameters += "NULL";

	return parameters;

}

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

bool
NaiveBayesClassifier::SetParameter(const String &keyword, const String &/*value*/) {

	// The master table cannot currently be set this way.
	if (keyword == Keyword::DecisionTable())
		return false;

	// Unknown keyword or illegal value.
	return false;

}

//-------------------------------------------------------------------
// Method........: Apply
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Assumes that library clients use handles.
// Revisions.....:
//===================================================================

Structure *
NaiveBayesClassifier::Apply(Structure &structure) const {

	// Check input type.
	if (!IsApplicable(structure))
		return NULL;

	// Cast to verified type.
	Handle<InformationVector> inf = dynamic_cast(InformationVector *, &structure);

	int i, no_attributes = inf->GetNoAttributes();

	// Briefly verify compatibility.
	if (no_attributes != conditionals_.size())
		return NULL;

	if (decision_attribute_ < 0 || decision_attribute_ >= no_attributes)
		return NULL;

	// Create result structure.
	Handle<Classification> classification = Creator::Classification();

	PPMap::const_iterator it1;
	CPMap::const_iterator it2;

	// Consider each possible decision value in turn.
	for (it1 = priors_.begin(); it1 != priors_.end(); it1++) {

		int    decision    = (*it1).first;
		double probability = (*it1).second;

		// Compute product of conditional probabilities.
		for (i = 0; i < no_attributes; i++) {

			// Only consider condition attributes.
			if (i == decision_attribute_)
				continue;

			int condition = inf->GetEntry(i);

			// Skip missing values.
			if (condition == Undefined::Integer())
				continue;

			IIPair iipair(condition, decision);

			// Lookup conditional probability.
			it2 = conditionals_[i].find(iipair);

			if (it2 == conditionals_[i].end()) {
				probability = 0.0;
				break;
			}

			probability *= (*it2).second;

		}

		if (probability != 0.0)
			classification->AppendDecisionValue(decision, probability);

	}

	if (classification->GetNoDecisionValues() > 0) {
		classification->SetDecisionAttribute(decision_attribute_);
		classification->Normalize();
		classification->Sort();
		return classification.Release();
	}

	return NULL;

}

//-------------------------------------------------------------------
// Methods inherited from Classifier.
//===================================================================

//-------------------------------------------------------------------
// Method........: IsCompatible
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Is this classifier compatible with information vectors
//                 extracted from the given decision table?
// Comments......:
// Revisions.....:
//===================================================================

bool
NaiveBayesClassifier::IsCompatible(const DecisionTable &table, bool masked) const {

	// Check compatibility between tables.
	if (GetDecisionTable() == NULL) {
		Message::Error("No master decision table set.", false);
		return false;
	}

	if (GetDecisionTable().GetPointer() == &table)
		return true;

	if (GetDecisionTable()->GetNoAttributes(masked) != table.GetNoAttributes(masked)) {
		Message::Error("Mismatch in decision table dimensions.", false);
		return false;
	}

	// May the coding schemes be different?
	if (!table.HasDictionary() && !GetDecisionTable()->HasDictionary()) {       // None of the tables have associated dictionaries.
		return true;
	}
	else if ((table.HasDictionary() && !GetDecisionTable()->HasDictionary()) ||	// Only one table has an associated dictionary.
		       (!table.HasDictionary() && GetDecisionTable()->HasDictionary())) {
		Message::Warning("The coding schemes used by the decision tables may be different!", false);
		return true;
	}
	else {                                                                      // Both tables have associated dictionaries.
		Handle<Dictionary> dict1 = table.GetDictionary();
		Handle<Dictionary> dict2 = GetDecisionTable()->GetDictionary();
		if (!(dict1->IsCompatible(*dict2))) {
			Message::Warning("Possibly different coding schemes in use by decision tables.", false);
			return true;
		}
	}

	return true;

}

//-------------------------------------------------------------------
// Method........: Initialize
// Author........: Aleksander 豩rn
// Date..........:
// Description...: Computes probabilities.
//
// Comments......: The table given as an argument is the table of
//                 objects to be classified, not the table to
//                 compute probabilities from.
// Revisions.....:
//===================================================================

bool
NaiveBayesClassifier::Initialize(const DecisionTable &/*table*/, bool masked) {

	int i, j;

	// Clear probability data structures.
	conditionals_.erase(conditionals_.begin(), conditionals_.end());
	priors_.erase(priors_.begin(), priors_.end());

	Handle<DecisionTable> master = GetDecisionTable();

	// Is a table to compute probabilities from provided?
	if (master == NULL) {
		Message::Error("No master decision table set.", false);
		return false;
	}

	// Get index of decision attribute.
	decision_attribute_ = master->GetDecisionAttribute(masked);

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

	int no_objects    = master->GetNoObjects(masked);
	int no_attributes = master->GetNoAttributes(masked);

	// Compute prior counts.
	for (i = 0; i < no_objects; i++) {
		int decision = master->GetEntry(i, decision_attribute_, masked);
		priors_.insert(Pair(const int, double)(decision, 0.0));
		priors_[decision] += 1.0;
	}

	conditionals_.reserve(no_attributes);

	// Compute conditional counts and normalize them.
	for (j = 0; j < no_attributes; j++) {

		conditionals_.push_back(CPMap());

		// Only consider condition attributes.
		if (j == decision_attribute_)
			continue;

		for (i = 0; i < no_objects; i++) {
			int condition = master->GetEntry(i, j, masked);
			int decision  = master->GetEntry(i, decision_attribute_, masked);
			IIPair iipair(condition, decision);
			conditionals_[j].insert(Pair(const IIPair, double)(iipair, 0.0));
			conditionals_[j][iipair] += 1.0;
		}

		CPMap::iterator it1;

		for (it1 = conditionals_[j].begin(); it1 != conditionals_[j].end(); it1++) {
			(*it1).second /= priors_[(*it1).first.second];
		}

	}

	PPMap::iterator it2;

	// Normalize prior counts.
	for (it2 = priors_.begin(); it2 != priors_.end(); it2++) {
		(*it2).second /= no_objects;
	}

	return true;

}

//-------------------------------------------------------------------
// Method........: SetRules
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Comments......: Overloading this method does not make much sense
//                 since this is not a rule-based classifier, but
//                 this hack should enable this classifier to be used in
//                 the specialized command script language.
// Revisions.....:
//===================================================================

bool
NaiveBayesClassifier::SetRules(const Rules *rules) {

	// This ensures that this object does not keep the table unnecessarily alive.
	// Side effect: GetParameters cannot return the table name.
	if (rules == NULL)
		return SetDecisionTable(NULL);

	// Backtrack to the decision table the rules were derived from.
	Handle<DecisionTable> table = dynamic_cast(DecisionTable *, rules->FindParent(DECISIONTABLE));

	return SetDecisionTable(table);

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧亚洲嫩模精品一区三区| 国产一区二区美女| 亚洲精品成人a在线观看| 国产精品全国免费观看高清| 久久无码av三级| 精品国产乱码久久久久久久| k8久久久一区二区三区| 日韩色在线观看| 国产精品久久久久久久久快鸭| 亚洲福利一二三区| 国产一区二区中文字幕| 国产精一品亚洲二区在线视频| 3atv一区二区三区| 亚洲国产你懂的| 色婷婷精品大在线视频 | 日韩av一区二区在线影视| 91视视频在线直接观看在线看网页在线看| 日韩欧美国产麻豆| 青青草原综合久久大伊人精品| 欧美色欧美亚洲另类二区| 亚洲日韩欧美一区二区在线| 成人夜色视频网站在线观看| 国产欧美精品日韩区二区麻豆天美| 日本成人在线电影网| 欧美日韩在线播| 午夜精品福利在线| 欧美美女bb生活片| 五月婷婷综合在线| 4438亚洲最大| 久久97超碰色| 久久久久久9999| 成人午夜在线免费| 中日韩免费视频中文字幕| 国产精品一区二区三区99| 久久综合久久综合亚洲| 国产九色sp调教91| 中文在线一区二区| 97超碰欧美中文字幕| 亚洲人成7777| 91久久国产最好的精华液| 亚洲精品成人少妇| 欧美精品 日韩| 蜜臀a∨国产成人精品| 欧美第一区第二区| 国产成人亚洲综合a∨婷婷图片 | 极品销魂美女一区二区三区| 日韩一区国产二区欧美三区| 麻豆国产精品一区二区三区| www国产成人| 北条麻妃一区二区三区| 亚洲一区二区三区自拍| 欧美丰满嫩嫩电影| 国产精品中文欧美| 久久国内精品自在自线400部| 久久久五月婷婷| 99久久精品国产一区二区三区 | 久久精品人人做人人综合| 成人激情小说乱人伦| 亚洲一卡二卡三卡四卡| 欧美一激情一区二区三区| 国产成人福利片| 一区二区三区精品视频在线| 日韩一级完整毛片| 成人少妇影院yyyy| 日本伊人午夜精品| 亚洲色图欧美偷拍| 欧美变态tickle挠乳网站| av在线一区二区三区| 日韩1区2区3区| 中文字幕五月欧美| 欧美日韩成人在线一区| 国产 日韩 欧美大片| 午夜日韩在线电影| 亚洲国产精品传媒在线观看| 在线不卡a资源高清| 丁香亚洲综合激情啪啪综合| 亚洲成a人片综合在线| 欧美国产精品一区二区三区| 欧美日韩精品福利| 一本色道亚洲精品aⅴ| 精品无人区卡一卡二卡三乱码免费卡| 美女精品一区二区| 亚洲卡通欧美制服中文| 久久久精品tv| 欧美一级片在线看| 91美女视频网站| 国产福利一区在线| 国内成+人亚洲+欧美+综合在线 | 国产毛片一区二区| 亚洲二区在线视频| 国产精品三级久久久久三级| 亚洲精品在线免费播放| 欧美精品丝袜中出| 91福利精品第一导航| 波多野结衣一区二区三区| 韩国一区二区在线观看| 亚洲第一精品在线| 伊人一区二区三区| **性色生活片久久毛片| 国产三区在线成人av| 欧美大胆一级视频| 91精品国产综合久久福利软件| 91九色02白丝porn| 93久久精品日日躁夜夜躁欧美| 成人一道本在线| 成人午夜视频福利| 国产乱码一区二区三区| 蜜桃视频一区二区三区在线观看| 日韩精品每日更新| 欧美96一区二区免费视频| 日韩国产欧美在线视频| 人人狠狠综合久久亚洲| 美女一区二区在线观看| 久久国产精品72免费观看| 久久91精品国产91久久小草| 精品亚洲国产成人av制服丝袜| 美女网站色91| 国产一区二区三区香蕉| 国产成人免费视频网站高清观看视频| 韩国一区二区在线观看| 粉嫩av一区二区三区粉嫩| 不卡在线观看av| 91丨九色丨黑人外教| 欧美最猛黑人xxxxx猛交| 欧美色综合影院| 日韩欧美激情在线| 26uuu国产电影一区二区| 国产欧美一区二区在线| 亚洲欧美怡红院| 天堂在线一区二区| 精品一区二区三区在线观看| 国产91精品一区二区| 色视频欧美一区二区三区| 欧美在线小视频| 日韩一级二级三级| 欧美韩国日本一区| 亚洲高清免费在线| 激情图区综合网| 一本一道久久a久久精品综合蜜臀| 在线观看欧美黄色| 日韩欧美亚洲国产另类| 国产女同性恋一区二区| 亚洲在线观看免费| 国内精品国产三级国产a久久| 91玉足脚交白嫩脚丫在线播放| 欧美久久久久久久久久| 久久久久久久电影| 亚洲一区二区三区在线看| 久久99久久久久久久久久久| av亚洲精华国产精华精| 制服视频三区第一页精品| 2023国产一二三区日本精品2022| 亚洲精品菠萝久久久久久久| 久久成人免费电影| 91丨九色丨尤物| www日韩大片| 亚洲国产欧美日韩另类综合| 国产成人综合自拍| 制服视频三区第一页精品| 中文字幕一区二区三区四区 | 盗摄精品av一区二区三区| 欧美亚洲动漫制服丝袜| xnxx国产精品| 日韩成人精品视频| 99re这里只有精品首页| 欧美精品一区二区三区蜜桃视频| 亚洲人成7777| 成人免费毛片a| 日韩免费观看高清完整版| 亚洲一区二区三区国产| 成人激情电影免费在线观看| 日韩欧美亚洲国产另类| 五月激情综合网| 色天天综合色天天久久| 国产精品成人在线观看| 国产精品一区二区久久精品爱涩| 欧美精品在线观看播放| 亚洲最色的网站| jizz一区二区| 国产精品护士白丝一区av| 国产在线播放一区二区三区| 91精品国产综合久久久蜜臀粉嫩| 一区二区三区久久| 99久久久无码国产精品| 欧美激情一区二区三区全黄| 老司机免费视频一区二区| 在线播放中文一区| 天天色天天操综合| 欧美美女黄视频| 日韩黄色片在线观看| 精品视频1区2区| 亚洲国产日韩精品| 欧美猛男超大videosgay| 亚洲高清免费观看高清完整版在线观看| 99精品久久久久久| 亚洲欧洲制服丝袜| 色域天天综合网| 亚洲一区精品在线| 欧洲生活片亚洲生活在线观看| 一区二区激情小说|