Feature
public class Feature : Hashable
Undocumented
-
Feature Name
Declaration
Swift
public var name: String
-
Possible values for the feature
Declaration
Swift
public var values: Set<FeatureValue>
-
entropy of dataset if feature is chosen to grow tree
Declaration
Swift
public var entropy: Float?
-
gini impurity of dataset if feature is chosen to grow tree
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
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
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: Feature, rhs: Feature) -> 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)