使用J创建散点图矩阵

问题描述 投票:3回答:1

我正在命令行上进行一些数据科学,并发现J是用于基本分析(统计)任务的便捷工具。在几年前对这种语言有了一些初步的了解之后,我不得不重新开始使用。能够为我现在所处的位置获得帮助将非常棒。

我有一组测量的属性,想以视觉方式显示相关性。该视图通常称为散点图矩阵,一个很好的例子是here。我认为可以使用其出色的绘图库在J中创建类似的图形。

到目前为止我所做的:

NB. For sake of brevity, my test data is simulated here comprising 4 attributes with 7 measurements:
   ]A=:i. 7 4
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27

NB. With the aid of a sparse matrix I created the index matrix of the multiplot matrix/layout
   ]Idx=: 4 $. $. 4 4$1
0 0
0 1
0 2
0 3
1 0
1 1
1 2
1 3
2 0
2 1
2 2
2 3
3 0
3 1
3 2
3 3

NB. Creating a single plot work fine with this sentence, here showing attribute 1 vs 3.
'TYPE marker' plot 1 1 <;.1 |: 3 1 {"1 A

NB. And here is my failed approach for creating a (multiplot) scatterplot matrix
   pd 'multi 4 4'
   3 : 0''
for_ijk. Idx do.
pd 1 1 <;.1 |: ijk {"1 A
end.
)
   pd 'show'

首先,在J中通过循环执行此操作感觉不对。是否有更好的方法为每个图元素注入索引?

第二,循环无法正确地将数据馈送到绘图(pd),但是我找不到一种将所有结果附加到大矩阵上而仅将其馈送到pd的方法。

任何想法都非常受欢迎!提前非常感谢。

我正在命令行上进行一些数据科学,并发现J是用于基本分析(统计)任务的便捷工具。在几年前对这种语言有了初步的了解之后,我不得不...

plot j
1个回答
2
投票

您的方法很好,据我所知,pd-multi一次需要将所有数据作为2元素列表的装箱清单:

© www.soinside.com 2019 - 2024. All rights reserved.