mcpField
S
statistical-analyzer

statistical-analyzer

github.com/dkyazzentwatwaデータ・データベース12458 回インストール29 週間前に更新
リポジトリ

statistical-analyzer について

statistical-analyzerは、データセットの統計分析を支援するPythonおよびコマンドラインツールです。一般的な検定や回帰、前提条件の確認に対応し、平易な解釈、可視化、PDFまたはHTMLレポートを作成します。

主な機能

  1. 01仮説検定、回帰、ANOVA
  2. 02相関と分布の分析
  3. 03平易な結果の解釈
  4. 04前提条件の確認と警告
  5. 05統計プロットと可視化
  6. 06PDFおよびHTMLレポートの生成

活用シーン

  1. 01t検定やANOVAで処置群を比較する
  2. 02回帰や相関で関係を分析する
  3. 03分布と検定の前提条件を確認する
  4. 04結果と図を含むレポートを作成する

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill statistical-analyzer

インストール後、Claude Code で/statistical-analyzerを入力して読み込まれたか確認します。

同梱ファイルscripts/requirements.txtscripts/statistical_analyzer.py

詳細

統計分析ツール

仮説検定、回帰分析、ANOVA、平易な言葉での結果解釈を含む、ガイド付きの統計分析です。

機能

  • 仮説検定:t検定、カイ二乗検定、比率検定
  • 回帰分析:線形回帰、多項式回帰、重回帰
  • ANOVA:事後検定を含む一元配置・二元配置ANOVA
  • 分布分析:正規性検定、Q-Qプロット
  • 相関分析:有意性を含むPearson、Spearman
  • 平易な言葉での結果解釈:統計出力を解釈します
  • 可視化:回帰プロット、残差分析、箱ひげ図
  • レポート生成:解釈付きのPDF/HTMLレポート

クイックスタート

from statistical_analyzer import StatisticalAnalyzer

analyzer = StatisticalAnalyzer()

# T-test
analyzer.load_data(df, group_col='treatment', value_col='score')
results = analyzer.t_test(group1='control', group2='experimental')
print(results['interpretation'])

# Regression
analyzer.load_data(df)
results = analyzer.linear_regression(x='age', y='income')
print(f"R²: {results['r_squared']}")
analyzer.plot_regression('regression.png')

CLI の使用方法

# T-test
python statistical_analyzer.py --data data.csv --test t-test --group treatment --value score --output results.html

# ANOVA
python statistical_analyzer.py --data data.csv --test anova --group category --value score --output results.pdf

# Regression
python statistical_analyzer.py --data data.csv --test regression --x age --y income --output report.pdf

# Correlation matrix
python statistical_analyzer.py --data data.csv --test correlation --output correlation.png

API リファレンス

StatisticalAnalyzer クラス
class StatisticalAnalyzer:
    def __init__(self)

    # Data Loading
    def load_data(self, data, **kwargs) -> 'StatisticalAnalyzer'
    def load_csv(self, filepath, **kwargs) -> 'StatisticalAnalyzer'

    # Hypothesis Tests
    def t_test(self, group1, group2, paired=False, alternative='two-sided') -> Dict
    def one_sample_t_test(self, column, expected_mean, alternative='two-sided') -> Dict
    def anova(self, groups, value_col) -> Dict
    def chi_square(self, observed, expected=None) -> Dict
    def proportion_test(self, successes, total, expected_prop=0.5) -> Dict

    # Regression
    def linear_regression(self, x, y) -> Dict
    def polynomial_regression(self, x, y, degree=2) -> Dict
    def multiple_regression(self, predictors: List[str], target: str) -> Dict

    # Correlation
    def correlation(self, method='pearson') -> pd.DataFrame  # Correlation matrix
    def correlation_test(self, var1, var2, method='pearson') -> Dict

    # Distribution Tests
    def normality_test(self, column, method='shapiro') -> Dict
    def qq_plot(self, column, output=None) -> str

    # Visualization
    def plot_regression(self, output, x=None, y=None) -> str
    def plot_residuals(self, output) -> str
    def plot_distribution(self, column, output) -> str
    def plot_boxplot(self, groups, value_col, output) -> str

    # Reporting
    def generate_report(self, output, format='pdf') -> str
    def summary(self) -> str

検定

t検定

2つのグループ間の平均値を比較します:

analyzer.load_csv('data.csv')

# Independent samples
results = analyzer.t_test(
    group1='control',
    group2='treatment',
    paired=False
)

# Results
print(results)
# {
#     'statistic': -2.45,
#     'p_value': 0.018,
#     'mean_diff': -5.2,
#     'ci': (-9.5, -0.9),
#     'interpretation': 'The difference is statistically significant (p=0.018)...'
# }

# Paired samples (before/after)
results = analyzer.t_test(
    group1='before',
    group2='after',
    paired=True
)
ANOVA

複数のグループ間の平均値を比較します:

results = analyzer.anova(
    groups=['control', 'treatment_a', 'treatment_b'],
    value_col='score'
)

# Results include post-hoc tests
print(results['interpretation'])
# "There is a statistically significant difference between groups (p<0.001).
#  Post-hoc tests show treatment_a differs from control (p=0.003)..."
回帰分析
# Simple linear regression
results = analyzer.linear_regression(x='hours_studied', y='exam_score')

print(f"R² = {results['r_squared']:.3f}")
print(f"Equation: y = {results['slope']:.2f}x + {results['intercept']:.2f}")
print(f"p-value: {results['p_value']:.4f}")

# Polynomial regression
results = analyzer.polynomial_regression(x='age', y='salary', degree=2)

# Multiple regression
results = analyzer.multiple_regression(
    predictors=['age', 'experience', 'education'],
    target='salary'
)
相関分析
# Full correlation matrix
corr_matrix = analyzer.correlation(method='pearson')
print(corr_matrix)

# Test specific correlation
results = analyzer.correlation_test('height', 'weight', method='pearson')
print(results['interpretation'])
# "There is a strong positive correlation (r=0.82, p<0.001)"
分布検定
# Test normality
results = analyzer.normality_test('scores', method='shapiro')
# Returns: {'statistic': 0.98, 'p_value': 0.35,
#           'interpretation': 'Data appears normally distributed (p=0.35)'}

# Q-Q plot
analyzer.qq_plot('scores', output='qq_plot.png')

解釈ガイド

分析ツールは、平易な言葉で解釈を提示します:

有意水準
  • p < 0.001:「極めて有意」
  • p < 0.01:「非常に有意」
  • p < 0.05:「統計的に有意」
  • p ≥ 0.05:「統計的に有意ではない」
効果量
  • Cohen's d:小(0.2)、中(0.5)、大(0.8)
  • R²:弱い(<0.3)、中程度(0.3-0.7)、強い(>0.7)
  • 相関:弱い(<0.3)、中程度(0.3-0.7)、強い(>0.7)

可視化

回帰プロット
analyzer.linear_regression(x='age', y='income')
analyzer.plot_regression('regression.png')
# Creates scatter plot with regression line and confidence interval
残差プロット
analyzer.plot_residuals('residuals.png')
# Checks regression assumptions (homoscedasticity)
箱ひげ図
analyzer.plot_boxplot(
    groups=['control', 'treatment_a', 'treatment_b'],
    value_col='score',
    output='boxplot.png'
)
分布プロット
analyzer.plot_distribution('scores', 'distribution.png')
# Histogram with normal curve overlay

レポート

包括的なレポートを生成します:

analyzer.load_csv('data.csv')
analyzer.t_test(group1='control', group2='treatment')
analyzer.linear_regression(x='hours', y='score')

# PDF report with all analyses
analyzer.generate_report('analysis_report.pdf', format='pdf')

# HTML report
analyzer.generate_report('analysis_report.html', format='html')

レポートには以下が含まれます:

  • 要約統計量
  • 解釈付きの検定結果
  • 可視化
  • 仮定の検証
  • 推奨事項

仮定の検証

仮定を自動的に検証します:

# T-test checks:
# - Normality (Shapiro-Wilk)
# - Equal variances (Levene's test)
# Warnings if assumptions violated

# ANOVA checks:
# - Normality per group
# - Homogeneity of variances
# Suggests non-parametric alternatives

# Regression checks:
# - Linearity
# - Homoscedasticity
# - Normality of residuals
# - Independence (Durbin-Watson)

依存関係

  • scipy>=1.10.0
  • statsmodels>=0.14.0
  • pandas>=2.0.0
  • numpy>=1.24.0
  • matplotlib>=3.7.0
  • seaborn>=0.12.0
  • reportlab>=4.0.0

コメント