xml doc rewrite

This commit is contained in:
Miha
2024-10-27 09:38:53 -07:00
parent c21b96152c
commit b2fcdda785
71 changed files with 2607 additions and 1102 deletions
+37
View File
@@ -1,10 +1,44 @@
using System;
namespace QuanTAlib;
/// <summary>
/// RMSLE: Root Mean Square Logarithmic Error
/// A variation of RMSE that operates on log-transformed values. RMSLE is particularly
/// useful for data with exponential growth or when relative errors in larger values
/// should be treated similarly to relative errors in smaller values.
/// </summary>
/// <remarks>
/// The RMSLE calculation process:
/// 1. Adds 1 to both actual and predicted values (to handle zeros)
/// 2. Takes natural log of both values
/// 3. Calculates squared difference of logs
/// 4. Averages the squared differences
/// 5. Takes the square root
///
/// Key characteristics:
/// - Scale-independent due to log transformation
/// - Penalizes underestimates more than overestimates
/// - Handles exponential trends well
/// - More sensitive to relative differences
/// - Can handle zero values (adds 1 before log)
///
/// Formula:
/// RMSLE = √((1/n) * Σ(log(actual + 1) - log(predicted + 1))²)
///
/// Sources:
/// https://www.kaggle.com/wiki/RootMeanSquaredLogarithmicError
/// https://medium.com/analytics-vidhya/root-mean-square-log-error-rmse-vs-rmlse-935c6cc1802a
///
/// Note: Square root of MSLE, useful for data with exponential growth
/// </remarks>
public class Rmsle : AbstractBase
{
private readonly CircularBuffer _actualBuffer;
private readonly CircularBuffer _predictedBuffer;
/// <param name="period">The number of points over which to calculate the RMSLE.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when period is less than 1.</exception>
public Rmsle(int period)
{
if (period < 1)
@@ -18,6 +52,8 @@ public class Rmsle : AbstractBase
Init();
}
/// <param name="source">The data source object that publishes updates.</param>
/// <param name="period">The number of points over which to calculate the RMSLE.</param>
public Rmsle(object source, int period) : this(period)
{
var pubEvent = source.GetType().GetEvent("Pub");
@@ -47,6 +83,7 @@ public class Rmsle : AbstractBase
double actual = Input.Value;
_actualBuffer.Add(actual, Input.IsNew);
// If no predicted value provided, use mean of actual values
double predicted = double.IsNaN(Input2.Value) ? _actualBuffer.Average() : Input2.Value;
_predictedBuffer.Add(predicted, Input.IsNew);