GradientDescentLinearRegression
public class GradientDescentLinearRegression : LinearRegression
Gradient Descent linear regression.
Reference: “linear regression using gradient descent”
-
The number of iterations for gradient descent.
Declaration
Swift
var iterationCount: Int
-
The linear rate gradient descent.
Declaration
Swift
var learningRate: Float
-
Whether to calculate the intercept for this model.
Declaration
Swift
public var fitIntercept: Bool
-
The weights of the model.
Declaration
Swift
public var weights: Tensor<Float>
-
Creates a linear regression model.
Declaration
Swift
public init( iterationCount: Int = 1000, learningRate: Float = 0.001, fitIntercept: Bool = true )
Parameters
iterationCount
The number of iterations for gradient descent. The default is
1000
.learningRate
The learning rate for gradient descent. The default is
0.001
.fitIntercept
Whether to calculate the intercept for this model. If
false
, no intercept will be used in calculations. The default istrue
. -
Initialize weights between
[-1/N, 1/N]
.Declaration
Swift
internal func initializeWeights(featuresCount: Int)
Parameters
featuresCount
The number of features in training data.
-
Fit a linear model.
Declaration
Swift
public func fit(data: Tensor<Float>, labels: Tensor<Float>)
Parameters
data
Training data with shape
[sample count, feature count]
.labels
Target value with shape
[sample count, target count]
.