Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(blog): convert case to cases in blog posts #10560

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading