Qu

score

Builtin index · Statistics & ML

result = model.score(X, [y])

Input: X, y · Output: result

What it is

Scores a fitted model Record model against an N-row feature matrix X and, for a supervised kind, the matching length-N target vector y.

Overloads

X can be Record, matrix, or vector.

5 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.

CodeInputOutputDescription
result = model.score(X, [y])
X Record, matrix, or vectornot documented yet
y optionalnot documented yet
result number
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Xr = randn(60, 2, seed = 61)
beta = [1.5, -0.7]
yr = Xr * beta + 0.05 * randn(60, seed = 62)
om = ols_model(Xr, yr)
print("regression score is R2: {round(om.score(Xr, yr), 4)}")
output
regression score is R2: 0.999
CodeInputOutputDescription
result = model.score(X, [y])
X Record, matrix, or vectornot documented yet
y optionalnot documented yet
result number
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

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
CodeInputOutputDescription
result = model.score(X, [y])
X Record, matrix, or vectornot documented yet
y optionalnot documented yet
result number
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Gs = vstack(randn(20, 2, seed = 64) + 4, randn(20, 2, seed = 65) - 4)
km = kmeans_model(Gs, 2, seed = 5)
print("kmeans score is negative inertia: {round(km.score(Gs), 4)}")
output
kmeans score is negative inertia: -59.3334
CodeInputOutputDescription
result = model.score(X, [y])
X Record, matrix, or vectorOn a pca_model, .score(X) returns the summed explained-variance fraction of the fitted components.
y optionaly is required for a supervised kind and refused for a clustering one.
result number
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Gs = vstack(randn(20, 2, seed = 64) + 4, randn(20, 2, seed = 65) - 4)
pm = pca_model(Gs, 1)
print("pca score is summed explained variance: {round(pm.score(Gs), 4)}")
output
pca score is summed explained variance: 0.9807
CodeInputOutputDescription
result = model.score(X, [y])
X Record, matrix, or vectorOn a gmm_model, .score(X) returns the total log-likelihood of X under the fitted mixture.
y optionaly is required for a supervised kind and refused for a clustering one.
result number
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Gs = vstack(randn(20, 2, seed = 64) + 4, randn(20, 2, seed = 65) - 4)
gm = gmm_model(Gs, 2, seed = 5)
print("gmm score is total log-likelihood: {round(gm.score(Gs), 2)}")
output
gmm score is total log-likelihood: -127.81

How it works

score(model, X, [y]) — callable as model.score(X) / model.score(X, y). A supervised model (ols/ridge) needs y and returns R²; kmeans takes just X and returns negative inertia; pca ignores both and returns its fitted explained-variance-ratio sum (not sklearn's probabilistic log-likelihood score — a deliberately simpler metric).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.