基于不同变量的混淆矩阵颜色和计数你好,
我正在使用图形生成器制作混淆矩阵。 我有两列,一列是已知类别(y 轴),另一列是预测类别(x 轴)。 我希望方框内的数字显示每个方框中的样本数量。 如下图所示。

但是,我希望主对角线(真阳性)为一种颜色,而其余框为不同颜色,而不是颜色渐变图。 我有一列为 1 或 0,具体取决于样本是否为真阳性,但是当我将此列添加到图形生成器中的颜色选项时,会发生这种情况:

有没有办法让我拥有第二张图片中的颜色,但拥有第一张图片的标签?
谢谢你!
大规模定制回复:基于不同变量的混淆矩阵颜色和计数抱歉,我错过了保存该步骤。我又在这里先总结表格,然后使用行标签而不是计数来绘制图表,但这次我实际上定义了行标签:

Names Default To Here( 1 );
dt = Open( "$Sample_data/big class.jmp" );
random reset(2);
dt << New Column("Age 2", Numeric, "Ordinal", Format("Fixed Dec", 5, 0), Formula(:age[Col Shuffle()]));
dt << Run Formulas;
dt:age << Set Name("Age 1");
dtSum = (sum = dt << Tabulate(
Add Table(
Column Table( Statistics( N ) ),
Row Table( Grouping Columns( :"Age 2"n, :"Age 1"n ) )
)
)) << Make Into Data Table;
dtSum << New Column("Is Diagonal", Numeric, "Nominal", Format("Best", 12), Formula(:Age 1 == :Age 2));
dtSum:N << Label( 1 );
gb = dtSum << Graph Builder(
Size( 525, 450 ),
Show Control Panel( 0 ),
Variables( X( :Age 1 ), Y( :Age 2 ), Color( :Is Diagonal ) ),
Elements( Heatmap( X, Y, Legend( 5 ), Label( "Label by Row" ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
5,
Properties( 0, {Fill Color( -15790017 )}, Item ID( "0", 1 ) ),
Properties( 1, {Fill Color( 5 )}, Item ID( "1", 1 ) )
)}
)
)
);
回复:基于不同变量的混淆矩阵颜色和计数感谢您的回答,但我认为这没有给出正确的解决方案,请参见下文:

左边显示应该显示的实际值,右边是脚本提供的结果。
回复:基于不同变量的混淆矩阵颜色和计数您可以先总结表格,然后使用行标签而不是计数来绘制图表:

Names Default To Here( 1 );
dt = Open( "$Sample_data/big class.jmp" );
<BR />random reset(2);
dt << New Column("Age 2", Numeric, "Ordinal", Format("Fixed Dec", 5, 0), Formula(:age[Col Shuffle()]));
dt:age << Set Name("Age 1");
dtSum = (dt << Tabulate(
Add Table(
Column Table( Statistics( N ) ),
Row Table( Grouping Columns( :"Age 2"n, :"Age 1"n ) )
)
)) << Make Into Data Table;
dtSum << New Column("Is Diagonal", Numeric, "Nominal", Format("Best", 12), Formula(:Age 1 == :Age 2));
dtSum << Graph Builder(
Size( 525, 450 ),
Show Control Panel( 0 ),
Variables( X( :Age 1 ), Y( :Age 2 ), Color( :Is Diagonal ) ),
Elements( Heatmap( X, Y, Legend( 5 ), Label( "Label by Row" ) ) ),
SendToReport(
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
5,
Properties( 0, {Fill Color( -15790017 )}, Item ID( "0", 1 ) ),
Properties( 1, {Fill Color( 5 )}, Item ID( "1", 1 ) )
)}
)
)
);