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

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

?? garff.cpp

?? 一個非常有用的開源代碼
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
/*	Copyright (C) 2006, Mike Gashler	This library is free software; you can redistribute it and/or	modify it under the terms of the GNU Lesser General Public	License as published by the Free Software Foundation; either	version 2.1 of the License, or (at your option) any later version.	see http://www.gnu.org/copyleft/lesser.html*/#include "GArff.h"#include "../GClasses/GArray.h"#include "../GClasses/GMacros.h"#include "../GClasses/GMath.h"#include <math.h>#include "GBits.h"#include "GMatrix.h"GArffRelation::GArffRelation(){	m_szName = NULL;	m_pAttributes = new GPointerArray(32);	m_nInputCount = -1;	m_pInputIndexes = NULL;	m_nOutputCount = -1;	m_pOutputIndexes = NULL;}GArffRelation::~GArffRelation(){	int n;	int nCount;	nCount = m_pAttributes->GetSize();	for(n = 0; n < nCount; n++)		delete((GArffAttribute*)m_pAttributes->GetPointer(n));	delete(m_pAttributes);	delete[] m_szName;	delete[] m_pInputIndexes;	delete[] m_pOutputIndexes;}void GArffRelation::AddAttribute(GArffAttribute* pAttr){	m_pAttributes->AddPointer(pAttr);}GArffRelation* ParseError(int nLine, const char* szProblem){	GAssert(false, szProblem);	return NULL;}int GArffRelation::CountContinuousAttributes(){	int n;	int nAttributes = GetAttributeCount();	int nCount = 0;	for(n = 0; n < nAttributes; n++)	{		GArffAttribute* pAttr = GetAttribute(n);		if(pAttr->IsContinuous())			nCount++;	}	return nCount;}void GArffRelation::SaveArffFile(GArffData* pData, const char* szFilename){	// Open the file for writing	FILE* pFile = fopen(szFilename, "w");	FileHolder hFile(pFile);	if(!pFile)		ThrowError(L"Failed to open file: %s", szFilename);	// Write the relation title	fputs("@RELATION ", pFile);	const char* szName = GetName();	if(!szName)		szName = "Untitled";	fputs(szName, pFile);	fputs("\n\n", pFile);	// Write the attributes	char szTmp[64];	int i, j;	for(i = 0; i < GetAttributeCount(); i++)	{		GArffAttribute* pAttr = GetAttribute(i);		fputs("@ATTRIBUTE ", pFile);		szName = pAttr->GetName();		if(!szName)		{			strcpy(szTmp, "a");			itoa(i, szTmp, 10);			szName = szTmp;		}		fputs(szName, pFile);		fputs("\t", pFile);		if(pAttr->IsContinuous())			fputs("CONTINUOUS", pFile);		else		{			fputs("{", pFile);			for(j = 0; j < pAttr->GetValueCount(); j++)			{				szName = pAttr->GetValue(j);				if(!szName)				{					strcpy(szTmp, "v");					itoa(j, szTmp, 10);					szName = szTmp;				}				fputs(szName, pFile);				fputs(",", pFile);			}			fputs("}", pFile);		}		fputs("\n", pFile);	}	// Write the data	fputs("\n@DATA\n", pFile);	for(i = 0; i < pData->GetSize(); i++)	{		double* pVector = pData->GetVector(i);		for(j = 0; j < GetAttributeCount(); j++)		{			if(j > 0)				fputs(",", pFile);			GArffAttribute* pAttr = GetAttribute(j);			if(pAttr->IsContinuous())			{				GBits::DoubleToString(szTmp, pVector[j]);				fputs(szTmp, pFile);			}			else			{				szName = pAttr->GetValue((int)pVector[j]);				if(!szName)				{					strcpy(szTmp, "v");					itoa(j, szTmp, 10);					szName = szTmp;				}				fputs(szName, pFile);			}		}		fputs("\n", pFile);	}}/*static*/ GArffRelation* GArffRelation::ParseFile(GArffData** ppOutData, const char* szFile, int nLen){	// Parse the relation name	int nPos = 0;	int nLine = 1;	Holder<GArffRelation*> hRelation(new GArffRelation());	GArffRelation* pRelation = hRelation.Get();	while(true)	{		// Skip Whitespace		while(nPos < nLen && szFile[nPos] <= ' ')		{			if(szFile[nPos] == '\n')				nLine++;			nPos++;		}		if(nPos >= nLen)			return ParseError(nLine, "Expected @RELATION");		// Check for comments		if(szFile[nPos] == '%')		{			for(nPos++; szFile[nPos] != '\n' && nPos < nLen; nPos++)			{			}			continue;		}		// Parse Relation		if(nLen - nPos < 9 || strnicmp(&szFile[nPos], "@RELATION", 9) != 0)			return ParseError(nLine, "Expected @RELATION");		nPos += 9;		// Skip Whitespace		while(szFile[nPos] <= ' ' && nPos < nLen)		{			if(szFile[nPos] == '\n')				nLine++;			nPos++;		}		if(nPos >= nLen)			return ParseError(nLine, "Expected relation name");		// Parse Name		int nNameStart = nPos;		while(szFile[nPos] > ' ' && nPos < nLen)			nPos++;		pRelation->m_szName = new char[nPos - nNameStart + 1];		memcpy(pRelation->m_szName, &szFile[nNameStart], nPos - nNameStart);		pRelation->m_szName[nPos - nNameStart] = '\0';		break;	}	// Parse the attribute section	while(true)	{		// Skip Whitespace		while(nPos < nLen && szFile[nPos] <= ' ')		{			if(szFile[nPos] == '\n')				nLine++;			nPos++;		}		if(nPos >= nLen)			return ParseError(nLine, "Expected @ATTRIBUTE or @DATA");		// Check for comments		if(szFile[nPos] == '%')		{			for(nPos++; szFile[nPos] != '\n' && nPos < nLen; nPos++)			{			}			continue;		}		// Check for @DATA		if(nLen - nPos < 5) // 10 = strlen("@DATA")			return ParseError(nLine, "Expected @DATA");		if(strnicmp(&szFile[nPos], "@DATA", 5) == 0)		{			nPos += 5;			break;		}		// Parse @ATTRIBUTE		if(nLen - nPos < 10) // 10 = strlen("@ATTRIBUTE")			return ParseError(nLine, "Expected @ATTRIBUTE");		if(strnicmp(&szFile[nPos], "@ATTRIBUTE", 10) != 0)			return ParseError(nLine, "Expected @ATTRIBUTE or @DATA");		nPos += 10;		GArffAttribute* pAttr = GArffAttribute::Parse(&szFile[nPos], nLen - nPos);		if(!pAttr)			return ParseError(nLine, "Problem with attribute");		pRelation->m_pAttributes->AddPointer(pAttr);		// Move to next line		for(nPos++; szFile[nPos] != '\n' && nPos < nLen; nPos++)		{		}	}	// Parse the data section	Holder<GArffData*> hData(new GArffData(256));	GArffData* pData = hData.Get();	while(true)	{		// Skip Whitespace		while(nPos < nLen && szFile[nPos] <= ' ')		{			if(szFile[nPos] == '\n')				nLine++;			nPos++;		}		if(nPos >= nLen)			break;		// Check for comments		if(szFile[nPos] == '%')		{			for(nPos++; szFile[nPos] != '\n' && nPos < nLen; nPos++)			{			}			continue;		}		// Parse the data line		double* pRow = pRelation->ParseDataRow(&szFile[nPos], nLen - nPos);		if(!pRow)			return ParseError(nLine, "Problem with data line");		pData->AddVector(pRow);		// Move to next line		for(nPos++; szFile[nPos] != '\n' && nPos < nLen; nPos++)		{		}		continue;	}	*ppOutData = hData.Drop();	return hRelation.Drop();}/*static*/ double* GArffRelation::ParseDataRow(const char* szFile, int nLen){	char szBuf[512];	int nAttributeCount = GetAttributeCount();	Holder<double*> hData(new double[nAttributeCount]);	double* pData = hData.Get();	GArffAttribute* pAttr;	int n;	for(n = 0; n < nAttributeCount; n++)	{		// Eat whitespace		while(nLen > 0 && *szFile <= ' ')		{			if(*szFile == '\n')				return NULL;			szFile++;			nLen--;		}		if(nLen < 1)			return NULL;		// Parse the next value		pAttr = GetAttribute(n);		int nPos;		for(nPos = 0; nPos < nLen; nPos++)		{			if(szFile[nPos] == ',')				break;			if(szFile[nPos] == '\n')				break;			if(nPos > 0 && szFile[nPos] > ' ' && szFile[nPos - 1] <= ' ')			{				nPos--;				break;			}		}		int nEnd;		for(nEnd = nPos; nEnd > 0 && szFile[nEnd - 1] <= ' '; nEnd--)		{		}		memcpy(szBuf, szFile, nEnd);		szBuf[nEnd] = '\0';		if(strcmp(szBuf, "?") == 0)			pData[n] = -1;		else if(pAttr->IsContinuous())		{			// Parse a continuous value			if(szBuf[0] == '.' || szBuf[0] == '-' || (szBuf[0] >= '0' && szBuf[0] <= '9'))				pData[n] = atof(szBuf);			else				return NULL;		}		else		{			// Parse an enumerated value			int nVal = pAttr->FindEnumeratedValue(szBuf);			if(nVal < 0)				return NULL;			pData[n] = nVal;		}		// Advance past the attribute		if(nPos < nLen)			nPos++;		while(nPos > 0)		{			szFile++;			nPos--;			nLen--;		}	}	return hData.Drop();}int GArffRelation::GetAttributeCount(){	return m_pAttributes->GetSize();}GArffAttribute* GArffRelation::GetAttribute(int n){	return (GArffAttribute*)m_pAttributes->GetPointer(n);}void GArffRelation::CountInputs(){	m_nInputCount = 0;	m_nOutputCount = 0;	int n;	int nCount = GetAttributeCount();	GArffAttribute* pAttr;	for(n = 0; n < nCount; n++)	{		pAttr = GetAttribute(n);		if(pAttr->IsInput())			m_nInputCount++;		else			m_nOutputCount++;	}	GAssert(m_nInputCount > 0, "no inputs");	//GAssert(m_nOutputCount > 0, "no outputs");	delete[] m_pInputIndexes;	delete[] m_pOutputIndexes;	m_pInputIndexes = new int[m_nInputCount];	m_pOutputIndexes = new int[m_nOutputCount];	int nIn = 0;	int nOut = 0;	for(n = 0; n < nCount; n++)	{		pAttr = GetAttribute(n);		if(pAttr->IsInput())			m_pInputIndexes[nIn++] = n;		else			m_pOutputIndexes[nOut++] = n;	}}int GArffRelation::GetInputCount(){	if(m_nInputCount < 0)		CountInputs();	return m_nInputCount;}int GArffRelation::GetOutputCount(){	if(m_nOutputCount < 0)		CountInputs();	return m_nOutputCount;}int GArffRelation::GetInputIndex(int n){	if(!m_pInputIndexes)		CountInputs();	GAssert(n >= 0 && n < m_nInputCount, "out of range");	return m_pInputIndexes[n];}int GArffRelation::GetOutputIndex(int n){	if(!m_pOutputIndexes)		CountInputs();	GAssert(n >= 0 && n < m_nOutputCount, "out of range");	return m_pOutputIndexes[n];}double GArffRelation::MeasureTotalOutputInfo(GArffData* pData){	double dInfo = 0;	int nOutputs = GetOutputCount();	int n, nIndex;	GArffAttribute* pAttr;	for(n = 0; n < nOutputs; n++)	{		nIndex = GetOutputIndex(n);		pAttr = GetAttribute(nIndex);		if(pAttr->IsContinuous())			dInfo += pData->ComputeVariance(pData->ComputeMean(nIndex), nIndex);		else			dInfo += pData->MeasureEntropy(this, nIndex);	}	return dInfo;}double GArffRelation::ComputeInputDistanceSquared(double* pRow1, double* pRow2){	double dSum = 0;	double d;	int n, nIndex;	for(n = 0; n < m_nInputCount; n++)	{		nIndex = GetInputIndex(n);		if(GetAttribute(nIndex)->IsContinuous())		{			d = pRow2[nIndex] - pRow1[nIndex];			dSum += (d * d);		}		else		{			if(pRow2[nIndex] != pRow1[nIndex])				dSum += 1;		}	}	return dSum;}double GArffRelation::ComputeScaledInputDistanceSquared(double* pRow1, double* pRow2, double* pInputScales){	double dSum = 0;	double d;	int n, nIndex;	for(n = 0; n < m_nInputCount; n++)	{		nIndex = GetInputIndex(n);		if(GetAttribute(nIndex)->IsContinuous())		{			d = pRow2[nIndex] * pInputScales[n] - pRow1[nIndex] * pInputScales[n];			dSum += (d * d);		}		else

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩国产精品大片| 国产亚洲综合在线| 亚洲电影在线播放| 欧美精品18+| 日本不卡一二三区黄网| 精品精品欲导航| 国产激情视频一区二区在线观看| 久久亚洲欧美国产精品乐播| 国产毛片精品视频| 中文av字幕一区| 久久免费看少妇高潮| 国产东北露脸精品视频| 国产精品美女视频| 91蝌蚪porny| 日韩二区三区四区| 国产午夜精品福利| 91国偷自产一区二区开放时间 | 色综合天天综合在线视频| 亚洲精品成人精品456| 91麻豆精品国产91久久久久久久久| 免费观看久久久4p| 国产精品萝li| 欧美精品1区2区3区| 国产99精品国产| 一区二区日韩av| 日韩欧美久久久| 懂色av一区二区三区免费看| 中文字幕在线不卡| 欧美探花视频资源| 免费人成网站在线观看欧美高清| 精品区一区二区| 风间由美一区二区三区在线观看 | 久久精品二区亚洲w码| 欧美高清在线精品一区| 色婷婷综合激情| 日韩激情av在线| 国产精品入口麻豆九色| 欧美色图激情小说| 国内成人免费视频| 亚洲欧美综合网| 欧美日韩国产经典色站一区二区三区 | 色婷婷综合久久久中文字幕| 一区二区三区成人在线视频| 日韩一区二区不卡| 丁香网亚洲国际| 自拍偷自拍亚洲精品播放| 欧美色窝79yyyycom| 国产精品一区二区无线| 亚洲一区中文日韩| 久久日韩粉嫩一区二区三区| 99国产精品视频免费观看| 日韩av高清在线观看| 亚洲国产精品传媒在线观看| 欧美精品色一区二区三区| 91久久国产最好的精华液| 国产精品影视天天线| 亚洲精品国产无套在线观| 欧美国产日产图区| 日韩一区二区三区视频在线| 99精品久久99久久久久| 精品一区二区三区影院在线午夜| 中文字幕字幕中文在线中不卡视频| 7777精品伊人久久久大香线蕉完整版 | 欧美高清视频在线高清观看mv色露露十八| 麻豆精品在线看| 亚洲欧洲99久久| 久久这里都是精品| 91精品国产入口| 欧洲激情一区二区| 成人美女视频在线观看| 久久99久久久久| 天天影视色香欲综合网老头| 亚洲欧美一区二区不卡| 久久久精品2019中文字幕之3| 在线不卡中文字幕播放| 色综合久久综合网欧美综合网| 久久国产精品99久久人人澡| 日日噜噜夜夜狠狠视频欧美人| 亚洲色图视频免费播放| 欧美国产日韩a欧美在线观看| 欧美日韩精品欧美日韩精品| 在线免费亚洲电影| 色综合久久综合中文综合网| av爱爱亚洲一区| 99re热这里只有精品免费视频| 国产成人午夜视频| 国产精品中文欧美| 国产精品一区三区| 国产高清视频一区| 麻豆极品一区二区三区| 亚洲第一激情av| 三级一区在线视频先锋| 亚洲国产日韩a在线播放性色| 亚洲午夜视频在线| 一区二区三区波多野结衣在线观看 | 欧美在线免费观看亚洲| 91美女在线观看| 99在线精品一区二区三区| av电影在线不卡| 一本一道久久a久久精品| 91免费看`日韩一区二区| 久久老女人爱爱| 久久精品人人爽人人爽| 中文字幕成人av| 亚洲婷婷国产精品电影人久久| 一区二区中文字幕在线| 综合欧美亚洲日本| 亚洲国产一区二区三区| 午夜私人影院久久久久| 香蕉成人啪国产精品视频综合网| 日韩高清不卡一区二区三区| 久久99精品久久久| 高清av一区二区| 色天天综合久久久久综合片| 成人精品免费看| 色琪琪一区二区三区亚洲区| 欧美日韩视频在线第一区 | 热久久免费视频| 九九精品一区二区| 成人丝袜高跟foot| 在线亚洲一区观看| 日韩欧美中文一区| 中文字幕亚洲在| 亚洲第一激情av| 国产久卡久卡久卡久卡视频精品| 99久久婷婷国产综合精品电影| 色综合天天做天天爱| 91精品久久久久久蜜臀| 国产午夜精品久久| 午夜欧美在线一二页| 国产麻豆视频精品| 91亚洲精华国产精华精华液| 欧美一区二区免费视频| 日本一区二区三区在线不卡| 亚洲午夜免费福利视频| 国产精品一区二区在线播放| 欧美在线视频你懂得| 2022国产精品视频| 亚洲www啪成人一区二区麻豆| 国产中文字幕精品| 欧美日韩一区高清| 国产欧美日韩亚州综合| 日韩精品亚洲专区| 91视频在线观看免费| 91精品国产乱码久久蜜臀| 亚洲精品国产a久久久久久| 国产在线国偷精品免费看| 欧美午夜影院一区| 国产欧美日韩三区| 免费不卡在线视频| 欧美色老头old∨ideo| 国产精品嫩草影院av蜜臀| 亚洲成人在线免费| 91网站在线播放| 亚洲国产经典视频| 精品在线观看免费| 欧美日本国产视频| 一区二区三区不卡视频| 激情五月婷婷综合网| 欧美不卡一区二区三区四区| 亚洲精品videosex极品| 国产精品1024| 日韩欧美高清一区| 成人av在线影院| 日韩欧美不卡一区| 日韩av中文字幕一区二区| 在线精品视频免费播放| 国产精品国产成人国产三级| 国产一区二三区好的| 8v天堂国产在线一区二区| 国产日韩v精品一区二区| 久久精品国产一区二区三区免费看| 欧美自拍偷拍午夜视频| 中文字幕日韩精品一区| 成人午夜又粗又硬又大| 国产女人18毛片水真多成人如厕 | 日韩美女天天操| 亚洲va在线va天堂| 欧美影院午夜播放| 亚洲在线视频一区| 色久优优欧美色久优优| 亚洲人123区| 日本韩国一区二区三区| 亚洲免费伊人电影| 91传媒视频在线播放| 久久久国产一区二区三区四区小说| 蜜臀av一区二区在线观看| 7777精品伊人久久久大香线蕉| 午夜成人免费视频| 91精品国产综合久久香蕉麻豆 | 亚洲不卡一区二区三区| 欧美日韩一区中文字幕| 三级影片在线观看欧美日韩一区二区| 欧美日韩国产区一| 免费观看日韩av| 久久久久久久久岛国免费| 国产盗摄一区二区| 亚洲欧美综合在线精品| 不卡大黄网站免费看| 一区二区三区影院|