在以下直方图中对分级值进行着色时遇到问题。我打算对 x 轴(信用度)上小于 50 的所有条形进行着色。在 Altair 中这是如何完成的?
base = alt.Chart(X_train)
histogram = base.mark_bar().encode(
alt.X('Creditworthiness', bin=True),
y='count()',
color=alt.condition(
alt.datum.Creditworthiness < 50,
alt.value("steelblue"), # The positive color
alt.value("orange") # The negative color
)
)
threshold_line = pd.DataFrame([{"threshold": max_profit_threshold}])
mark = alt.Chart(threshold_line).mark_rule(color="#e45755").encode(
x='threshold:Q',
size=alt.value(2)
)
histogram + mark
Run Code Online (Sandbox Code Playgroud)
我被告知下面的代码是= O(MN)然而,我想出了O(N ^ 2).这是正确的答案,为什么?
我的思维过程:嵌套for循环加上if语句 - >(O(N ^ 2)+ O(1))+(O(N ^ 2)+ O(1))= O(N ^ 2)
谢谢
public static void zeroOut(int[][] matrix) {
int[] row = new int[matrix.length];
int[] column = new int[matrix[0].length];
// Store the row and column index with value 0
for (int i = 0; i < matrix.length; i++)
{
for (int j = 0; j < matrix[0].length;j++) {
if (matrix[i][j] == 0)
{
row[i] = 1;
column[j] = 1;
}
}
}
// Set arr[i][j] to …Run Code Online (Sandbox Code Playgroud)