小编tko*_*leh的帖子

Altair 颜色分级值

在以下直方图中对分级值进行着色时遇到问题。我打算对 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)

在此输入图像描述

python data-visualization altair

4
推荐指数
1
解决办法
1336
查看次数

大哦符号O(NM)或(N ^ 2)

我被告知下面的代码是= 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)

java big-o loops for-loop

3
推荐指数
1
解决办法
4360
查看次数

标签 统计

altair ×1

big-o ×1

data-visualization ×1

for-loop ×1

java ×1

loops ×1

python ×1