{"schemaVersion":1,"resourceType":"connector","slug":"explain","name":"Explain","catalog":"explain","description":"Explain scikit-learn and XGBoost model predictions with per-row SHAP values and global feature importance","language":"Python","categories":["analytics"],"repository":"https://github.com/Query-farm/vgi-explain","license":"MIT","generatedAt":"2026-12-01T18:22:16+00:00","runtime":{"engineVersion":"2.0.1","protocolVersion":"3.4"},"release":{"tag":"v0.5.0","publishedAt":"2026-11-25T18:30:35Z","url":"https://github.com/Query-farm/vgi-explain/releases/tag/v0.5.0"},"links":{"html":"https://query.farm/products/orchard/connectors/explain/","llms":"https://query.farm/products/orchard/connectors/explain/llms.txt","markdown":"https://query.farm/products/orchard/connectors/explain/index.md","json":"https://query.farm/products/orchard/api/v1/connectors/explain.json","objects":"https://query.farm/products/orchard/api/v1/connectors/explain/objects.json","search":"https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=explain&q={query}"},"authentication":{"mode":"none_declared","guidance":"No service credentials are declared by this connector. Individual datasets, input files or deployments may have their own prerequisites.","interpretation":"Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute(\"CREATE SECRET stripe (TYPE stripe, api_key ?)\", [os.environ[\"STRIPE_API_KEY\"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.","secrets":[]},"deployment":{"local":{"methods":[{"id":"uvx","label":"uvx","icon":"simple-icons:python","steps":[{"title":"Attach with uvx","description":"Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.","lang":"sql","code":"ATTACH 'explain' AS explain (\n  TYPE vgi,\n  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-explain@v0.5.0 vgi-explain'\n);"}]},{"id":"docker","label":"Docker","icon":"simple-icons:docker","steps":[{"title":"Attach the signed image","description":"Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.","lang":"sql","code":"ATTACH 'explain' AS explain (\n  TYPE vgi,\n  LOCATION 'oci://ghcr.io/query-farm/vgi-explain:0.5.0'\n);"}]}],"pinnedMethods":[{"id":"uvx","label":"uvx","icon":"simple-icons:python","steps":[{"title":"Attach with uvx","description":"Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.","lang":"sql","code":"ATTACH 'explain' AS explain (\n  TYPE vgi,\n  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-explain@v0.5.0 vgi-explain'\n);"}]},{"id":"docker","label":"Docker","icon":"simple-icons:docker","steps":[{"title":"Attach the signed image","description":"Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.","lang":"sql","code":"ATTACH 'explain' AS explain (\n  TYPE vgi,\n  LOCATION 'oci://ghcr.io/query-farm/vgi-explain:0.5.0'\n);"}]}]},"selfHost":{"instructions":"https://github.com/Query-farm/vgi-explain","connectionGuide":"https://query.farm/vgi/connect-to-a-worker/","guidance":"Deploy using the connector repository instructions and use its supported HTTP or SSH transport. Replace example URLs with your actual deployment; configure its authentication."},"queryFarm":{"available":true,"console":"https://auth.queryfarm.cloud/console/new?worker=explain","organizationMonthlyMinimumUsd":10,"pricing":"https://query.farm/products/orchard/hosted/"},"publicDemo":null},"setup":{"extensions":{"duckdb":"SET allow_extension_repositories = 'allowed';\n\nCREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm\n    WITH PREFIX 'https://duckdb-extensions.query.farm';\n\nINSTALL vgi FROM query_farm;\nLOAD vgi FROM query_farm;","haybarn":"INSTALL vgi FROM community;\nLOAD vgi;"},"attachSql":"ATTACH 'explain' AS explain (\n  TYPE vgi,\n  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-explain@v0.5.0 vgi-explain'\n);","attachOptions":[],"note":"Install and load VGI, attach the connector using the catalog alias shown here, then create required secrets. Replace placeholders and omit unused optional secret parameters. Satisfy file, network and credential prerequisites before executing a query."},"example":{"title":"See which features drive a model’s predictions","sql":"SET VARIABLE m = (SELECT model FROM read_parquet('https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet') WHERE name = 'rf_clf'); SELECT feature, rank, method FROM explain.main.feature_importance((SELECT id, signal, noise_a, noise_b FROM read_parquet('https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet')), model := getvariable('m'), id := 'id') ORDER BY rank","requiresCredentials":null,"note":null,"objects":[{"name":"explain.main.feature_importance","kind":"table_in_out_function","links":{"html":"https://query.farm/products/orchard/connectors/explain/#obj-main-feature_importance","markdown":"https://query.farm/products/orchard/connectors/explain/objects/table_in_out_function.bWFpbg.ZmVhdHVyZV9pbXBvcnRhbmNl.md","json":"https://query.farm/products/orchard/api/v1/connectors/explain/objects/table_in_out_function.bWFpbg.ZmVhdHVyZV9pbXBvcnRhbmNl.json"}}],"evidence":{"status":"captured_result","capturedAt":"2026-12-01T06:16:30+00:00","engineVersion":"2.0.1","protocolVersion":"3.4.0","releaseTag":"v0.5.0","sample":{"columns":["feature","rank","method"],"types":["VARCHAR","INTEGER","VARCHAR"],"rows":[["signal",1,"mean_abs_shap"],["noise_b",2,"mean_abs_shap"],["noise_a",3,"mean_abs_shap"]],"more":false}},"artifact":null},"objects":{"total":4,"index":"https://query.farm/products/orchard/api/v1/connectors/explain/objects.json","search":"https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=explain&q={query}"},"agentTasks":["This worker publishes a browsable, model-free reference of the model families it can explain. Using that reference, return the names of every supported model family, in alphabetical order.","A fitted RandomForest classifier is stored as a model BLOB in the committed fixture 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (the row WHERE name = 'rf_clf'), and a matching feature matrix (columns id, signal, noise_a, noise_b) is in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet'. Load the model into a session variable, then rank the model's features by global SHAP importance and return only the name of the single most important feature.","The model BLOB in fixture 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (WHERE name = 'rf_clf') is a binary classifier. Load it into a session variable and return how many rows (one per class) its SHAP base-value output has.","Load the model BLOB from 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (WHERE name = 'rf_clf') into a session variable and compute per-row SHAP contributions for the feature rows in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet' (columns id, signal, noise_a, noise_b). Return the distinct feature names that appear in the output, in alphabetical order.","Using the binary-classifier model BLOB in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (WHERE name = 'rf_clf') and the feature rows in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet' (columns id, signal, noise_a, noise_b), return the distinct class labels present in the per-row SHAP output, ordered.","Load the model BLOB from 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (WHERE name = 'rf_clf') into a session variable and compute global feature importance over the non-empty feature relation in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet' (columns id, signal, noise_a, noise_b). Return the single method label the function reports for how importance was computed.","Load the binary-classifier model BLOB from 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (WHERE name = 'rf_clf') into a session variable. Its SHAP explanation reports one output per class ('0' and '1'). Using SHAP additivity (a row's model output for a class = that class's SHAP base value plus the sum of the row's per-feature SHAP contributions for the same class), reconstruct the predicted probability of class '1' for every feature row in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet' (columns id, signal, noise_a, noise_b). Return a single BIGINT column: the number of rows whose reconstructed class-'1' probability is at least 0.5.","Load the model BLOB from 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/models.parquet' (WHERE name = 'rf_clf') into a session variable. Over the feature rows in 'https://raw.githubusercontent.com/Query-farm/vgi-explain/v0.2.0/test/fixtures/features.parquet' (columns id, signal, noise_a, noise_b), find the feature ranked second by global SHAP importance, then count the rows in which that feature's per-row SHAP contribution toward class '1' is positive. Return a single BIGINT column with that count."],"provenance":{"generatedAt":"2026-12-01T18:22:16+00:00","repository":"https://github.com/Query-farm/vgi-explain","harvest":{"status":"ok","method":"subprocess","error":null,"vgi_version":"9773130dde"},"catalogVerification":{"verified":true,"status":"passed","total":4,"passed":4,"failed":0,"needs_credentials":0,"location":"uvx --from git+https://github.com/Query-farm/vgi-explain@v0.5.0 vgi-explain","transport":"subprocess","environment":{"vgi_extension_version":"9773130dde","haybarn_version":"2.0.1rc3","engine_version":"v2.0.1","python":"3.12.4","platform":"darwin_arm64","protocol_version":"3.4.0"},"checked_at":"2026-12-01T06:14:04+00:00"},"interpretation":"Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."},"interpretation":["Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.","Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.","A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.","Service credentials, external data availability and deployment authentication are separate requirements."]}