# NMath Stats User's Guide

7.6 Predicted Probabilities (.NET, C#, CSharp, VB, Visual Basic, F#)

You can use a LogisticRegression object to generate predictions. The PredictedProbability() method returns the probability of a positive outcome predicted by the model for a given set of predictor values. For example:

Code Example – C# logistic regression

``` DoubleVector predictors =
new DoubleVector( 150.0, 33.5, 0.66, 80.0 );
double predicted = lr.PredictedProbability( predictors );
```

A MismatchedSizeException is raised if the length of the given vector is not equal to the number of parameters in the model.

Similarly, the PredictedProbabilities() method returns a vector of predicted probabilities of a positive outcome for the predictor variable values contained in the rows of an input matrix.

Code Example – C# logistic regression

```DoubleMatrix predictors =
new DoubleMatrix( "3x4 [ 150.0 33.5 0.66 80.0
160.0 24.5 0.88 70.0
170.0 22.6 0.56 60.0 ]" );
DoubleVector predicted = lr.PredictedProbabilities( predictors );
```

In the returned vector of predicted observations, the ith element is the predicted response for the set of predictor variable values in the ith row of the given matrix.

Top

Top