[Pharo-dev] Similarity Matrix

Alexandre Bergel alexandre.bergel at me.com
Sun Dec 15 11:30:21 EST 2013


Hi Hernan,

In that case, I suggest you to define your own builder to build the matrix you need.
I have given a try, but I cannot properly parse your data. The problem is about separating column (is it 4 or 5 white spaces?). Having a “,” would help.

I gave a try, as you can see with the script below. It produces the following:



Each box gives its value when the mouse is above.

-=-=-=  -=-=-=  -=-=-=  -=-=-=  -=-=-=  
| view f blockSize shape values el |
values := '     a1    a2    a3    a4    a5    a6    a7    a8    a9    a10    a11    a12    a13    a14    a15    a16    a17    a18    a19    a20    a21
a1    1    0.130    0.132    0.130    0.158    0.189    0.130    0.022    1.000    0.062    0.083    0.061    0.080    0.059    0.149    1.000    0.098    0.161    0.109    1.000       
a2         1    0.195    0.487    0.220    0.220    1.000    0.060    0.130    0.118    0.234    0.234    0.224    0.200    0.622    0.130    0.342    0.235    0.425    0.130    0.000    
a3              1    0.195    0.464    0.464    0.195    0.073    0.132    0.116    0.114    0.256    0.109    0.085    0.133    0.132    0.105    0.320    0.171    0.132    0.000    
a4                   1    0.220    0.190    0.487    0.060    0.130    0.118    0.160    0.234    0.154    0.132    0.395    0.130    0.342    0.235    0.425    0.130    0.000    
a5                        1    0.500    0.220    0.071    0.158    0.195    0.220    0.389    0.209    0.182    0.156    0.158    0.162    0.417    0.225    0.158    0.000    
a6                             1    0.220    0.071    0.189    0.114    0.136    0.282    0.130    0.106    0.156    0.189    0.132    0.360    0.167    0.189    0.000    
a7                                  1    0.060    0.130    0.118    0.234    0.234    0.224    0.200    0.622    0.130    0.342    0.235    0.425    0.130    0.000    
a8                                       1    0.022    0.156    0.104    0.082    0.100    0.100    0.019    0.022    0.095    0.088    0.061    0.022    0.028    
a9                                            1    0.062    0.083    0.061    0.080    0.059    0.149    1.000    0.098    0.161    0.109    1.000    0.000    
a10                                                 1    0.541    0.140    0.372    0.283    0.073    0.062    0.111    0.139    0.143    0.062    0.025    
a11                                                      1    0.160    0.714    0.579    0.176    0.083    0.133    0.200    0.163    0.083    0.024    
a12                                                           1    0.154    0.132    0.176    0.061    0.308    0.235    0.239    0.061    0.000    
a13                                                                1    0.676    0.170    0.080    0.128    0.189    0.157    0.080    0.023    
a14                                                                     1    0.148    0.059    0.128    0.158    0.135    0.059    0.023   
a15                                                                          1    0.149    0.262    0.158    0.341    0.149    0.000    
a16                                                                               1    0.098    0.161    0.109    1.000    0.000    
a17                                                                                    1    0.207    0.316    0.098    0.000    
a18                                                                                         1    0.206    0.161    0.000    
a19                                                                                              1    0.109    0.000    
a20                                                                                                   1    0.000    
a21                                                                                                        1    
' lines collect: [ : line | line trimBoth findTokens: '    ' ].


blockSize := 10.
view := ROView new.
values do: [ :lineOfValues |
	lineOfValues do: [ :v | 
		shape := ROBox new size: blockSize; color: Color white.
		f := [Float readFrom: v readStream] ifError: [ -1 ].
		f >= 0  
			ifTrue: [ shape color: (Color gray: f) ].
		el := shape elementOn: f.
		el @ ROPopup.
		view add: el
	].

	"We fill the remaining of the line with white boxes. 
	 We need to have the same amount of boxes for all the lines"
	(values first size - lineOfValues size)
		timesRepeat: [ view add: (ROBox new color: Color white) element ].
  
].
ROGridLayout new gapSize: 0; lineItemsCount: (values first size); on: view elements.
view open.
-=-=-=  -=-=-=  -=-=-=  -=-=-=  -=-=-=  

 


Cheers,
Alexandre




On Dec 15, 2013, at 12:56 AM, Hernán Morales Durand <hernan.morales at gmail.com> wrote:

> Hi Alexandre,
> 
> Just to provide you some feedback. My similarity matrices sometimes are calculated by other tools. However I want to display them using Roassal. For example this is a similarity matrix of 21 lines and 21 columns:
> 
> '     a1    a2    a3    a4    a5    a6    a7    a8    a9    a10    a11    a12    a13    a14    a15    a16    a17    a18    a19    a20    a21
> a1    1    0.130    0.132    0.130    0.158    0.189    0.130    0.022    1.000    0.062    0.083    0.061    0.080    0.059    0.149    1.000    0.098    0.161    0.109    1.000    0.000    
> a2         1    0.195    0.487    0.220    0.220    1.000    0.060    0.130    0.118    0.234    0.234    0.224    0.200    0.622    0.130    0.342    0.235    0.425    0.130    0.000    
> a3              1    0.195    0.464    0.464    0.195    0.073    0.132    0.116    0.114    0.256    0.109    0.085    0.133    0.132    0.105    0.320    0.171    0.132    0.000    
> a4                   1    0.220    0.190    0.487    0.060    0.130    0.118    0.160    0.234    0.154    0.132    0.395    0.130    0.342    0.235    0.425    0.130    0.000    
> a5                        1    0.500    0.220    0.071    0.158    0.195    0.220    0.389    0.209    0.182    0.156    0.158    0.162    0.417    0.225    0.158    0.000    
> a6                             1    0.220    0.071    0.189    0.114    0.136    0.282    0.130    0.106    0.156    0.189    0.132    0.360    0.167    0.189    0.000    
> a7                                  1    0.060    0.130    0.118    0.234    0.234    0.224    0.200    0.622    0.130    0.342    0.235    0.425    0.130    0.000    
> a8                                       1    0.022    0.156    0.104    0.082    0.100    0.100    0.019    0.022    0.095    0.088    0.061    0.022    0.028    
> a9                                            1    0.062    0.083    0.061    0.080    0.059    0.149    1.000    0.098    0.161    0.109    1.000    0.000    
> a10                                                 1    0.541    0.140    0.372    0.283    0.073    0.062    0.111    0.139    0.143    0.062    0.025    
> a11                                                      1    0.160    0.714    0.579    0.176    0.083    0.133    0.200    0.163    0.083    0.024    
> a12                                                           1    0.154    0.132    0.176    0.061    0.308    0.235    0.239    0.061    0.000    
> a13                                                                1    0.676    0.170    0.080    0.128    0.189    0.157    0.080    0.023    
> a14                                                                     1    0.148    0.059    0.128    0.158    0.135    0.059    0.023    
> a15                                                                          1    0.149    0.262    0.158    0.341    0.149    0.000    
> a16                                                                               1    0.098    0.161    0.109    1.000    0.000    
> a17                                                                                    1    0.207    0.316    0.098    0.000    
> a18                                                                                         1    0.206    0.161    0.000    
> a19                                                                                              1    0.109    0.000    
> a20                                                                                                   1    0.000    
> a21                                                                                                        1    
> ' lines collect: [ : line | line trimBoth findTokens: Character tab ]
> 
> May be your Comparison class could be tailored to set manually rhs, lhs and similarity? What do you recommend for raw matrices?
> 
> Cheers,
> 
> Hernán
> 
> 
> 
> 2013/11/29 Alexandre Bergel <alexandre.bergel at me.com>
> Hi!
> 
> I know some of you are working on DSM-kind of matrix. Oscar has been working on a similarity matrix for Roassal. I just want to share a self-explanble screenshot with you guys.
> 
> 
> On this example, the methods of the subclasses of Set are compared between themselves.
> Black dot is a couple (m1, m2) that are very similar
> <Screen Shot 2013-11-29 at 6.12.39 PM.png>
> 
> More on https://www.facebook.com/media/set/?set=a.550677725018829.1073741833.340543479365589&type=1
> 
> Cheers,
> Alexandre
> -- 
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
> 
> 
> 
> 

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131215/42d1bf6e/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2013-12-15 at 5.29.24 PM.png
Type: image/png
Size: 9219 bytes
Desc: not available
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131215/42d1bf6e/attachment.png>


More information about the Pharo-dev mailing list