R² (r-squared) loss.
Inheritance Hierarchy Namespace: Accord.Math.Optimization.LossesAccord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax[SerializableAttribute] public class RSquaredLoss : LossBase<double[][], double[][], double[]>, ILoss<double[]>, ILoss<double[], double>
<SerializableAttribute> Public Class RSquaredLoss Inherits LossBase(Of Double()(), Double()(), Double()) Implements ILoss(Of Double()), ILoss(Of Double(), Double)Request Example View Source
The RSquaredLoss type exposes the following members.
Constructors Properties Name Description AdjustGets whether the adjusted version of the R² measure should be computed instead.
ExpectedGets the expected outputs (the ground truth).
(Inherited from LossBaseTInput, TScore, TLoss.) NumberOfInputsGets or sets the number of variables being fit in the problem.
WeightsGets or sets the weights associated with each input-output pair.
Top Methods Name Description EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object.) FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.) GetHashCodeServes as the default hash function.
(Inherited from Object.) GetTypeGets the Type of the current instance.
(Inherited from Object.) Loss(Double)Computes the loss between the expected values (ground truth) and the given actual values that have been predicted.
Loss(Double)Computes the loss between the expected values (ground truth) and the given actual values that have been predicted.
(Overrides LossBaseTInput, TScore, TLossLoss(TScore).) MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object.) ToStringReturns a string that represents the current object.
(Inherited from Object.) Top Extension Methods Name Description HasMethodChecks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) IsEqualCompares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.) To(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.) ToT 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.) Top Remarks ExamplesThis example shows how to fit a multiple linear regression model and compute adjusted and non-adjusted versions of the R² coefficient of determination at the end:
Servo servo = new Servo(); object[][] instances = servo.Instances; double[] outputs = servo.Output; var codebook = new Codification<object>() { { "motor", CodificationVariable.Categorical }, { "screw", CodificationVariable.Categorical }, { "pgain", CodificationVariable.Continuous }, { "vgain", CodificationVariable.Continuous }, }; codebook.Learn(instances); int numberOfInputs = codebook.NumberOfInputs; int numberOfOutputs = codebook.NumberOfOutputs; double[][] inputs = codebook.ToDouble().Transform(instances); var ols = new OrdinaryLeastSquares() { UseIntercept = true }; MultipleLinearRegression regression = ols.Learn(inputs, outputs); double[] predicted = regression.Transform(inputs); double error = new SquareLoss(outputs).Loss(predicted); double r2 = new RSquaredLoss(numberOfOutputs, outputs).Loss(predicted); var r2loss = new RSquaredLoss(numberOfOutputs, outputs) { Adjust = true, }; double ar2 = r2loss.Loss(predicted); double ur2 = regression.CoefficientOfDetermination(inputs, outputs, adjust: true);See Also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4