本文整理汇总了C++中Samples::getFeatureNum方法的典型用法代码示例。如果您正苦于以下问题:C++ Samples::getFeatureNum方法的具体用法?C++ Samples::getFeatureNum怎么用?C++ Samples::getFeatureNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Samples
的用法示例。
在下文中一共展示了Samples::getFeatureNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: samples
OfflineKMeans::OfflineKMeans(const Samples<float>& data, const int k): samples(data),
featureNum(data.getFeatureNum()), sampleNum(data.getSampleNum()), clusterNum(k) {
initClusters();
#ifdef OKM_DBG
print();
while(reCluster() == true) {
print();
}
#else
while(reCluster() == true);
#endif
}
示例2: trainingSamples
LogisticRegression::LogisticRegression(const Samples<float>& samples, const float a,
const RegressionFunction& regFunc, float thres): trainingSamples(samples),
featureNum(samples.getFeatureNum()), sampleNum(samples.getSampleNum()),
alpha(a), rf(regFunc), threshold(thres) {
if((featureNum <= 0) || (sampleNum <= 0)) {
// TODO: handle scenario "featureNum <= 0" and "sampleNum <= 0" in proper way.
}
categories = new float[sampleNum];
for(int i = 0; i < sampleNum; ++i)
categories[i] = trainingSamples.getSample(i)[featureNum];
// calculate category range = maximum category - minimum category
float category0 = categories[0];
float minCategory = category0;
float maxCategory = category0;
for(int i = 1; i < sampleNum; ++i) {
float categoryi = categories[i];
if(minCategory > categoryi)
minCategory = categoryi;
if(maxCategory < categoryi)
maxCategory = categoryi;
}
categoryRange = maxCategory - minCategory;
#ifdef LR_DEBUG
std::cout<<"categoryRange = "<<categoryRange<<std::endl;
#endif
parameters = new long double[featureNum];
for(int i = 0; i < featureNum; ++i)
parameters[i] = 1.0;
// calculate parameters using gradient ascent algorithm
gradientAscent();
}