Fit class probabilities for device alerts
Use grouped holdouts to inspect classification probabilities and log loss.
import aner.data
import aner.ml
import aner.tensor
let table = data.scan_csv_auto("examples/fixtures/contextual/logistic_observations.csv").collect()
let study = data.frame(table, row_id: "row_id", group: "device", target: "alert",
units: List("", "", "m", "1"))
let parts = study.partition_groups(train: List("A", "B"), validation: List("C"), test: List("D"))
let plan = ml.logistic(alpha: 0.5)
let folds = plan.cross_validate(parts.train(), folds: 2, seed: 42)
let model = plan.fit(parts.train())
let probabilities = model.predict_proba(parts.test())
print(folds)
print(model.evaluate(parts.test()))
print(probabilities.row_id(0))
print(probabilities.values().value(0, 0))
Make it your experiment.
Use Aner 0.1.0 or newer. Save this program as examples/logistic_alerts.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/logistic_alerts.aner
aner run examples/logistic_alerts.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.1.0 or newer. Requires Aner 0.0.9 or newer. The example uses CPU Float64 and a synthetic CSV fixture. Run it from a writable project directory. Save each supplied fixture beneath the exact examples/fixtures path shown in the source and run from the project root.
aner check examples/logistic_alerts.aner
aner run examples/logistic_alerts.anerlogistic_observations.csv Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution