RandomFeature

public class RandomFeature : Hashable

Undocumented

  • Undocumented

    Declaration

    Swift

    public var name: String
  • Undocumented

    Declaration

    Swift

    public var values: Set<FeatureValue>
  • Undocumented

    Declaration

    Swift

    public var entropy: Float?
  • Undocumented

    Declaration

    Swift

    public var giniImpurity: Float?
  • Initializer for Feature

    Declaration

    Swift

    public init(data: [[String]], column: Int)

    Parameters

    data

    2D string of data

    column

    column number of feature

    Return Value

    Feature

  • Returns most occuring featureValue

    Declaration

    Swift

    public func getDominantValue() -> FeatureValue

    Return Value

    FeatureValue

  • Returns standard deviation of continous target variable

    Declaration

    Swift

    public func getTargetStdDev(data: [[String]], target: Int) -> Float

    Parameters

    data

    string array of data

    target

    col num of target var

    Return Value

    standard deviation of target variable as Float

  • Computes info gain values for categorical feature/feature values

    Declaration

    Swift

    public func getInfoGainCategorical(data: [[String]], target: Int) -> (Float, Float)

    Parameters

    data

    string array of data

    target

    col num of target var

    Return Value

    • infoGain: from choosing the feature as float
    • featureEntropy: entropy of the feature as float

  • Computes info gain values for numerical feature/feature values

    Declaration

    Swift

    public func getInfoGainNumerical(data: [[String]], target: Int) -> (Float, RandomDataSet, RandomDataSet, Float)

    Parameters

    data

    string array of data

    target

    col num of target var

    Return Value

    • entropy: entropy of the feature
    • dataset1: dataset split part 1
    • dataset2: dataset split part 2
    • cutoff: for the dataset split

  • Computes gini impurity values for categorical feature/feature values

    Declaration

    Swift

    public func getGiniImpurityCategorical(data: [[String]], target: Int) -> Float

    Parameters

    data

    string array of data

    target

    col num of target var

    Return Value

    gini impurity of choosing feature as float

  • Computes gini impurity values for numerical feature/feature values

    Declaration

    Swift

    public func getGiniImpurityNumerical(data: [[String]], target: Int) -> (Float, RandomDataSet, RandomDataSet, Float)

    Parameters

    data

    string array of data

    target

    col num of target var

    Return Value

    • giniImpurity: gini impurity of the feature
    • dataset1: dataset split part 1
    • dataset2: dataset split part 2
    • cutoff: for the dataset split

  • Required == func for implementing Hashable

    Declaration

    Swift

    public static func == (lhs: RandomFeature, rhs: RandomFeature) -> Bool

    Parameters

    lhs

    feature on the left

    rhs

    feature on the right

    Return Value

    true if feature names is same else false

  • Empty required hash func for implementing Hashable

    Declaration

    Swift

    public func hash(into hasher: inout Hasher)