Click or drag to resize
Accord.NET (logo)

ProportionalHazardsNewtonRaphson Class

Newton-Raphson learning updates for Cox's Proportional Hazards models.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.Models.Regression.FittingProportionalHazardsNewtonRaphson

Namespace:  Accord.Statistics.Models.Regression.Fitting
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
public class ProportionalHazardsNewtonRaphson : ISupervisedLearning<ProportionalHazards, Tuple<double[], double>, int>, 
	ISupervisedLearning<ProportionalHazards, Tuple<double[], double>, bool>, 
	IConvergenceLearning
Request Example View Source

The ProportionalHazardsNewtonRaphson type exposes the following members.

Constructors
  NameDescription
Public methodProportionalHazardsNewtonRaphson
Constructs a new Newton-Raphson learning algorithm for Cox's Proportional Hazards models.
Public methodProportionalHazardsNewtonRaphson(ProportionalHazards)
Constructs a new Newton-Raphson learning algorithm for Cox's Proportional Hazards models.
Top
Properties
  NameDescription
Public propertyComputeBaselineFunction
Gets or sets a value indicating whether an estimate of the baseline hazard function should be computed at the end of the next iterations.
Public propertyComputeStandardErrors
Gets or sets a value indicating whether standard errors should be computed at the end of the next iterations.
Public propertyCurrentIteration
Gets or sets the number of performed iterations.
Public propertyEstimator
Gets or sets the hazard estimator that should be used by the proportional hazards learning algorithm. Default is to use BreslowNelsonAalen.
Public propertyGradient
Gets the Gradient vector computed in the last Newton-Raphson iteration.
Public propertyHasConverged
Gets or sets whether the algorithm has converged.
Public propertyHessian
Gets the Hessian matrix computed in the last Newton-Raphson iteration.
Public propertyIterations Obsolete.
Please use MaxIterations instead.
Public propertyLambda
Gets or sets the smoothing factor used to avoid numerical problems in the beginning of the training. Default is 0.1.
Public propertyMaxIterations
Gets or sets the maximum number of iterations performed by the learning algorithm.
Public propertyModel
Gets or sets the regression model being learned.
Public propertyNormalize
Gets or sets a value indicating whether the Cox model should be computed using the mean-centered version of the covariates. Default is true.
Public propertyParameters
Gets the total number of parameters in the model.
Public propertyPrevious
Gets the previous values for the coefficients which were in place before the last learning iteration was performed.
Public propertySolution
Gets the current values for the coefficients.
Public propertyTies
Gets or sets the ties handling method to be used by the proportional hazards learning algorithm. Default is to use Efron's method.
Public propertyToken
Gets or sets a cancellation token that can be used to stop the learning algorithm while it is running.
Public propertyTolerance
Gets or sets the maximum absolute parameter change detectable after an iteration of the algorithm used to detect convergence. Default is 1e-5.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLearn(TupleDouble, Double, SurvivalOutcome, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(TupleDouble, Double, Boolean, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(TupleDouble, Double, Int32, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(Double, Double, SurvivalOutcome, Double)
Learns a model that can map the given inputs to the given outputs.
Public methodLearn(Double, Double, Int32, Double)
Learns a model that can map the given inputs to the given outputs.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRun(Double, SurvivalOutcome) Obsolete.
Runs the Newton-Raphson update for Cox's hazards learning until convergence.
Public methodRun(Double, Int32) Obsolete.
Runs the Newton-Raphson update for Cox's hazards learning until convergence.
Public methodRun(Double, Double) Obsolete.
Runs the Newton-Raphson update for Cox's hazards learning until convergence.
Public methodRun(Double, Double, SurvivalOutcome) Obsolete.
Runs the Newton-Raphson update for Cox's hazards learning until convergence.
Public methodRun(Double, Double, Int32) Obsolete.
Runs the Newton-Raphson update for Cox's hazards learning until convergence.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Examples
// Let's say we have the following survival problem. Each row in the
// table below represents a patient under care in a hospital. The first
// colum represents their age (a single feature, but there could have
// been many like age, height, weight, etc), the time until an event
// has happened (like, for example, unfortunatey death) and the event
// outcome (i.e. what has exactly happened after this amount of time,
// has the patient died or did he simply leave the hospital and we 
// couldn't get more data about him?)

object[,] data =
{
    //    input         time until           outcome 
    // (features)     event happened     (what happened?)
    {       50,              1,         SurvivalOutcome.Censored  },
    {       70,              2,         SurvivalOutcome.Failed    },
    {       45,              3,         SurvivalOutcome.Censored  },
    {       35,              5,         SurvivalOutcome.Censored  },
    {       62,              7,         SurvivalOutcome.Failed    },
    {       50,             11,         SurvivalOutcome.Censored  },
    {       45,              4,         SurvivalOutcome.Censored  },
    {       57,              6,         SurvivalOutcome.Censored  },
    {       32,              8,         SurvivalOutcome.Censored  },
    {       57,              9,         SurvivalOutcome.Failed    },
    {       60,             10,         SurvivalOutcome.Failed    },
}; // Note: Censored means that we stopped recording data for that person,
   // so we do not know what actually happened to them, except that things
   // were going fine until the point in time appointed by "time to event"

// Parse the data above
double[][] inputs = data.GetColumn(0).ToDouble().ToJagged();
double[] time = data.GetColumn(1).ToDouble();
SurvivalOutcome[] output = data.GetColumn(2).To<SurvivalOutcome[]>();

// Create a new PH Newton-Raphson learning algorithm
var teacher = new ProportionalHazardsNewtonRaphson()
{
    ComputeBaselineFunction = true,
    ComputeStandardErrors = true,
    MaxIterations = 100
};

// Use the learning algorithm to infer a Proportional Hazards model
ProportionalHazards regression = teacher.Learn(inputs, time, output);

// Use the regression to make predictions (problematic)
SurvivalOutcome[] prediction = regression.Decide(inputs);

// Use the regression to make score estimates 
double[] score = regression.Score(inputs);

// Use the regression to make probability estimates 
double[] probability = regression.Probability(inputs);
See Also