KNeighborsRegressor
public class KNeighborsRegressorK neighbors regressor.
The target is predicted by local interpolation of the targets associated of the nearest neighbors in the training set.
- 
                  
                  The order of the norm of the difference: ||a - b||_p.DeclarationSwift var p: Int
- 
                  
                  Weight function used in prediction. DeclarationSwift public var weights: String
- 
                  
                  Number of neighbors. DeclarationSwift var neighborCount: Int
- 
                  
                  The training data. DeclarationSwift var data: Tensor<Float>
- 
                  
                  The target value correspoing to training data. DeclarationSwift var labels: Tensor<Float>
- 
                  
                  Create a K neighbors regressor model. DeclarationSwift public init( neighborCount: Int = 5, weights: String = "distance", p: Int = 2 )ParametersneighborCountNumber of neighbors to use, default to 5.weightsWeight function used in prediction. Possible values uniform- uniform weighted,distance- weight point by inverse of their distance. Default set todistance.pThe order of the norm of the difference: ||a - b||_p, default set to2.
- 
                  
                  Fit a K-neighbors regressor model. DeclarationSwift public func fit(data: Tensor<Float>, labels: Tensor<Float>)ParametersdataTraining data with shape [sample count, feature count].labelsTarget value with shape [sample count].
- 
                  
                  Returns the average value of target. DeclarationSwift internal func computeWeights( distances: Tensor<Float>, labels: Tensor<Float> ) -> Tensor<Float>ParametersdistancesContains the distance between test data and top neighbors. labelsContains the value of target. 
- 
                  
                  Returns the individual predicted value. DeclarationSwift internal func predictSingleSample(_ test: Tensor<Float>) -> Tensor<Float>ParametersdataInput data to be regressed. Return ValuePredicted target value. 
- 
                  
                  Returns predicted values. DeclarationSwift public func prediction(for data: Tensor<Float>) -> Tensor<Float>ParametersdataTest data with shape [sample count, feature count].Return ValuePredicted value tensor. 
- 
                  
                  Returns the coefficient of determination ( R^2) of the prediction.DeclarationSwift public func score(data: Tensor<Float>, labels: Tensor<Float>) -> FloatParametersdataSample data with shape [sample count, feature count].labelsTarget values with shape [sample count].Return ValueThe coefficient of determination ( R^2) of the prediction.
 KNeighborsRegressor Class Reference
      KNeighborsRegressor Class Reference