---
title: Spearman
description: "| 模型接口类别 | 函数接口 |"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2200/bds/kunpengbdssparkml_16_0027.html
sourcePath: /source/zh/kunpengboostkithistory/2200/bds/kunpengbdssparkml_16_0027.html
indexId: 70f1cf564b049afc9e0f82c3641395ad1bd26e35c0d6bd2377a0416d0b0dda3d73
---
# Spearman

| 模型接口类别 | 函数接口 |
| --- | --- |
| ML API | def corr(dataset: Dataset[\_], column: String, method: String): DataFrame |


#### ML API

- 功能描述
  传入Dataset格式的样本数据，调用fitPredict接口，输出聚类结果。


- 输入输出

  1. 包名：org.apache.spark.ml.stat
  2. 类名：Correlation
  3. 方法名：corr
  4. 输入：Dataset[_]，训练样本数据，必须字段如下| 参数名称 | 取值类型 | 描述 |
| --- | --- | --- |
| data | Dataset[Vector] | 矩阵，以行为单位进行存储。 |
| column | String | 指定进行列进行相关矩阵计算。 |
| method | String | 相关矩阵方法，可以选择spearman。 |


  5. 算法参数| 参数名称 | 取值类型 | 缺省值 | 描述 |
| --- | --- | --- | --- |
| method | String | pearson | 求解相关矩阵的方法 |


    代码接口示例： 1 val mat_df = ml.stat.Correlation.corr(data,"matrix", method = "spearman")

  6. 输出：Pearson相关矩阵Matrix| 参数名称 | 取值类型 | 描述 |
| --- | --- | --- |
| df | DataFrame | Spearman相关矩阵，列名为column+method。 |


- 使用样例

```
val mat = stat.Correlation.corr(data, "matrix", “spearman”)
```
