本文整理汇总了C++中DataFrame::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFrame::isNull方法的具体用法?C++ DataFrame::isNull怎么用?C++ DataFrame::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFrame
的用法示例。
在下文中一共展示了DataFrame::isNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute
void PrincipalComponentsAnalysis::compute(DataFrame& df)
{
if (df.getNumFactors() > 2)
{
// see PrincipalComponentsAnalysisTest
cout << "You realize this hasn't been tested, right?" << endl;
}
Matrix dataMat(df.getNumFactors(), df.getNumDataVectors());
Matrix deviates(df.getNumFactors(), df.getNumDataVectors());
SymmetricMatrix covar(df.getNumFactors());
DiagonalMatrix eigenValues(df.getNumFactors());
Matrix eigenVectors;
ColumnVector means(df.getNumFactors());
means = 0.0;
RowVector h(df.getNumDataVectors());
h = 1.0;
for (unsigned int j = 0; j < df.getNumFactors(); j++)
{
if (df.isNominal(j))
{
throw Tgs::Exception("Only numeric values are supported.");
}
}
for(unsigned int i = 0; i < df.getNumDataVectors(); i++)
{
for (unsigned int j = 0; j < df.getNumFactors(); j++)
{
double v = df.getDataElement(i, j);
if (df.isNull(v))
{
throw Tgs::Exception("Only non-null values are supported.");
}
dataMat.element(j, i) = v;
means.element(j) += v / (double)df.getNumDataVectors();
}
}
try
{
deviates = dataMat - (means * h);
covar << (1.0/(float)df.getNumDataVectors()) * (deviates * deviates.t());
Jacobi::jacobi(covar, eigenValues, eigenVectors);
}
catch (const std::exception&)
{
throw;
}
catch (...)
{
throw Tgs::Exception("Unknown error while calculating PCA");
}
_sortEigens(eigenVectors, eigenValues);
_components.resize(df.getNumFactors());
for (unsigned int v = 0; v < df.getNumFactors(); v++)
{
_components[v].resize(df.getNumFactors());
for (unsigned int d = 0; d < df.getNumFactors(); d++)
{
_components[v][d] = eigenVectors.element(d, v);
}
}
}