← Back to Skills Marketplace
wu-uk

contribution-analysis

by wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ⚠ suspicious
70
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install lake-warming-attribution-contribution-analysis
Description
Calculate the relative contribution of different factors to a response variable using R² decomposition. Use when you need to quantify how much each factor ex...
README (SKILL.md)

Contribution Analysis Guide

Overview

Contribution analysis quantifies how much each factor contributes to explaining the variance of a response variable. This skill focuses on R² decomposition method.

Complete Workflow

When you have multiple correlated variables that belong to different categories:

import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LinearRegression
from factor_analyzer import FactorAnalyzer

# Step 1: Combine ALL variables into one matrix
pca_vars = ['Var1', 'Var2', 'Var3', 'Var4', 'Var5', 'Var6', 'Var7', 'Var8']
X = df[pca_vars].values
y = df['ResponseVariable'].values

# Step 2: Standardize
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# Step 3: Run ONE global PCA on all variables together
fa = FactorAnalyzer(n_factors=4, rotation='varimax')
fa.fit(X_scaled)
scores = fa.transform(X_scaled)

# Step 4: R² decomposition on factor scores
def calc_r2(X, y):
    model = LinearRegression()
    model.fit(X, y)
    y_pred = model.predict(X)
    ss_res = np.sum((y - y_pred) ** 2)
    ss_tot = np.sum((y - np.mean(y)) ** 2)
    return 1 - (ss_res / ss_tot)

full_r2 = calc_r2(scores, y)

# Step 5: Calculate contribution of each factor
contrib_0 = full_r2 - calc_r2(scores[:, [1, 2, 3]], y)
contrib_1 = full_r2 - calc_r2(scores[:, [0, 2, 3]], y)
contrib_2 = full_r2 - calc_r2(scores[:, [0, 1, 3]], y)
contrib_3 = full_r2 - calc_r2(scores[:, [0, 1, 2]], y)

R² Decomposition Method

The contribution of each factor is calculated by comparing the full model R² with the R² when that factor is removed:

Contribution_i = R²_full - R²_without_i

Output Format

contributions = {
    'Category1': contrib_0 * 100,
    'Category2': contrib_1 * 100,
    'Category3': contrib_2 * 100,
    'Category4': contrib_3 * 100
}

dominant = max(contributions, key=contributions.get)
dominant_pct = round(contributions[dominant])

with open('output.csv', 'w') as f:
    f.write('variable,contribution\
')
    f.write(f'{dominant},{dominant_pct}\
')

Common Issues

Issue Cause Solution
Negative contribution Suppressor effect Check for multicollinearity
Contributions don't sum to R² Normal behavior R² decomposition is approximate
Very small contributions Factor not important May be negligible driver

Best Practices

  • Run ONE global PCA on all variables together, not separate PCA per category
  • Use factor_analyzer with varimax rotation
  • Map factors to category names based on loadings interpretation
  • Report contribution as percentage
  • Identify the dominant (largest) factor
Usage Guidance
This skill appears to implement R² decomposition via factor scores, but several issues need attention before you rely on it: (1) fix the PCA vs FactorAnalyzer mismatch — decide whether to use PCA or factor analysis and update the text and variable names accordingly; (2) declare required Python packages (pandas, numpy, scikit-learn, factor_analyzer) so consumers know what to install; (3) correct the output: the example writes only the dominant category to output.csv rather than all contributions — if you need full results, modify the write block to export every category and its percentage; (4) be cautious: drop-one R² contributions can be negative and are not a unique or fair allocation when predictors/factors are correlated. Consider alternate attribution methods (e.g., Shapley values, dominance analysis, permutation importance, or cross-validated R²) and using cross-validation or a holdout set so R² estimates are not overly optimistic; (5) test the pipeline on synthetic data to confirm factor-to-category mapping and contribution sums before using results in reports. If the author provides corrected example code and dependency metadata, confidence in the skill would increase.
Capability Analysis
Type: OpenClaw Skill Name: lake-warming-attribution-contribution-analysis Version: 0.1.0 The skill bundle provides standard data science workflows for R² decomposition and factor analysis using legitimate libraries like scikit-learn and factor_analyzer. The code and instructions in SKILL.md are strictly aligned with the stated purpose of statistical contribution analysis and contain no indicators of malicious intent, data exfiltration, or unauthorized system access.
Capability Assessment
Purpose & Capability
Name and description (contribution analysis via R² decomposition) align with the instructions, which implement factor scores and drop-one R² comparisons. However, the prose says to run a global PCA while the example code uses FactorAnalyzer (factor analysis), and variable names (pca_vars) conflict with the chosen method.
Instruction Scope
The SKILL.md runs entirely in-process on a dataframe (df) and writes output.csv locally — no network or secret access — which is reasonable. However the instructions have functional issues: (1) the example computes only the dominant contribution to output.csv (it writes only one row) instead of writing all category contributions as the guide implies; (2) drop-one R² differences are order-dependent and can be negative (the guide notes this but treats it lightly); (3) the method may produce misleading attribution when predictors/factors are correlated or when factors are derived and then immediately regressed on the same data (risk of inflated R²).
Install Mechanism
This is instruction-only (no install spec) which is low risk, but the runtime example requires Python packages (pandas, numpy, scikit-learn, factor_analyzer) that are not declared anywhere in the skill metadata. Users need to install these dependencies themselves.
Credentials
The skill requests no environment variables, credentials, or privileged paths. It only assumes access to an in-memory dataframe and local filesystem write permission for output.csv.
Persistence & Privilege
The skill has no install or persistence, always:false, and does not request elevated or cross-skill configuration changes.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install lake-warming-attribution-contribution-analysis
  3. After installation, invoke the skill by name or use /lake-warming-attribution-contribution-analysis
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.1.0
Bulk publish from all-task-skills-dedup
Metadata
Slug lake-warming-attribution-contribution-analysis
Version 0.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is contribution-analysis?

Calculate the relative contribution of different factors to a response variable using R² decomposition. Use when you need to quantify how much each factor ex... It is an AI Agent Skill for Claude Code / OpenClaw, with 70 downloads so far.

How do I install contribution-analysis?

Run "/install lake-warming-attribution-contribution-analysis" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is contribution-analysis free?

Yes, contribution-analysis is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does contribution-analysis support?

contribution-analysis is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created contribution-analysis?

It is built and maintained by wu-uk (@wu-uk); the current version is v0.1.0.

💬 Comments