commit 420f38b4add209ffb95b36312160b27e1bcc90a2 Author: Zhongwei Li Date: Sat Nov 29 18:51:54 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..c6296c1 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "regression-analysis-tool", + "description": "Regression analysis and modeling", + "version": "1.0.0", + "author": { + "name": "Claude Code Plugins", + "email": "[email protected]" + }, + "skills": [ + "./skills" + ], + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..66ac2d4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# regression-analysis-tool + +Regression analysis and modeling diff --git a/commands/run-regression.md b/commands/run-regression.md new file mode 100644 index 0000000..7e9e4fa --- /dev/null +++ b/commands/run-regression.md @@ -0,0 +1,15 @@ +--- +description: Execute AI/ML task with intelligent automation +--- + +# AI/ML Task Executor + +You are an AI/ML specialist. When this command is invoked: + +1. Analyze the current context and requirements +2. Generate appropriate code for the ML task +3. Include data validation and error handling +4. Provide performance metrics and insights +5. Save artifacts and generate documentation + +Support modern ML frameworks and best practices. diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..64544c8 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,69 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/ai-ml/regression-analysis-tool", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "f27227f0e3dc76aa0eaadeb47f0fb8681c4d78d8", + "treeHash": "15901e9c649ee9d55035d312ed2aebcf6525fe1a531377ba7bc76352c8e69228", + "generatedAt": "2025-11-28T10:18:41.423936Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "regression-analysis-tool", + "description": "Regression analysis and modeling", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "1c87d843737bbfbbb510b2613e932eeb93f721db9d376a842ee7436940c7ed78" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "3c0ce9b8541f39a72e0bbdb71228f6642eb9db9c3dc933cfa01f3a3c9103bfa6" + }, + { + "path": "commands/run-regression.md", + "sha256": "043efb83e2f02fc6d0869c8a3a7388d6e49f6c809292b93dd6a97a1b142e5647" + }, + { + "path": "skills/regression-analysis-tool/SKILL.md", + "sha256": "b383bbf666ffce87ad46e1e454cdffd055bb99d454d203971caa907d6d604063" + }, + { + "path": "skills/regression-analysis-tool/references/README.md", + "sha256": "a7584189a0b9668266f4d379b9a978019fe48d2eeb66be13ce8b5e71cec160cc" + }, + { + "path": "skills/regression-analysis-tool/scripts/README.md", + "sha256": "282fe9b954f74234b4ef07a91f2ea22724625db437656625c82f2a43b6358b9a" + }, + { + "path": "skills/regression-analysis-tool/assets/example_dataset.csv", + "sha256": "e9f763a191d2ed5a88fa97a2fcf30f2e6f9fb5aaac4805845fb4846abcc79675" + }, + { + "path": "skills/regression-analysis-tool/assets/model_visualization_template.py", + "sha256": "8567d9847ca283fdc1d579c405477d7c2637c72056e073bdd5e96f109b5e58be" + }, + { + "path": "skills/regression-analysis-tool/assets/README.md", + "sha256": "0a3b6f4e1236619edc288f954f6af3c6d76ed49c54f267a1f059e726fcf1f321" + } + ], + "dirSha256": "15901e9c649ee9d55035d312ed2aebcf6525fe1a531377ba7bc76352c8e69228" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/regression-analysis-tool/SKILL.md b/skills/regression-analysis-tool/SKILL.md new file mode 100644 index 0000000..d0c806a --- /dev/null +++ b/skills/regression-analysis-tool/SKILL.md @@ -0,0 +1,56 @@ +--- +name: performing-regression-analysis +description: | + This skill empowers Claude to perform regression analysis and modeling using the regression-analysis-tool plugin. It analyzes datasets, generates appropriate regression models (linear, polynomial, etc.), validates the models, and provides performance metrics. Use this skill when the user explicitly requests regression analysis, prediction based on data, or mentions terms like "linear regression," "polynomial regression," "regression model," or "predictive modeling." This skill is also helpful when the user needs to understand the relationship between variables in a dataset. +allowed-tools: Read, Write, Edit, Grep, Glob, Bash +version: 1.0.0 +--- + +## Overview + +This skill enables Claude to analyze data, build regression models, and provide insights into the relationships between variables. It leverages the regression-analysis-tool plugin to automate the process and ensure best practices are followed. + +## How It Works + +1. **Data Analysis**: Claude analyzes the provided data to understand its structure and identify potential relationships between variables. +2. **Model Generation**: Based on the data, Claude generates appropriate regression models (e.g., linear, polynomial). +3. **Model Validation**: Claude validates the generated models to ensure their accuracy and reliability. +4. **Performance Reporting**: Claude provides performance metrics and insights into the model's effectiveness. + +## When to Use This Skill + +This skill activates when you need to: +- Perform regression analysis on a given dataset. +- Predict future values based on existing data using regression models. +- Understand the relationship between independent and dependent variables. +- Evaluate the performance of a regression model. + +## Examples + +### Example 1: Predicting House Prices + +User request: "Can you build a regression model to predict house prices based on square footage and number of bedrooms?" + +The skill will: +1. Analyze the provided data on house prices, square footage, and number of bedrooms. +2. Generate a regression model (likely multiple to compare) to predict house prices. +3. Provide performance metrics such as R-squared and RMSE. + +### Example 2: Analyzing Sales Trends + +User request: "I need to analyze the sales data for the past year and identify any trends using regression analysis." + +The skill will: +1. Analyze the provided sales data. +2. Generate a regression model to identify trends and patterns in the sales data. +3. Visualize the trend and report the equation and R-squared value. + +## Best Practices + +- **Data Preparation**: Ensure the data is clean and preprocessed before performing regression analysis. +- **Model Selection**: Choose the appropriate regression model based on the data and the problem. +- **Validation**: Always validate the model to ensure its accuracy and reliability. + +## Integration + +This skill works independently using the regression-analysis-tool plugin. It can be used in conjunction with other data analysis and visualization tools to provide a comprehensive understanding of the data. \ No newline at end of file diff --git a/skills/regression-analysis-tool/assets/README.md b/skills/regression-analysis-tool/assets/README.md new file mode 100644 index 0000000..1ab2a5d --- /dev/null +++ b/skills/regression-analysis-tool/assets/README.md @@ -0,0 +1,6 @@ +# Assets + +Bundled resources for regression-analysis-tool skill + +- [ ] example_dataset.csv: Example CSV dataset for demonstrating regression analysis. +- [ ] model_visualization_template.py: Python script template for visualizing the regression model and its performance. diff --git a/skills/regression-analysis-tool/assets/example_dataset.csv b/skills/regression-analysis-tool/assets/example_dataset.csv new file mode 100644 index 0000000..6edc7ef --- /dev/null +++ b/skills/regression-analysis-tool/assets/example_dataset.csv @@ -0,0 +1,21 @@ +# Example dataset for regression analysis with the regression-analysis-tool plugin. +# This dataset contains independent variables (X1, X2, X3) and a dependent variable (Y). +# Use this dataset as a starting point for running the /run-regression command. +# You can replace this data with your own dataset. Ensure your data is clean and properly formatted. +# Columns should be comma-separated. The first row should be the header row. +# If you need to include text values, enclose them in double quotes. +# This example contains 10 rows, but your dataset can contain more. + +X1,X2,X3,Y +10,20,30,100 +15,25,35,120 +20,30,40,140 +25,35,45,160 +30,40,50,180 +35,45,55,200 +40,50,60,220 +45,55,65,240 +50,60,70,260 +55,65,75,280 +#Add your own data below. +#,,, \ No newline at end of file diff --git a/skills/regression-analysis-tool/assets/model_visualization_template.py b/skills/regression-analysis-tool/assets/model_visualization_template.py new file mode 100644 index 0000000..113ad0d --- /dev/null +++ b/skills/regression-analysis-tool/assets/model_visualization_template.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python3 + +""" +This script provides a template for visualizing regression model results. + +It includes functionalities for plotting predicted vs. actual values, +residual plots, and other visualizations to assess model performance. +""" + +import argparse +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd +import seaborn as sns +from sklearn.metrics import mean_squared_error, r2_score +from typing import Optional + + +def plot_predicted_vs_actual( + y_true: np.ndarray, y_pred: np.ndarray, title: str = "Predicted vs. Actual" +) -> None: + """ + Plots predicted values against actual values. + + Args: + y_true (np.ndarray): Array of actual values. + y_pred (np.ndarray): Array of predicted values. + title (str, optional): Title of the plot. Defaults to "Predicted vs. Actual". + """ + try: + plt.figure(figsize=(8, 6)) + plt.scatter(y_true, y_pred, alpha=0.5) + plt.xlabel("Actual Values") + plt.ylabel("Predicted Values") + plt.title(title) + plt.plot([y_true.min(), y_true.max()], [y_true.min(), y_true.max()], "k--", lw=2) + plt.show() + except Exception as e: + print(f"Error plotting predicted vs. actual: {e}") + + +def plot_residuals( + y_true: np.ndarray, y_pred: np.ndarray, title: str = "Residual Plot" +) -> None: + """ + Plots the residuals (errors) of the regression model. + + Args: + y_true (np.ndarray): Array of actual values. + y_pred (np.ndarray): Array of predicted values. + title (str, optional): Title of the plot. Defaults to "Residual Plot". + """ + try: + residuals = y_true - y_pred + plt.figure(figsize=(8, 6)) + plt.scatter(y_pred, residuals, alpha=0.5) + plt.xlabel("Predicted Values") + plt.ylabel("Residuals") + plt.title(title) + plt.axhline(y=0, color="k", linestyle="--") # Add a horizontal line at y=0 + plt.show() + except Exception as e: + print(f"Error plotting residuals: {e}") + + +def visualize_regression_results( + y_true: np.ndarray, y_pred: np.ndarray, model_name: str = "Regression Model" +) -> None: + """ + Visualizes the regression results, including predicted vs. actual and residual plots. + + Args: + y_true (np.ndarray): Array of actual values. + y_pred (np.ndarray): Array of predicted values. + model_name (str, optional): Name of the regression model. Defaults to "Regression Model". + """ + try: + plot_predicted_vs_actual( + y_true, y_pred, title=f"{model_name}: Predicted vs. Actual" + ) + plot_residuals(y_true, y_pred, title=f"{model_name}: Residual Plot") + + # Calculate and print metrics + mse = mean_squared_error(y_true, y_pred) + r2 = r2_score(y_true, y_pred) + print(f"{model_name} - Mean Squared Error: {mse:.4f}") + print(f"{model_name} - R-squared: {r2:.4f}") + + except Exception as e: + print(f"Error visualizing regression results: {e}") + + +def main( + actual_values_file: str, predicted_values_file: str, model_name: str = "Regression Model" +) -> None: + """ + Main function to load data and visualize regression results. + + Args: + actual_values_file (str): Path to the CSV file containing actual values. + predicted_values_file (str): Path to the CSV file containing predicted values. + model_name (str, optional): Name of the regression model. Defaults to "Regression Model". + """ + try: + # Load data from CSV files + actual_df = pd.read_csv(actual_values_file) + predicted_df = pd.read_csv(predicted_values_file) + + # Assuming the CSVs have a single column with the values + y_true = actual_df.iloc[:, 0].values + y_pred = predicted_df.iloc[:, 0].values + + visualize_regression_results(y_true, y_pred, model_name=model_name) + + except FileNotFoundError: + print("Error: One or both of the input files were not found.") + except pd.errors.EmptyDataError: + print("Error: One or both of the input files are empty.") + except KeyError: + print("Error: The specified column does not exist in the input file.") + except Exception as e: + print(f"An unexpected error occurred: {e}") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Visualize regression model results from CSV files." + ) + parser.add_argument( + "--actual", + type=str, + required=True, + help="Path to the CSV file containing actual values.", + ) + parser.add_argument( + "--predicted", + type=str, + required=True, + help="Path to the CSV file containing predicted values.", + ) + parser.add_argument( + "--model_name", + type=str, + default="Regression Model", + help="Name of the regression model (optional).", + ) + + args = parser.parse_args() + + # Create dummy data files for example usage + example_actual_data = pd.DataFrame({"actual": np.random.rand(100)}) + example_predicted_data = pd.DataFrame({"predicted": example_actual_data["actual"] + np.random.normal(0, 0.1, 100)}) + example_actual_data.to_csv("actual_values.csv", index=False) + example_predicted_data.to_csv("predicted_values.csv", index=False) + + # Example usage with command-line arguments + main(args.actual, args.predicted, args.model_name) + # Clean up dummy data files + import os + os.remove("actual_values.csv") + os.remove("predicted_values.csv") \ No newline at end of file diff --git a/skills/regression-analysis-tool/references/README.md b/skills/regression-analysis-tool/references/README.md new file mode 100644 index 0000000..6062967 --- /dev/null +++ b/skills/regression-analysis-tool/references/README.md @@ -0,0 +1,7 @@ +# References + +Bundled resources for regression-analysis-tool skill + +- [ ] regression_metrics.md: Detailed explanation of regression metrics (R-squared, MSE, RMSE, MAE) and their interpretation. +- [ ] regression_model_selection.md: Guide on selecting the appropriate regression model (linear, polynomial, etc.) based on the data characteristics. +- [ ] data_preprocessing.md: Best practices for data preprocessing steps like handling missing values, outlier detection, and feature scaling. diff --git a/skills/regression-analysis-tool/scripts/README.md b/skills/regression-analysis-tool/scripts/README.md new file mode 100644 index 0000000..78bc0b0 --- /dev/null +++ b/skills/regression-analysis-tool/scripts/README.md @@ -0,0 +1,7 @@ +# Scripts + +Bundled resources for regression-analysis-tool skill + +- [ ] validate_data.py: Script to validate the input dataset for regression analysis, checking for missing values, outliers, and data type consistency. +- [ ] generate_model.py: Script to automatically generate and train regression models based on the input data and specified parameters. +- [ ] evaluate_model.py: Script to evaluate the performance of the trained regression model using metrics like R-squared, Mean Squared Error (MSE), etc.