← 返回 Skills 市场
wu-uk

pca-decomposition

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
74
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install lake-warming-attribution-pca-decomposition
功能描述
Reduce dimensionality of multivariate data using PCA with varimax rotation. Use when you have many correlated variables and need to identify underlying facto...
使用说明 (SKILL.md)

PCA Decomposition Guide

Overview

Principal Component Analysis (PCA) reduces many correlated variables into fewer uncorrelated components. Varimax rotation makes components more interpretable by maximizing variance.

When to Use PCA

  • Many correlated predictor variables
  • Need to identify underlying factor groups
  • Reduce multicollinearity before regression
  • Exploratory data analysis

Basic PCA with Varimax Rotation

from sklearn.preprocessing import StandardScaler
from factor_analyzer import FactorAnalyzer

# Standardize data first
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# PCA with varimax rotation
fa = FactorAnalyzer(n_factors=4, rotation='varimax')
fa.fit(X_scaled)

# Get factor loadings
loadings = fa.loadings_

# Get component scores for each observation
scores = fa.transform(X_scaled)

Workflow for Attribution Analysis

When using PCA for contribution analysis with predefined categories:

  1. Combine ALL variables first, then do PCA together:
# Include all variables from all categories in one matrix
all_vars = ['AirTemp', 'NetRadiation', 'Precip', 'Inflow', 'Outflow',
            'WindSpeed', 'DevelopedArea', 'AgricultureArea']
X = df[all_vars].values

scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# PCA on ALL variables together
fa = FactorAnalyzer(n_factors=4, rotation='varimax')
fa.fit(X_scaled)
scores = fa.transform(X_scaled)
  1. Interpret loadings to map factors to categories (optional for understanding)

  2. Use factor scores directly for R² decomposition

Important: Do NOT run separate PCA for each category. Run one global PCA on all variables, then use the resulting factor scores for contribution analysis.

Interpreting Factor Loadings

Loadings show correlation between original variables and components:

Loading Interpretation
> 0.7 Strong association
0.4 - 0.7 Moderate association
\x3C 0.4 Weak association

Example: Economic Indicators

import pandas as pd
from sklearn.preprocessing import StandardScaler
from factor_analyzer import FactorAnalyzer

# Variables: gdp, unemployment, inflation, interest_rate, exports, imports
df = pd.read_csv('economic_data.csv')
variables = ['gdp', 'unemployment', 'inflation',
             'interest_rate', 'exports', 'imports']

X = df[variables].values
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

fa = FactorAnalyzer(n_factors=3, rotation='varimax')
fa.fit(X_scaled)

# View loadings
loadings_df = pd.DataFrame(
    fa.loadings_,
    index=variables,
    columns=['RC1', 'RC2', 'RC3']
)
print(loadings_df.round(2))

Choosing Number of Factors

Option 1: Kaiser Criterion

# Check eigenvalues
eigenvalues, _ = fa.get_eigenvalues()

# Keep factors with eigenvalue > 1
n_factors = sum(eigenvalues > 1)

Option 2: Domain Knowledge

If you know how many categories your variables should group into, specify directly:

# Example: health data with 3 expected categories (lifestyle, genetics, environment)
fa = FactorAnalyzer(n_factors=3, rotation='varimax')

Common Issues

Issue Cause Solution
Loadings all similar Too few factors Increase n_factors
Negative loadings Inverse relationship Normal, interpret direction
Low variance explained Data not suitable for PCA Check correlations first

Best Practices

  • Always standardize data before PCA
  • Use varimax rotation for interpretability
  • Check factor loadings to name components
  • Use Kaiser criterion or domain knowledge for n_factors
  • For attribution analysis, run ONE global PCA on all variables
安全使用建议
This skill is an instruction-only guide for performing PCA with varimax rotation and appears coherent and low-risk. Before using it: (1) ensure you have the required Python libraries (pandas, scikit-learn, factor_analyzer) installed from trusted sources; (2) run the example code on non-sensitive or test data first to confirm behavior; and (3) note that the SKILL.md provides guidance only — it won't install dependencies for you. If you need automated execution, verify what runtime will execute the code and whether it has access to your files or network.
功能分析
Type: OpenClaw Skill Name: lake-warming-attribution-pca-decomposition Version: 0.1.0 The skill bundle provides legitimate documentation and code examples for performing Principal Component Analysis (PCA) using standard libraries like sklearn and factor_analyzer. The content in SKILL.md is focused entirely on statistical data processing and lacks any indicators of malicious intent, data exfiltration, or prompt injection.
能力评估
Purpose & Capability
Name and description match the instructions: the SKILL.md describes PCA with varimax rotation and gives examples for factor analysis and attribution. There are no requested credentials, binaries, or unrelated requirements.
Instruction Scope
Instructions stay within expected bounds (data standardization, PCA, interpreting loadings). Example code reads a CSV and references dataframe variables — normal for an analysis guide. The doc does not instruct reading system files, environment variables, or transmitting data externally. Note: it presumes you will run the provided Python snippets in your environment.
Install Mechanism
No install spec (lowest risk). However, the guide uses Python libraries (scikit-learn, factor_analyzer, pandas) but does not declare or provide installation instructions for those dependencies; this is an interoperability/documentation omission rather than a security problem.
Credentials
No environment variables, credentials, or config paths are requested. The skill does not ask for any secrets or unrelated permissions.
Persistence & Privilege
always:false and no install or code files — the skill does not request persistent presence or elevated privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install lake-warming-attribution-pca-decomposition
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /lake-warming-attribution-pca-decomposition 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug lake-warming-attribution-pca-decomposition
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

pca-decomposition 是什么?

Reduce dimensionality of multivariate data using PCA with varimax rotation. Use when you have many correlated variables and need to identify underlying facto... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 74 次。

如何安装 pca-decomposition?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install lake-warming-attribution-pca-decomposition」即可一键安装,无需额外配置。

pca-decomposition 是免费的吗?

是的,pca-decomposition 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

pca-decomposition 支持哪些平台?

pca-decomposition 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 pca-decomposition?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论