📄 gnaiveinstance.h
字号:
/*
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
*/
#ifndef __GNAIVEINSTANCE_H__
#define __GNAIVEINSTANCE_H__
#include "GLearner.h"
class GNaiveInstanceAttr;
// This is a cross between a KNN instance learner and a Naive Bayes learner.
// It's not yet well tested, but in theory it should be able to regress with
// precision like KNN, but be tolerant to the curse of dimensionality like
// Naive Bayes.
class GNaiveInstance : public GSupervisedLearner
{
protected:
GNaiveInstanceAttr** m_pAttrs;
int m_nNeighbors;
double m_dMinDist;
double* m_pValueSums;
double* m_pWeightSums;
double* m_pSumBuffer;
double* m_pSumOfSquaresBuffer;
double* m_pInputBuffer;
int m_nVectorModeInputs;
int m_nVectorModeOutputs;
public:
// nNeighbors is the number of neighbors (in every dimension)
// that will contribute to the output value. dDiscernment tells
// it how much to emphasize low-variance patterns over high-variance
// patterns. (0=none, 1=proportional to variance ratio)
GNaiveInstance(GArffRelation* pRelation, int nNeighbors);
virtual ~GNaiveInstance();
// Discard any training (but not any settings) so it can be trained again
virtual void Reset();
// Incrementally train with a single instance
void AddInstance(double* pVector);
// Train using all the samples in a collection
virtual void Train(GArffData* pData);
// Deduce the output values from the input values
virtual void Eval(double* pVector);
protected:
void EvalInput(int nInputDim, double dInput);
};
#endif // __GNAIVEINSTANCE_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -