NMath Stats User's Guide

TOC | Previous | Next | Index

7.3 Checking for Convergence (.NET, C#, CSharp, VB, Visual Basic, F#)

After constructing a LogisticRegression object, first check that the parameter calculation was successful. For example, this code checks the IsGood property, and if the calculation failed, prints out some diagnostic information using the ParameterCalculationErrorMessage property.

Code Example – C# logistic regression

if ( !lr.IsGood )
      "Logistic regression parameter calculation failed:" );
    Console.WriteLine( lr.ParameterCalculationErrorMessage );

    var parameterCalc = lr.ParameterCalculator;
    Console.WriteLine( "Maximum iterations: " + 
      parameterCalc.MaxIterations );
    Console.WriteLine( "Number of iterations: " + 
      parameterCalc.Iterations );
    Console.WriteLine( "Converged? " + parameterCalc.Converged );