本文簡要介紹 python 語言中 scipy.io.arff.loadarff
的用法。
用法:
scipy.io.arff.loadarff(f)#
讀取 arff 文件。
數據以記錄數組的形式返回,可以像 NumPy 數組的字典一樣進行訪問。例如,如果其中一個屬性名為 ‘pressure’,則可以從
data
記錄數組訪問其前 10 個數據點,如下所示:data['pressure'][0:10]
- f: file-like 或 str
File-like 要讀取的對象,或要打開的文件名。
- data: 記錄數組
arff 文件的數據,可通過屬性名稱訪問。
- meta: scipy.io.arff.MetaData
包含有關 arff 文件的信息,例如屬性的名稱和類型、關係(數據集的名稱)等。
- ParseArffError
如果給定文件不是ARFF-formatted,則會引發此問題。
- NotImplementedError
ARFF 文件具有尚不支持的屬性。
參數 ::
返回 ::
拋出 ::
注意:
這個函數應該可以讀取大部分 arff 文件。未實現的函數包括:
日期類型屬性
字符串類型屬性
它可以讀取具有數字和名義屬性的文件。它無法讀取數據稀疏的文件(文件中的 {})。但是,此函數可以讀取缺少數據的文件(文件中的?),將數據點表示為 NaN。
例子:
>>> from scipy.io import arff >>> from io import StringIO >>> content = """ ... @relation foo ... @attribute width numeric ... @attribute height numeric ... @attribute color {red,green,blue,yellow,black} ... @data ... 5.0,3.25,blue ... 4.5,3.75,green ... 3.0,4.00,red ... """ >>> f = StringIO(content) >>> data, meta = arff.loadarff(f) >>> data array([(5.0, 3.25, 'blue'), (4.5, 3.75, 'green'), (3.0, 4.0, 'red')], dtype=[('width', '<f8'), ('height', '<f8'), ('color', '|S6')]) >>> meta Dataset: foo width's type is numeric height's type is numeric color's type is nominal, range is ('red', 'green', 'blue', 'yellow', 'black')
相關用法
- Python SciPy arff.MetaData用法及代碼示例
- Python SciPy interpolate.make_interp_spline用法及代碼示例
- Python SciPy stats.anderson用法及代碼示例
- Python SciPy ClusterNode.pre_order用法及代碼示例
- Python SciPy stats.iqr用法及代碼示例
- Python SciPy FortranFile.read_record用法及代碼示例
- Python SciPy ndimage.correlate用法及代碼示例
- Python SciPy special.exp1用法及代碼示例
- Python SciPy special.expn用法及代碼示例
- Python SciPy signal.czt_points用法及代碼示例
- Python SciPy interpolate.krogh_interpolate用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- Python SciPy distance.sokalmichener用法及代碼示例
- Python SciPy linalg.eigvalsh_tridiagonal用法及代碼示例
- Python SciPy linalg.cdf2rdf用法及代碼示例
- Python SciPy csc_array.diagonal用法及代碼示例
- Python SciPy fft.idctn用法及代碼示例
- Python SciPy linalg.LaplacianNd用法及代碼示例
- Python SciPy linalg.solve_circulant用法及代碼示例
- Python SciPy hierarchy.ward用法及代碼示例
- Python SciPy signal.chirp用法及代碼示例
- Python SciPy stats.genpareto用法及代碼示例
- Python SciPy ndimage.variance用法及代碼示例
- Python SciPy signal.residue用法及代碼示例
- Python SciPy linalg.polar用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.io.arff.loadarff。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。