MCPcopy Create free account
hub / github.com/apache/madlib / stateToResult

Function stateToResult

examples/hello_world/iterative/simple_logistic.cpp:410–447  ·  view source on GitHub ↗

* @brief Compute the diagnostic statistics * * This function wraps the common parts of computing the results for both the * CG and the IRLS method. */

Source from the content-addressed store, hash-verified

408 * CG and the IRLS method.
409 */
410AnyType stateToResult(
411 const Allocator &inAllocator,
412 const HandleMap<const ColumnVector, TransparentHandle<double> > &inCoef,
413 const Matrix & hessian,
414 const double &logLikelihood,
415 int status,
416 const uint64_t &numRows) {
417
418 SymmetricPositiveDefiniteEigenDecomposition<Matrix> decomposition(
419 hessian, EigenvaluesOnly, ComputePseudoInverse);
420
421 const Matrix &inverse_of_X_transp_AX = decomposition.pseudoInverse();
422 const ColumnVector &diagonal_of_X_transp_AX = inverse_of_X_transp_AX.diagonal();
423
424 MutableNativeColumnVector stdErr(
425 inAllocator.allocateArray<double>(inCoef.size()));
426 MutableNativeColumnVector waldZStats(
427 inAllocator.allocateArray<double>(inCoef.size()));
428 MutableNativeColumnVector waldPValues(
429 inAllocator.allocateArray<double>(inCoef.size()));
430 MutableNativeColumnVector oddsRatios(
431 inAllocator.allocateArray<double>(inCoef.size()));
432
433 for (Index i = 0; i < inCoef.size(); ++i) {
434 stdErr(i) = std::sqrt(diagonal_of_X_transp_AX(i));
435 waldZStats(i) = inCoef(i) / stdErr(i);
436 waldPValues(i) = 2. * prob::cdf( prob::normal(),
437 -std::abs(waldZStats(i)));
438 oddsRatios(i) = std::exp( inCoef(i) );
439 }
440
441 // Return all coefficients, standard errors, etc. in a tuple
442 AnyType tuple;
443 tuple << inCoef << logLikelihood << stdErr << waldZStats << waldPValues
444 << oddsRatios << inverse_of_X_transp_AX
445 << sqrt(decomposition.conditionNo()) << status << numRows;
446 return tuple;
447}
448
449} // namespace hello_world
450} // namespace modules

Callers 1

runMethod · 0.70

Calls 3

conditionNoMethod · 0.80
cdfFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected