Click or drag to resize
Accord.NET (logo)

ProportionalHazards Class

Cox's Proportional Hazards Model.
Inheritance Hierarchy
SystemObject
  Accord.MachineLearningTransformBaseTupleDouble, Double, Boolean
    Accord.MachineLearningClassifierBaseTupleDouble, Double, Boolean
      Accord.MachineLearningBinaryClassifierBaseTupleDouble, Double
        Accord.MachineLearningBinaryScoreClassifierBaseTupleDouble, Double
          Accord.MachineLearningBinaryLikelihoodClassifierBaseTupleDouble, Double
            Accord.Statistics.Models.RegressionProportionalHazards

Namespace:  Accord.Statistics.Models.Regression
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public sealed class ProportionalHazards : BinaryLikelihoodClassifierBase<Tuple<double[], double>>
Request Example View Source

The ProportionalHazards type exposes the following members.

Constructors
  NameDescription
Public methodProportionalHazards
Creates a new Cox Proportional-Hazards Model.
Public methodProportionalHazards(Int32)
Creates a new Cox Proportional-Hazards Model.
Public methodProportionalHazards(Int32, IUnivariateDistribution)
Creates a new Cox Proportional-Hazards Model.
Top
Properties
  NameDescription
Public propertyBaselineHazard
Gets the baseline hazard function, if specified.
Public propertyCoefficients
Gets the coefficient vector, in which the first value is always the intercept value.
Public propertyInputs Obsolete.
Gets the number of inputs handled by this model.
Public propertyIntercept
Gets or sets the intercept (bias) for the regression model.
Public propertyNumberOfClasses
Gets the number of classes expected and recognized by the classifier.
(Inherited from ClassifierBaseTInput, TClasses.)
Public propertyNumberOfInputs
Gets the number of inputs accepted by the model.
(Inherited from TransformBaseTInput, TOutput.)
Public propertyNumberOfOutputs
Gets the number of outputs generated by the model.
(Inherited from TransformBaseTInput, TOutput.)
Public propertyOffsets Obsolete.
Gets the mean vector used to center observations before computations.
Public propertyStandardErrors
Gets the standard errors associated with each coefficient during the model estimation phase.
Top
Methods
  NameDescription
Public methodChiSquare(Double, Double, SurvivalOutcome)
The likelihood ratio test of the overall model, also called the model chi-square test.
Public methodChiSquare(Double, Double, Int32)
The likelihood ratio test of the overall model, also called the model chi-square test.
Public methodClone
Creates a new Cox's Proportional Hazards that is a copy of the current instance.
Public methodCompute(Double) Obsolete.
Obsolete. Please use the Probability(input) method instead.
Public methodCompute(Double) Obsolete.
Obsolete. Please use the Probability(input) method instead.
Public methodCompute(Double) Obsolete.
Obsolete. Please use the Probability(input) method instead.
Public methodCompute(Double, Double) Obsolete.
Obsolete. Please use the Probability(input, time) method instead.
Public methodCompute(Double, Double) Obsolete.
Computes the model output for the given input vector.
Public methodDecide(TInput)
Computes a class-label decision for a given input.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodDecide(TInput)
Computes class-label decisions for a given set of input vectors.
(Inherited from ClassifierBaseTInput, TClasses.)
Public methodDecide(Double)
Computes class-label decisions for each vector in the given input.
Public methodDecide(Double)
Computes class-label decisions for each vector in the given input.
Public methodDecide(TInput, Boolean)
Computes class-label decisions for the given input.
(Inherited from BinaryClassifierBaseTInput.)
Public methodDecide(TInput, Boolean)
Computes a class-label decision for a given input.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodDecide(Double, Double)
Computes class-label decisions for each vector in the given input.
Public methodDecide(Double, Double)
Computes class-label decisions for each vector in the given input.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetConfidenceInterval
Gets the 95% confidence interval for the Hazard Ratio for a given coefficient.
Public methodGetDeviance
Gets the Deviance for the model.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetHazardRatio
Gets the Hazard Ratio for a given coefficient.
Public methodGetLogHazardRatio
Gets the Log-Hazard Ratio between two observations.
Public methodGetLogLikelihoodRatio
Gets the Log-Likelihood Ratio between two models.
Public methodGetPartialLogLikelihood(Double, SurvivalOutcome)
Gets the Partial Log-Likelihood for the model.
Public methodGetPartialLogLikelihood(Double, Int32)
Gets the Partial Log-Likelihood for the model.
Public methodGetPartialLogLikelihood(Double, Double, SurvivalOutcome)
Gets the Partial Log-Likelihood for the model.
Public methodGetPartialLogLikelihood(Double, Double, Int32)
Gets the Partial Log-Likelihood for the model.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetWaldTest
Gets the Wald Test for a given coefficient.
Public methodLogLikelihood(TInput)
Predicts a class label vector for the given input vector, returning the log-likelihood that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihood(TInput)
Predicts a class label vector for the given input vector, returning the log-likelihood that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihood(Double)
Predicts a class label for the given input vector, returning the log-likelihood that the input vector belongs to its predicted class.
Public methodLogLikelihood(Double)
Predicts a class label vector for the given input vectors, returning the log-likelihood that the input vector belongs to its predicted class.
Public methodLogLikelihood(Double)
Predicts a class label vector for the given input vectors, returning the log-likelihood that the input vector belongs to its predicted class.
Public methodLogLikelihood(TInput, Boolean)
Predicts a class label vector for the given input vector, returning the log-likelihood that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihood(TInput, Int32)
Predicts a class label for each input vector, returning the log-likelihood that each vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihood(Double, Double)
Predicts a class label vector for the given input vectors, returning the log-likelihood that the input vector belongs to its predicted class.
Public methodLogLikelihood(Double, Double)
Predicts a class label vector for the given input vectors, returning the log-likelihood that the input vector belongs to its predicted class.
Public methodLogLikelihood(TupleDouble, Double, Double)
Predicts a class label vector for the given input vectors, returning the log-likelihood that the input vector belongs to its predicted class.
(Overrides BinaryLikelihoodClassifierBaseTInputLogLikelihood(TInput, Double).)
Public methodLogLikelihood(TInput, Boolean, Double)
Predicts a class label for each input vector, returning the log-likelihood that each vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput)
Computes the log-likelihood that the given input vector belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput)
Computes the log-likelihoods that the given input vectors belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput, Boolean)
Predicts a class label vector for the given input vector, returning the log-likelihoods of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput, Double)
Computes the log-likelihood that the given input vector belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput, Double)
Computes the log-likelihoods that the given input vectors belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput, Int32)
Predicts a class label vector for each input vector, returning the log-likelihoods of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput, Boolean, Double)
Predicts a class label vector for the given input vector, returning the log-likelihoods of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodLogLikelihoods(TInput, Boolean, Double)
Predicts a class label vector for each input vector, returning the log-likelihoods of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput)
Computes the probabilities that the given input vector belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput)
Computes the probabilities that the given input vectors belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput, Boolean)
Predicts a class label vector for the given input vector, returning the probabilities of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput, Double)
Computes the probabilities that the given input vector belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput, Double)
Computes the probabilities that the given input vectors belongs to each of the possible classes.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput, Int32)
Predicts a class label vector for each input vector, returning the probabilities of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput, Boolean, Double)
Predicts a class label vector for the given input vector, returning the probabilities of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbabilities(TInput, Boolean, Double)
Predicts a class label vector for each input vector, returning the probabilities of the input vector belonging to each possible class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbability(TInput)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbability(TInput)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbability(Double)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
Public methodProbability(Double)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
Public methodProbability(Double)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
Public methodProbability(TInput, Boolean)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbability(TInput, Double)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbability(TInput, Int32)
Predicts a class label for each input vector, returning the probability that each vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodProbability(Double, Double)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
Public methodProbability(Double, Double)
Predicts a class label for the given input vector, returning the probability that the input vector belongs to its predicted class.
Public methodProbability(TInput, Boolean, Double)
Predicts a class label for each input vector, returning the probability that each vector belongs to its predicted class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodScore(TInput)
Computes a numerical score measuring the association between the given input vector and its most strongly associated class (as predicted by the classifier).
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScore(TInput)
Computes a numerical score measuring the association between the given input vector and its most strongly associated class (as predicted by the classifier).
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScore(Double)
Computes a numerical score measuring the association between the given input vector and each class.
Public methodScore(Double)
Computes a numerical score measuring the association between the given input vector and each class.
Public methodScore(TInput, Double)
Computes a numerical score measuring the association between the given input vector and each class.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodScore(TInput, Boolean)
Predicts a class label for the input vector, returning a numerical score measuring the strength of association of the input vector to its most strongly related class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScore(TInput, Boolean)
Predicts a class label for each input vector, returning a numerical score measuring the strength of association of the input vector to the most strongly related class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScore(Double, Double)
Computes a numerical score measuring the association between the given input vector and each class.
Public methodScore(Double, Double)
Computes a numerical score measuring the association between the given input vector and each class.
Public methodScore(TInput, Boolean, Double)
Predicts a class label for each input vector, returning a numerical score measuring the strength of association of the input vector to the most strongly related class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput)
Computes a numerical score measuring the association between the given input vector and each class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput)
Computes a numerical score measuring the association between the given input vector and each class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput, Boolean)
Predicts a class label vector for the given input vector, returning a numerical score measuring the strength of association of the input vector to each of the possible classes.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput, Double)
Computes a numerical score measuring the association between the given input vector and each class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput, Boolean)
Predicts a class label vector for each input vector, returning a numerical score measuring the strength of association of the input vector to each of the possible classes.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput, Double)
Computes a numerical score measuring the association between the given input vector and each class.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput, Boolean, Double)
Predicts a class label vector for the given input vector, returning a numerical score measuring the strength of association of the input vector to each of the possible classes.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodScores(TInput, Boolean, Double)
Predicts a class label vector for each input vector, returning a numerical score measuring the strength of association of the input vector to each of the possible classes.
(Inherited from BinaryScoreClassifierBaseTInput.)
Public methodSurvival
Computes the model's baseline survival function. This method simply calls the ComplementaryDistributionFunction(Double) of the BaselineHazard function.
Public methodToMulticlass
Views this instance as a multi-class generative classifier, giving access to more advanced methods, such as the prediction of integer labels.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodToMultilabel
Views this instance as a multi-label generative classifier, giving access to more advanced methods, such as the prediction of one-hot vectors.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTransform(TInput)
Applies the transformation to an input, producing an associated output.
(Inherited from ClassifierBaseTInput, TClasses.)
Public methodTransform(TInput)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from TransformBaseTInput, TOutput.)
Public methodTransform(TInput, Boolean)
Applies the transformation to an input, producing an associated output.
(Inherited from BinaryClassifierBaseTInput.)
Public methodTransform(TInput, Int32)
Applies the transformation to an input, producing an associated output.
(Inherited from BinaryClassifierBaseTInput.)
Public methodTransform(TInput, Boolean)
Applies the transformation to an input, producing an associated output.
(Inherited from BinaryClassifierBaseTInput.)
Public methodTransform(TInput, Int32)
Applies the transformation to an input, producing an associated output.
(Inherited from BinaryClassifierBaseTInput.)
Public methodTransform(TInput, Int32)
Applies the transformation to an input, producing an associated output.
(Inherited from BinaryClassifierBaseTInput.)
Public methodTransform(TInput, Double)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodTransform(TInput, Double)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodTransform(TInput, Double)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from BinaryLikelihoodClassifierBaseTInput.)
Public methodTransform(TInput, TClasses)
Applies the transformation to an input, producing an associated output.
(Inherited from ClassifierBaseTInput, TClasses.)
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