基於不同變數的混淆矩陣顏色和計數你好,
我正在使用圖形生成器製作混淆矩陣。 我有兩列,一列是已知類別(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 ) )
)}
)
)
);