How can I get MLDataColumn from MLDataTable

I want to get a column mean,MLDataColumn has a function to calculate the mean。But the value obtained directly using the subscript access is MLUntypedColumn.(我想要获取一列的均值,MLDataColumn有一个方法可以计算均值,但是直接使用下标访问得到的是MLUntypedColumn)
The definition of the subscript is(下标引用方法的定义是):

/// Subscript by column name. Returns an invalid UntypedColumn if the DataTable does not contain the name.
    public subscript(columnName: String) -> CreateML.MLUntypedColumn

    /// Subscript by column name. Returns an invalid DataColumn if the DataTable does not contain the name.
    public subscript<Element>(columnName: String) -> CreateML.MLDataColumn<Element> where Element : MLDataValueConvertible

    /// Subscript by column name and type. Returns nil if no column has the given name or if the
    /// named column does not have the given type.
    public subscript<T>(columnName: String, columnType: T.Type) -> CreateML.MLDataColumn<T>? where T : MLDataValueConvertible { get }

    /// Subscript by the list of column names. Returns a DataTable with the specified columns
    public subscript<S>(columnNames: S) -> CreateML.MLDataTable where S : Sequence, S.Element == String { get }

I used xx["xx"] directly to call the first function.How to write the second reload function(我直接使用xx["xx"]这个使用的是第一个函数,我想要使用第二个重载函数应该怎么写).

Thanks.

直接使用 xxx["xxx"].ints或者 xxx["xxx"].strings就可获得到对于数据的MLDataColumn

Terms of Service

Privacy Policy

Cookie Policy