Functions
The following functions are available globally.
-
Creates a subset Random DataSet where all examples have a specific feature value | Helper Function
Declaration
Swift
public func createRandomDataSet(randomFeature: RandomFeature, featureValue: FeatureValue, data: [[String]], target: Int) -> RandomDataSet
Parameters
feature
feature we are targeting
featureValue
feature value desired
data
current data
target
col num for target var
Return Value
subset Random DataSet where all examples have the desired feature value
-
Deletes a column in a given 2D array | Helper function
Declaration
Swift
public func deleteColumn(data: [[String]], column: Int) -> [[String]]
Parameters
data
array from which column is to be deleted
column
col num to be deleted
Return Value
array with column deleted
-
Returns the column number for a given column name | Helper Function
Declaration
Swift
public func getColumnNumber(colName: String, data: [[String]]) -> Int
Parameters
colName
name of the feature at the column
data
array getting the col num from
Return Value
column number for the given column name
-
Creates a subset DataSet where all examples have a specific feature value | Helper Function
Declaration
Swift
public func createDataSet(feature: Feature, featureValue: FeatureValue, data: [[String]], target: Int) -> DataSet
Parameters
feature
feature we are targeting
featureValue
feature value desired
data
current data
target
col num for target var
Return Value
subset DataSet where all examples have the desired feature value
-
Splits a given dataset into two at a index | Helper Function
Declaration
Swift
public func splitDataSet(data: [[String]], startIndex: Int) -> ([[String]], [[String]])
Parameters
data
data tp be split
startIndex
split index - value included in second dataset returned
Return Value
Two string arrays split from original arrayß
-
Returns deterministic SVD contains sign-corrected versions of left singular vectors and right singular vectors from input matrix.
Reference: “Determinitic SVD”
Declaration
Swift
public func deterministicSvd<T: FloatingPoint & TensorFlowScalar>( _ input: Tensor<T>, columnBasedSignFlipping: Bool = true ) -> (s: Tensor<T>, u: Tensor<T>, v: Tensor<T>)
Parameters
input
The input matrix.
Return Value
The sign corrected svd to ensure deterministic output.
-
Returns the Minkowski distance between two tensors for the given distance metric
p
.Reference: “Minkowski distance”
Declaration
Swift
public func minkowskiDistance<Scalar: TensorFlowFloatingPoint>( _ a: Tensor<Scalar>, _ b: Tensor<Scalar>, p: Int ) -> Tensor<Scalar>
Parameters
a
The first tensor.
b
The second tensor.
p
The order of the norm of the difference:
||a - b||_p
.Return Value
The Minkowski distance based on value of
p
. -
Returns the Euclidean distance between two tensors.
Reference: “Euclidean distance”
Declaration
Swift
public func euclideanDistance<Scalar: TensorFlowFloatingPoint>( _ a: Tensor<Scalar>, _ b: Tensor<Scalar> ) -> Tensor<Scalar>
Parameters
a
The first tensor.
b
The second tensor.
Return Value
The Euclidean distance:
||a - b||_2
.