本文簡要介紹
pyspark.mllib.util.MLUtils.saveAsLibSVMFile
的用法。用法:
static saveAsLibSVMFile(data, dir)
以 LIBSVM 格式保存標記數據。
1.0.0 版中的新函數。
- data:
pyspark.RDD
要保存的 RDD LabeledPoint
- dir:str
保存數據的目錄
- data:
參數:
例子:
>>> from tempfile import NamedTemporaryFile >>> from fileinput import input >>> from pyspark.mllib.regression import LabeledPoint >>> from glob import glob >>> from pyspark.mllib.util import MLUtils >>> examples = [LabeledPoint(1.1, Vectors.sparse(3, [(0, 1.23), (2, 4.56)])), ... LabeledPoint(0.0, Vectors.dense([1.01, 2.02, 3.03]))] >>> tempFile = NamedTemporaryFile(delete=True) >>> tempFile.close() >>> MLUtils.saveAsLibSVMFile(sc.parallelize(examples), tempFile.name) >>> ''.join(sorted(input(glob(tempFile.name + "/part-0000*")))) '0.0 1:1.01 2:2.02 3:3.03\n1.1 1:1.23 3:4.56\n'
相關用法
- Python pyspark MLUtils.loadLibSVMFile用法及代碼示例
- Python pyspark MLUtils.convertMatrixColumnsToML用法及代碼示例
- Python pyspark MLUtils.convertMatrixColumnsFromML用法及代碼示例
- Python pyspark MLUtils.convertVectorColumnsToML用法及代碼示例
- Python pyspark MLUtils.convertVectorColumnsFromML用法及代碼示例
- Python pyspark MLUtils.loadLabeledPoints用法及代碼示例
- Python pyspark MultiIndex.size用法及代碼示例
- Python pyspark MultiIndex.hasnans用法及代碼示例
- Python pyspark MultiIndex.to_numpy用法及代碼示例
- Python pyspark MultiIndex.levshape用法及代碼示例
- Python pyspark MinHashLSH用法及代碼示例
- Python pyspark MultiIndex.max用法及代碼示例
- Python pyspark MultiIndex.drop用法及代碼示例
- Python pyspark MultiIndex.min用法及代碼示例
- Python pyspark MultiIndex.unique用法及代碼示例
- Python pyspark MultiIndex.rename用法及代碼示例
- Python pyspark MultiIndex.value_counts用法及代碼示例
- Python pyspark MatrixFactorizationModel用法及代碼示例
- Python pyspark MultiIndex.values用法及代碼示例
- Python pyspark MultiIndex.difference用法及代碼示例
- Python pyspark MultiIndex.sort_values用法及代碼示例
- Python pyspark MultiIndex.spark.transform用法及代碼示例
- Python pyspark MaxAbsScaler用法及代碼示例
- Python pyspark MultiIndex.T用法及代碼示例
- Python pyspark MultiIndex用法及代碼示例
注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.mllib.util.MLUtils.saveAsLibSVMFile。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。