Array

public extension Array
public extension Array where Element == Feature
extension Array: FloatData where Element == Float
extension Array: Int32Data where Element == Int32
extension Array: UInt32Data where Element == UInt32
public extension Array where Element: AdditiveArithmetic
public extension Array where Element: FloatingPoint
public extension Array where Element == AfterIterationOutput
public extension Array where Element: NumpyScalarCompatible
  • Declaration

    Swift

    func chunked(into chunks: Int) -> [[Element]]

    Parameters

    into

    Number of chunks.

    Return Value

    Self splitted into n equally sized chunks.

Available where Element == Feature

  • Save feature map compatible with XGBoost`s inputs.

    Declaration

    Swift

    func saveFeatureMap(to path: String) throws

    Parameters

    to

    Path where feature map will be saved.

  • Load previously saved feature map.

    Declaration

    Swift

    init(fromFeatureMap path: String) throws

    Parameters

    from

    Path to the feature map.

Available where Element == Float

  • Declaration

    Swift

    public func data() throws -> [Float]

    Return Value

    self

Available where Element == Int32

  • Declaration

    Swift

    public func data() throws -> [Int32]

    Return Value

    self

Available where Element == UInt32

  • Declaration

    Swift

    public func data() throws -> [UInt32]

    Return Value

    self

Available where Element: AdditiveArithmetic

  • Declaration

    Swift

    func diff() -> [Element]

    Return Value

    Array calucated from self as [self[i + 1] - self[i]] for i = 0 ..< count - 1.

Available where Element: FloatingPoint

  • Declaration

    Swift

    func sum(
        from initialValue: Element = 0
    ) -> Element

    Parameters

    from

    Initial value for sum.

    Return Value

    Sum of elements.

  • Declaration

    Swift

    func mean(
        sum: Element? = nil
    ) -> Element

    Parameters

    sum

    Precalculated sum.

    Return Value

    Mean of elements.

  • Declaration

    Swift

    func std(
        sum: Element? = nil,
        mean: Element? = nil,
        ddof: Int = 0
    ) -> Element

    Parameters

    sum

    Precalculated sum.

    mean

    Precalculated mean.

    ddof

    DDOF.

    Return Value

    STD of elements.

Available where Element == AfterIterationOutput

Available where Element: NumpyScalarCompatible

  • Precondition

    The numpy Python package must be installed.

    Declaration

    Swift

    func makeNumpyArray(shape: Shape) -> PythonObject

    Return Value

    Numpy array of shape.