Click or drag to resize
sqx

SQXVisualizeMatrixTableFromQuery Method

Procedure VisualizeMatrixTableFromQuery [nvarchar](max) @Query, [bit] @OrderByMax

Namespace:  sqx
Assembly:  SQX (in SQX.dll) Version: 1.0.2.6 (1.0.2.6)
Syntax
C#
public static int VisualizeMatrixTableFromQuery(
	SqlChars Query,
	SqlBoolean OrderByMax
)

Parameters

Query
Type: System.Data.SqlTypesSqlChars
[nvarchar](max)
OrderByMax
Type: System.Data.SqlTypesSqlBoolean
[bit] 1 Order by Max | 0 Order by Min

Return Value

Type: Int32
[int] 0 success | -1 failure
Remarks
Visualize Matrix Table From Query is usefull to visualize Correlation or Mutual Information Matrices for feature selection. It returns the ID instead of value, sorted by value.

NOTE: Query must return a dataset with all the matrix columns with numeric data type, ID should be the first column.

NOTE: For small Datasets.
Examples
SQL
declare @Query nvarchar(max) = N'
select a.Value [1],b.Value [2],c.Value [3],d.Value [4]
from sqx.VectorTable(sqx.RandomVector(10,1)) a
inner join sqx.VectorTable(sqx.RandomVector(10,2)) b ON a.ID = b.ID
inner join sqx.VectorTable(sqx.RandomVector(10,3)) c ON a.ID = c.ID
inner join sqx.VectorTable(sqx.RandomVector(10,4)) d ON a.ID = d.ID
'
declare @R sqx.Matrix
exec sqx.CorrelationMatrix @Query = @Query
    , @Population = 1, @SnapShot = 0, @CorrelationMatrix = @R OUTPUT
drop table if exists #tmpmatrix;
create table #tmpmatrix 
(ID int not null primary key,
[1] float,[2] float,[3] float,[4] float)
insert #tmpmatrix
exec sqx.MatrixToTable @R
set @Query = 'select ID,[1],[2],[3],[4] from #tmpmatrix'
select * from #tmpmatrix
exec sqx.VisualizeMatrixTableFromQuery @Query, 1
drop table if exists #tmpmatrix;
/*
ID          1                      2                      3                      4
----------- ---------------------- ---------------------- ---------------------- ------------------
1           1                      0.0171373794175597     0.258705024392653      -0.431665058767189
2           0.0171373794175597     1                      -0.394987971874921     0.233818402745601
3           0.258705024392653      -0.394987971874921     1                      0.129561546992729
4           -0.431665058767189     0.233818402745601      0.129561546992729      1

Position    ByMax1      ByMax2      ByMax3      ByMax4
----------- ----------- ----------- ----------- -----------
1           1           2           3           4
2           3           4           1           2
3           2           1           4           3
4           4           3           2           1*/
See Also