Collect concept examples
Assemble labelled positive and negative examples for each concept; ensure examples are representative and not confounded with the target label.
Probe with concept activation vectors. Judge concept influence on outputs.
Concept activation vectors (CAVs) test whether a human-interpretable concept is encoded in a model's internal activations and whether that concept affects predictions. Running a CAV experiment requires curated positive and negative concept examples, a trained model from which to extract layer activations, a linear probe to separate concept activations, and a directional-sensitivity measure such as TCAV scores. Common issues include noisy or ambiguous concept examples, activations that do not separate the concept, and over-interpreting small TCAV values.
Learning concept · Not a validated service
Concept activation vectors (CAVs) test whether a human-interpretable concept is encoded in a model's internal activations and whether that concept affects predictions. Running a CAV experiment requires curated positive and negative concept examples, a trained model from which to extract layer activations, a linear probe to separate concept activations, and a directional-sensitivity measure such as TCAV scores. Common issues include noisy or ambiguous concept examples, activations that do not separate the concept, and over-interpreting small TCAV values.
A proposed use is auditing a classification model for unintended sensitivity to protected or undesirable concepts (for example, checking whether a model's predictions correlate with a visual attribute). Any deployment for auditing or decision support should keep a human reviewer in the loop and not be used alone for high-stakes decisions.
Assemble labelled positive and negative examples for each concept; ensure examples are representative and not confounded with the target label.
Use a model suitable for extracting internal activations (for example a CNN for images) and hold out data for evaluation.
Extract activations from a chosen layer, train a linear classifier to separate concept examples and treat its normal vector as the CAV.
Measure directional sensitivity (TCAV) across examples and report statistical significance and robustness to concept-example choices.
The supplied starter generates a synthetic classification dataset with sklearn.make_classification, trains a RandomForestClassifier, computes permutation feature importances on the test set, and prints the model score and top features. It does not extract model activations, train concept probes, or compute CAV/TCAV scores.
X, y = make_classification(n_samples=700, n_features=8, n_informative=5, random_state=42)
columns = [f"feature_{i}" for i in range(X.shape[1])]
X = pd.DataFrame(X, columns=columns)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42, stratify=y)
model = RandomForestClassifier(n_estimators=250, random_state=42)
model.fit(X_train, y_train)
importance = permutation_importance(model, X_test, y_test, n_repeats=10, random_state=42)
report = pd.DataFrame({"feature": columns, "importance": importance.importances_mean})The starter uses synthetic tabular data and a random-forest model and reports permutation importances. It does not extract internal activations, does not train linear concept probes, and therefore does not implement concept activation vectors or TCAV analysis described by the project title.
A proposed extension: replace the synthetic data with a domain-appropriate dataset, use a model that exposes layer activations, collect concept-positive and concept-negative example sets, fit linear probes to those activations and compute TCAV scores to quantify concept influence.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.