You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by ra...@apache.org on 2023/02/02 21:27:17 UTC

[mahout] branch cochrane-orcutt-docs created (now d48ffc5f8)

This is an automated email from the ASF dual-hosted git repository.

rawkintrevo pushed a change to branch cochrane-orcutt-docs
in repository https://gitbox.apache.org/repos/asf/mahout.git


      at d48ffc5f8 Add docs

This branch includes the following new commits:

     new d48ffc5f8 Add docs

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[mahout] 01/01: Add docs

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rawkintrevo pushed a commit to branch cochrane-orcutt-docs
in repository https://gitbox.apache.org/repos/asf/mahout.git

commit d48ffc5f85b2f4919b4224e9755973794eff583c
Author: Trevor Grant <tr...@gmail.com>
AuthorDate: Thu Feb 2 15:27:11 2023 -0600

    Add docs
---
 .../regression/CochraneOrcuttModel.scala           | 42 +++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/org/apache/mahout/math/algorithms/regression/CochraneOrcuttModel.scala b/core/src/main/scala/org/apache/mahout/math/algorithms/regression/CochraneOrcuttModel.scala
index 3e5a49660..78932579d 100644
--- a/core/src/main/scala/org/apache/mahout/math/algorithms/regression/CochraneOrcuttModel.scala
+++ b/core/src/main/scala/org/apache/mahout/math/algorithms/regression/CochraneOrcuttModel.scala
@@ -40,13 +40,39 @@ class CochraneOrcuttModel[K](regressor: LinearRegressorModel[K]) extends LinearR
 
 }
 
+/**
+ * A class for fitting a Cochrane-Orcutt regression model.
+ *
+ * @param hyperparameters A sequence of hyperparameters in the form of symbol-value pairs.
+ *                        Default values will be used if no hyperparameters are provided.
+ * @tparam K The key type of the DRM.
+ *
+ * @author [Author Name]
+ * @since [Release Date]
+ */
 class CochraneOrcutt[K](hyperparameters: (Symbol, Any)*)  extends LinearRegressorFitter[K] {
 
+  /**
+   * The regressor to use.
+   */
   var regressor: LinearRegressorFitter[K] = _
+ 
+ /**
+   * The number of iterations to use in the model fitting process.
+   */
   var iterations: Int = _
+ 
+  /**
+   * The cache hint to use for larger inputs.
+   */
   var cacheHint: CacheHint.CacheHint = _
   // For larger inputs, CacheHint.MEMORY_AND_DISK2 is reccomended.
 
+  /**
+   * Sets the hyperparameters for the model.
+   *
+   * @param hyperparameters A map of hyperparameters in the form of symbol-value pairs.
+   */
   def setHyperparameters(hyperparameters: Map[Symbol, Any] = Map('foo -> None)): Unit = {
     setStandardHyperparameters(hyperparameters.toMap)
     regressor = hyperparameters.asInstanceOf[Map[Symbol, LinearRegressorFitter[K]]].getOrElse('regressor, new OrdinaryLeastSquares())
@@ -58,6 +84,12 @@ class CochraneOrcutt[K](hyperparameters: (Symbol, Any)*)  extends LinearRegresso
 
   setHyperparameters(hyperparameters.toMap)
 
+ /**
+   * Calculates the value of rho for a given error matrix.
+   *
+   * @param errorDrm The error matrix.
+   * @return The calculated value of rho.
+   */
   def calculateRho(errorDrm: DrmLike[K]): Double ={
     val error = errorDrm.collect.viewColumn(0)
     val n = error.length - 1
@@ -67,6 +99,14 @@ class CochraneOrcutt[K](hyperparameters: (Symbol, Any)*)  extends LinearRegresso
     e3.times(e2).sum / e3.assign(Functions.SQUARE).sum
   }
 
+   /**
+   * Fits a Cochrane-Orcutt regression model to the input features and target data.
+   *
+   * @param drmFeatures The features matrix.
+   * @param drmTarget The target matrix.
+   * @param hyperparameters A sequence of hyperparameters in the form of symbol-value pairs.
+   * @return A `CochraneOrcuttModel` instance containing the fitted model.
+   */
   def fit(drmFeatures: DrmLike[K], drmTarget: DrmLike[K], hyperparameters: (Symbol, Any)*): CochraneOrcuttModel[K] = {
 
     setHyperparameters(hyperparameters.toMap[Symbol, Any])
@@ -148,4 +188,4 @@ class CochraneOrcutt[K](hyperparameters: (Symbol, Any)*)  extends LinearRegresso
     finalModel
   }
 
-}
\ No newline at end of file
+}