logistic_model
Builtin index · Statistics & ML
result = logistic_model(X, y)
Input: X, y · Output: result
What it is
Binary logistic regression on an N-row, D-column X and a length-N 0/1 target y.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = logistic_model(X, y) | X —not documented yety —not documented yet | result Record | Returns a fitted model Record with .predict/.score, .score giving classification accuracy. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
Xc2 = randn(60, 2, seed = 63)
yc2 = zeros(60)
for i in 0 to 59
if Xc2[i, 0] + Xc2[i, 1] > 0
yc2[i] = 1
end if
end for
lgm = logistic_model(Xc2, yc2)
print("classification score is accuracy: {round(lgm.score(Xc2, yc2), 4)}")
output
classification score is accuracy: 1
from statistics-ml
km = kmedians_model(G, 3, seed = 5)
kd = kmedoids_model(G, 3, seed = 5)
gm = gmm_model(G, 3, seed = 5)
print("kmedians label for row 0: {km.predict(G)[0]}")
print("kmedoids label for row 0: {kd.predict(G)[0]}")
print("gmm log-likelihood: {round(gm.log_likelihood, 1)}")
gb = gradient_boosting_model(X, y, 20, learning_rate = 0.1, max_depth = 3)
print("gradient boosting r2: {round(gb.score(X, y), 3)}")
sv = svm_model(Xc, yc, kernel = "linear", C = 1.0)
lg = logistic_model(Xc, yc)
print("svm accuracy: {round(sv.score(Xc, yc), 3)}")
print("logistic accuracy: {round(lg.score(Xc, yc), 3)}")
svr = svr_model(X, y)
print("svr r2: {round(svr.score(X, y), 3)}")
output
kmedians label for row 0: 1 kmedoids label for row 0: 1 gmm log-likelihood: [-448.7, -448.7, -448.7, -448.7] gradient boosting r2: 0.953 svm accuracy: 0.995 logistic accuracy: 0.995 svr r2: 0.596
from statistics-ml
How it works
logistic_model(X, y, [learning_rate=0.1], [n_iter=1000]) — see logistic_fit_model's own doc comment for the algorithm (plain gradient descent, hand-derived gradient — not autodiff, unlike curve_fit) and its scope limits.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.