astar_mrmr
Builtin index · Statistics & ML
result = astar_mrmr(X, y, n_features, ...)
Input: X, y, n_features, ... · Output: result
What it is
A guided (A*) search on an N-row, D-column X and length-N y for a feature subset of size n_features (integer) that is relevant to the target and not redundant with itself (minimum-redundancy-maximum-relevance).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = astar_mrmr(X, y, n_features, ...) | X —A guided (A*) search on an N-row, D-column X and length-N y for a feature subset of size n_features (integer) that is relevant to the target and not redundant with itself (minimum-redundancy-maximum-relevance).y —A guided (A*) search on an N-row, D-column X and length-N y for a feature subset of size n_features (integer) that is relevant to the target and not redundant with itself (minimum-redundancy-maximum-relevance).n_features —A guided (A*) search on an N-row, D-column X and length-N y for a feature subset of size n_features (integer) that is relevant to the target and not redundant with itself (minimum-redundancy-maximum-relevance).... repeatablenot documented yet | result vector | Returns a vector of the selected column indices, zero-based, length n_features, the same convention as rfe. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
print("corrcoef matrix:\n{round(corrcoef(X), 3)}")
m = ols_model(X, y)
yhat = m.predict(X)
print("mae: {round(mae(y, yhat), 4)}, mse: {round(mse(y, yhat), 4)}")
cm = knn_model(Xc, yc, 5, kind = "classification")
predc = cm.predict(Xc)
print("precision: {round(precision(yc, predc), 3)}")
print("recall: {round(recall(yc, predc), 3)}")
print("f1: {round(f1(yc, predc), 3)}")
folds = k_fold(X, y, 4)
print("k_fold: {len(folds)} folds, first fold trains on {rows(folds[0].X_train)} rows")
stab = cv_stability(Xc, yc, n_repeats = 5, cv_folds = 3)
print("cv_stability: {round(mean(stab), 3)} +/- {round(std(stab), 3)}")
ab = ablation_study(Xc, yc, cv_folds = 3)
print("ablation_study scores: {round(ab, 4)}")
print("rfe keeps: {rfe(Xc, yc, 1)}")
print("mutual_info_classif: {round(mutual_info_classif(Xc, yc, k = 3), 4)}")
print("astar_mrmr keeps: {astar_mrmr(Xc, yc, 1)}")
print("permutation_importance: {round(permutation_importance(m, X, y, n_repeats = 5), 4)}")
corrcoef matrix: [1, -0.119, 0.007; -0.119, 1, -0.036; 0.007, -0.036, 1] mae: 0.0847, mse: 0.011 precision: 0.995 recall: 0.995 f1: 0.995 k_fold: 4 folds, first fold trains on 90 rows cv_stability: 0.908 +/- 0.012 ablation_study scores: [0.2401, 0.1301] rfe keeps: [0] mutual_info_classif: [0.2398, 0.1939] astar_mrmr keeps: [0] permutation_importance: [1.5394, 0.3327, 0.0947]
from statistics-ml
How it works
astar_mrmr(X, y, n_features, [beam_width=15], [redundancy_weight=1.0], [cv_folds=3], [max_depth=3], [seed=], [kind="classification"]) — the literal A*-mRMR feature selector; see astar_mrmr_search's own doc comment for the full algorithm (ported from Ahmed's own novel_methods.py::AStarMRMRHybrid). Returns the selected 0-based column indices as a Value::Vec, sklearn's get_support(indices=True) convention — slice X yourself with them (X[:, idx]-style) rather than getting a pre-sliced matrix back, so this composes with whatever you do next instead of assuming it.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.