SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWLogRegModelSelector< F > Class Template Reference

For a logistic regression model, selects a subset of predictor variables that accounts for the variation in the regression model's observation variable. More...

#include <rw/analytics/lgmodsel.h>

Inheritance diagram for RWLogRegModelSelector< F >:
RWRegressionModelSelector< double, bool, F >

Public Member Functions

 RWLogRegModelSelector ()
 
 RWLogRegModelSelector (const RWLogisticRegression &reg, RWSearchMethod s)
 
 RWLogRegModelSelector (const RWLogRegModelSelector< F > &rhs)
 
RWLogRegModelSelector< F > & operator= (const RWLogRegModelSelector< F > &rhs)
 
- Public Member Functions inherited from RWRegressionModelSelector< double, bool, F >
 RWRegressionModelSelector ()
 
 RWRegressionModelSelector (const RWRegression< double, bool > &reg, RWSearchMethod s)
 
 RWRegressionModelSelector (const RWRegressionModelSelector< double, bool, F > &rhs)
 
virtual ~RWRegressionModelSelector ()
 
const RWRegressionCalc< double, bool > & calcMethod () const
 
double evalFunctionForSelected () const
 
bool fail () const
 
RWCString failMessage () const
 
RWRegressionModelSelector< double, bool, F > & operator= (const RWRegressionModelSelector< double, bool, F > &rhs)
 
RWSearchMethod searchMethod () const
 
const RWBitVecselectedParamIndices () const
 
const RWBitVecselectedParamIndices (RWSearchMethod s)
 
const RWMathVec< double > & selectedParamValues () const
 
void setCalcMethod (const RWRegressionCalc< double, bool > &c)
 
void setRegression (const RWRegression< double, bool > &r)
 
void setSearchMethod (RWSearchMethod s)
 

Detailed Description

template<class F>
class RWLogRegModelSelector< F >

RWLogRegModelSelector is the class for logistic regression model selection. Provided with a logistic regression model containing a set of candidate predictor variables, the RWLogRegModelSelector class selects a subset of predictor variables that still accounts well for the variation in the regression model's observation variable. The criteria for selecting one predictor subset over another are determined by the template parameter F. Class F is a function object that returns a numerical value whenever it is given a regression matrix, an observation vector, and parameter estimates.

To be used as a template parameter for RWLogRegModelSelector, a class F must implement the following interface:

class F {
public:
double operator()(const RWGenMat<double>& regressionMatrix,
const RWMathVec<bool>& observationVector,
const RWMathVec<double>& parameterEstimates);
};
A templatized general matrix class.
Definition genmat.h:741
A templatized vector class.
Definition mathvec.h:667
Synopsis
#include <rw/analytics/gpvalfun.h>
#include <rw/analytics/lgmodsel.h>
#include <rw/analytics/logregress.h>
For a logistic regression model, selects a subset of predictor variables that accounts for the variat...
Definition lgmodsel.h:94
Performs basic logistic regression on a matrix of predictor variables and a vector of observations.
Definition logregress.h:82
@ rwForwardSelection
Definition regsel.h:26
Example
#include <rw/analytics/gpvalfun.h>
#include <rw/analytics/lgmodsel.h>
#include <rw/analytics/loglevbg.h>
#include <rw/analytics/logregress.h>
#include <iostream>
int main() {
RWGenMat<double> predData = "5x2 [1 234 2 431 3
333 4 654 5 788]";
obsData[0] = obsData[3] = obsData[4] = true;
obsData[1] = obsData[2] = false;
RWLogisticRegression lr(predData, obsData,
std::cout << "Searching using forward selection---------------"
<< std::endl;
std::cout << "selected parameter indices: "
<< selector.selectedParamIndices() << std::endl;
std::cout << "model criterion value: "
<< selector.evalFunctionForSelected() << std::endl;
std::cout << "Searching using backward selection--------------"
<< std::endl;
selector.setSearchMethod(rwBackwardSelection);
std::cout << "selected parameter indices: "
<< selector.selectedParamIndices() << std::endl;
std::cout << "model criterion value: "
<< selector.evalFunctionForSelected() << std::endl;
return 0;
}
Calculates model parameter estimates from logistic regression data using the Levenberg-Marquardt meth...
Definition loglevbg.h:74
@ rwBackwardSelection
Definition regsel.h:31
@ rwUninitialized
Definition defs.h:105

Constructor & Destructor Documentation

◆ RWLogRegModelSelector() [1/3]

template<class F >
RWLogRegModelSelector< F >::RWLogRegModelSelector ( )
inline

Default constructor. Behavior undefined.

◆ RWLogRegModelSelector() [2/3]

template<class F >
RWLogRegModelSelector< F >::RWLogRegModelSelector ( const RWLogRegModelSelector< F > & rhs)
inline

Copy constructor.

◆ RWLogRegModelSelector() [3/3]

template<class F >
RWLogRegModelSelector< F >::RWLogRegModelSelector ( const RWLogisticRegression & reg,
RWSearchMethod s )
inline

Constructs a model selector using the search method s.

Member Function Documentation

◆ operator=()

template<class F >
RWLogRegModelSelector< F > & RWLogRegModelSelector< F >::operator= ( const RWLogRegModelSelector< F > & rhs)
inline

Assignment operator.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.