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
iterationCountThe number of iterations for gradient descent. The default is
1000.learningRateThe learning rate for gradient descent. The default is
0.001.fitInterceptWhether 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
featuresCountThe number of features in training data.
-
Fit a linear model.
Declaration
Swift
public func fit(data: Tensor<Float>, labels: Tensor<Float>)Parameters
dataTraining data with shape
[sample count, feature count].labelsTarget value with shape
[sample count, target count].
GradientDescentLinearRegression Class Reference