[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C8JMP8GN3HFZCCP7N7H9AS":3,"skill-same:01M7C8JMP8GN3HFZCCP7N7H9AS":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7C8JMP8GN3HFZCCP7N7H9AS","contribution-analysis",null,"Calculate the relative contribution of different factors to a response variable using R² decomposition. Use when you need to quantify how much each factor explains the variance of an outcome.","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"MIT","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskillsbench_slice\u002Flake-warming-attribution\u002Fenvironment\u002Fskills\u002Fcontribution-analysis\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: contribution-analysis\ndescription: Calculate the relative contribution of different factors to a response variable using R² decomposition. Use when you need to quantify how much each factor explains the variance of an outcome.\nlicense: MIT\n---\n\n# Contribution Analysis Guide\n\n## Overview\n\nContribution analysis quantifies how much each factor contributes to explaining the variance of a response variable. This skill focuses on R² decomposition method.\n\n## Complete Workflow\n\nWhen you have multiple correlated variables that belong to different categories:\n```python\nimport pandas as pd\nimport numpy as np\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.linear_model import LinearRegression\nfrom factor_analyzer import FactorAnalyzer\n\n# Step 1: Combine ALL variables into one matrix\npca_vars = ['Var1', 'Var2', 'Var3', 'Var4', 'Var5', 'Var6', 'Var7', 'Var8']\nX = df[pca_vars].values\ny = df['ResponseVariable'].values\n\n# Step 2: Standardize\nscaler = StandardScaler()\nX_scaled = scaler.fit_transform(X)\n\n# Step 3: Run ONE global PCA on all variables together\nfa = FactorAnalyzer(n_factors=4, rotation='varimax')\nfa.fit(X_scaled)\nscores = fa.transform(X_scaled)\n\n# Step 4: R² decomposition on factor scores\ndef calc_r2(X, y):\n    model = LinearRegression()\n    model.fit(X, y)\n    y_pred = model.predict(X)\n    ss_res = np.sum((y - y_pred) ** 2)\n    ss_tot = np.sum((y - np.mean(y)) ** 2)\n    return 1 - (ss_res \u002F ss_tot)\n\nfull_r2 = calc_r2(scores, y)\n\n# Step 5: Calculate contribution of each factor\ncontrib_0 = full_r2 - calc_r2(scores[:, [1, 2, 3]], y)\ncontrib_1 = full_r2 - calc_r2(scores[:, [0, 2, 3]], y)\ncontrib_2 = full_r2 - calc_r2(scores[:, [0, 1, 3]], y)\ncontrib_3 = full_r2 - calc_r2(scores[:, [0, 1, 2]], y)\n```\n\n## R² Decomposition Method\n\nThe contribution of each factor is calculated by comparing the full model R² with the R² when that factor is removed:\n```\nContribution_i = R²_full - R²_without_i\n```\n\n## Output Format\n```python\ncontributions = {\n    'Category1': contrib_0 * 100,\n    'Category2': contrib_1 * 100,\n    'Category3': contrib_2 * 100,\n    'Category4': contrib_3 * 100\n}\n\ndominant = max(contributions, key=contributions.get)\ndominant_pct = round(contributions[dominant])\n\nwith open('output.csv', 'w') as f:\n    f.write('variable,contribution\\n')\n    f.write(f'{dominant},{dominant_pct}\\n')\n```\n\n## Common Issues\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| Negative contribution | Suppressor effect | Check for multicollinearity |\n| Contributions don't sum to R² | Normal behavior | R² decomposition is approximate |\n| Very small contributions | Factor not important | May be negligible driver |\n\n## Best Practices\n\n- Run ONE global PCA on all variables together, not separate PCA per category\n- Use factor_analyzer with varimax rotation\n- Map factors to category names based on loadings interpretation\n- Report contribution as percentage\n- Identify the dominant (largest) factor\n","# Contribution Analysis Guide\n\n## Overview\n\nContribution analysis quantifies how much each factor contributes to explaining the variance of a response variable. This skill focuses on R² decomposition method.\n\n## Complete Workflow\n\nWhen you have multiple correlated variables that belong to different categories:\n```python\nimport pandas as pd\nimport numpy as np\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.linear_model import LinearRegression\nfrom factor_analyzer import FactorAnalyzer\n\n# Step 1: Combine ALL variables into one matrix\npca_vars = ['Var1', 'Var2', 'Var3', 'Var4', 'Var5', 'Var6', 'Var7', 'Var8']\nX = df[pca_vars].values\ny = df['ResponseVariable'].values\n\n# Step 2: Standardize\nscaler = StandardScaler()\nX_scaled = scaler.fit_transform(X)\n\n# Step 3: Run ONE global PCA on all variables together\nfa = FactorAnalyzer(n_factors=4, rotation='varimax')\nfa.fit(X_scaled)\nscores = fa.transform(X_scaled)\n\n# Step 4: R² decomposition on factor scores\ndef calc_r2(X, y):\n    model = LinearRegression()\n    model.fit(X, y)\n    y_pred = model.predict(X)\n    ss_res = np.sum((y - y_pred) ** 2)\n    ss_tot = np.sum((y - np.mean(y)) ** 2)\n    return 1 - (ss_res \u002F ss_tot)\n\nfull_r2 = calc_r2(scores, y)\n\n# Step 5: Calculate contribution of each factor\ncontrib_0 = full_r2 - calc_r2(scores[:, [1, 2, 3]], y)\ncontrib_1 = full_r2 - calc_r2(scores[:, [0, 2, 3]], y)\ncontrib_2 = full_r2 - calc_r2(scores[:, [0, 1, 3]], y)\ncontrib_3 = full_r2 - calc_r2(scores[:, [0, 1, 2]], y)\n```\n\n## R² Decomposition Method\n\nThe contribution of each factor is calculated by comparing the full model R² with the R² when that factor is removed:\n```\nContribution_i = R²_full - R²_without_i\n```\n\n## Output Format\n```python\ncontributions = {\n    'Category1': contrib_0 * 100,\n    'Category2': contrib_1 * 100,\n    'Category3': contrib_2 * 100,\n    'Category4': contrib_3 * 100\n}\n\ndominant = max(contributions, key=contributions.get)\ndominant_pct = round(contributions[dominant])\n\nwith open('output.csv', 'w') as f:\n    f.write('variable,contribution\\n')\n    f.write(f'{dominant},{dominant_pct}\\n')\n```\n\n## Common Issues\n\n| Issue | Cause | Solution |\n|-------|-------|----------|\n| Negative contribution | Suppressor effect | Check for multicollinearity |\n| Contributions don't sum to R² | Normal behavior | R² decomposition is approximate |\n| Very small contributions | Factor not important | May be negligible driver |\n\n## Best Practices\n\n- Run ONE global PCA on all variables together, not separate PCA per category\n- Use factor_analyzer with varimax rotation\n- Map factors to category names based on loadings interpretation\n- Report contribution as percentage\n- Identify the dominant (largest) factor\n",{"name":5,"license":15,"description":7},"main","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe","tests\u002Ffixtures\u002Fskillsbench_slice\u002Flake-warming-attribution\u002Fenvironment\u002Fskills\u002Fcontribution-analysis",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill contribution-analysis",{"tool":37,"command":38},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill contribution-analysis",{"tool":40,"command":41},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill contribution-analysis","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskillsbench_slice\u002Flake-warming-attribution\u002Fenvironment\u002Fskills\u002Fcontribution-analysis\u002FSKILL.md",true,[],[46,54,61,68,73,78],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":69,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":74,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":79,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]