A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://accord-framework.net/docs/html/T_Accord_Math_Optimization_Losses_RSquaredLoss.htm below:

RSquaredLoss Class

R² (r-squared) loss.

Inheritance Hierarchy Namespace:  Accord.Math.Optimization.Losses
Assembly:

Accord.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 Adjust

Gets whether the adjusted version of the R² measure should be computed instead.

Expected

Gets the expected outputs (the ground truth).

(Inherited from LossBaseTInput, TScore, TLoss.) NumberOfInputs

Gets or sets the number of variables being fit in the problem.

Weights

Gets or sets the weights associated with each input-output pair.

Top Methods   Name Description Equals

Determines whether the specified object is equal to the current object.

(Inherited from Object.) Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

(Inherited from Object.) GetHashCode

Serves as the default hash function.

(Inherited from Object.) GetType

Gets 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).) MemberwiseClone

Creates a shallow copy of the current Object.

(Inherited from Object.) ToString

Returns a string that represents the current object.

(Inherited from Object.) Top Extension Methods   Name Description HasMethod

Checks whether an object implements a method with the given name.

(Defined by ExtensionMethods.) IsEqual

Compares 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 Examples

This 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