Skip to content

Commit

Permalink
docs(blog): convert case to cases in blog posts
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Dec 6, 2024
1 parent 0721d11 commit 2e92e20
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
12 changes: 5 additions & 7 deletions docs/posts/classification-metrics-on-the-backend/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ We can use the `case` function to create a new column that categorizes the outco

```{python}
case_expr = (
ibis.case()
.when((_.actual == 0) & (_.prediction == 0), "TN")
.when((_.actual == 0) & (_.prediction == 1), "FP")
.when((_.actual == 1) & (_.prediction == 0), "FN")
.when((_.actual == 1) & (_.prediction == 1), "TP")
.end()
case_expr = ibis.cases(
((_.actual == 0) & (_.prediction == 0), "TN"),
((_.actual == 0) & (_.prediction == 1), "FP"),
((_.actual == 1) & (_.prediction == 0), "FN"),
((_.actual == 1) & (_.prediction == 1), "TP"),
)
t = t.mutate(outcome=case_expr)
Expand Down
63 changes: 34 additions & 29 deletions docs/posts/ibis-bench/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -278,51 +278,56 @@ type, number of cores, and memory in gigabytes:
```{python}
#| code-fold: true
#| code-summary: "Show code to get instance details"
cpu_type_cases = (
ibis.case()
.when(
cpu_type_cases = ibis.cases(
(
ibis._["instance_type"].startswith("n2d"),
"AMD EPYC",
)
.when(
),
(
ibis._["instance_type"].startswith("n2"),
"Intel Cascade and Ice Lake",
)
.when(
),
(
ibis._["instance_type"].startswith("c3"),
"Intel Sapphire Rapids",
)
.when(
),
(
ibis._["instance_type"] == "work laptop",
"Apple M1 Max",
)
.when(
),
(
ibis._["instance_type"] == "personal laptop",
"Apple M2 Max",
)
.else_("unknown")
.end()
),
else_="unknown",
)
cpu_num_cases = (
ibis.case()
.when(
cpu_num_cases = ibis.cases(
(
ibis._["instance_type"].contains("-"),
ibis._["instance_type"].split("-")[-1].cast("int"),
)
.when(ibis._["instance_type"].contains("laptop"), 12)
.else_(0)
.end()
),
(
ibis._["instance_type"].contains("laptop"),
12,
),
else_=0,
)
memory_gb_cases = (
ibis.case()
.when(
memory_gb_cases = ibis.cases(
(
ibis._["instance_type"].contains("-"),
ibis._["instance_type"].split("-")[-1].cast("int") * 4,
)
.when(ibis._["instance_type"] == "work laptop", 32)
.when(ibis._["instance_type"] == "personal laptop", 96)
.else_(0)
.end()
),
(
ibis._["instance_type"] == "work laptop",
32,
),
(
ibis._["instance_type"] == "personal laptop",
96,
),
else_=0,
)
instance_details = (
Expand Down

0 comments on commit 2e92e20

Please sign in to comment.