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) -> RandomDataSetParameters
featurefeature we are targeting
featureValuefeature value desired
datacurrent data
targetcol 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
dataarray from which column is to be deleted
columncol 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]]) -> IntParameters
colNamename of the feature at the column
dataarray 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) -> DataSetParameters
featurefeature we are targeting
featureValuefeature value desired
datacurrent data
targetcol 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
datadata tp be split
startIndexsplit 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
inputThe 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
aThe first tensor.
bThe second tensor.
pThe 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
aThe first tensor.
bThe second tensor.
Return Value
The Euclidean distance:
||a - b||_2.
Functions Reference