Skip to content
Agentmart
Submit a tool

数据预处理

数学建模数据预处理,包含缺失值处理、异常值检测、标准化/归一化、特征工程

Skill by hongdotien10-hash

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/hongdotien10-hash-4e38b5

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

数学建模数据预处理,包含缺失值处理、异常值检测、标准化/归一化、特征工程

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/mrite-preprocess

What's inside

Skill name
数据预处理
Description
数学建模数据预处理,包含缺失值处理、异常值检测、标准化/归一化、特征工程
License
MIT
Instructions
224 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • name: only lowercase letters, digits and single hyphens allowed
  • name: "数据预处理" does not match folder "mrite-preprocess"

Files (1)

  • SKILL.md

SKILL.md (first lines)

# 数据预处理

## 目的

对原始数据进行系统化预处理,为建模提供清洁规整的输入数据。

## 预处理流程

### Step 1: 数据读取与理解

```python
import pandas as pd
import numpy as np
import chardet

# 自动检测编码(对CSV文件)
with open('文件.csv', 'rb') as f:
    result = chardet.detect(f.read())
    print(f"检测编码: {result['encoding']}")

# 读取数据
df = pd.read_excel('数据/data.xlsx', sheet_name='Sheet1')

# 基础信息
print(f"数据规模: {df.shape}")
print(f"列名: {list(df.columns)}")
print(f"数据类型:\n{df.dtypes}")
print(f"缺失值:\n{df.isnull().sum()}")
print(f"描述统计:\n{df.describe()}")
```

### Step 2: 数据清洗

#### 2.1 缺失值处理

```python
# 统计缺失情况
missing_ratio = df.isnull().sum() / len(df)
print("缺失比例:\n", missing_ratio)

# 策略选择
for col in df.columns:
    ratio = df[col].isnull().sum() / len(df)
    if ratio == 0:
        continue
    elif ratio < 0.05:  # <5%: 直接删除缺失行
        df = df.dropna(subset=[col])
        print(f"  [{col}] 缺失{ratio:.1%},删除缺失行")
    elif ratio < 0.20:  # 5%-20%: 插补
        if df[col].dtype in ['float64', 'int64']:
            df[col] = df[col].fillna(df[col].median())  # 数值列用中位数
        else:
            df[col] = df[col].fillna(df[col].mode()[0])  # 分类列用众数
        print(f"  [{col}] 缺失{ratio:.1%},已插补")
    else:  # >20%: 考虑删除该列
        print(f"  ⚠ [{col}] 缺失{ratio:.1%},比例过高,建议删除或特殊处理")
```

#### 2.2 异常值检测

```python
def detect_outliers(df, method='iqr'):
    """检测异常值"""
    outliers = {}
    for col in df.select_dtypes(include=[np.number]).columns:
        if method == 'iqr':
            Q1 = df[col].quantile(0.25)
            Q3 = df[col].quantile(0.75)
            IQR = Q3 - Q1
            lower = Q1 - 1.5 * IQR
            upper = Q3 + 1.5 * IQR
            mask = (df[col] < lower) | (df[col] > upper)
        elif method == 'zscore':
            from scipy import stats
            z = np.abs(stats.zscore(df[col].dropna()))
            mask = pd.Series(z > 3, index=df[col].dropna().index)

        if mask.sum() > 0:
            outliers[col] = {
                'count': mask.sum(),
                'ratio': mask.sum() / len(df),
                'indices': df[mask].index.tolist()
            }
    return outliers

outliers = detect_outliers(df, method='iqr')
for col, info in outliers.items():
    print(f"  [{col}] 异常值 {info['count']} 个 ({info['ratio']:.1%})")

# 处理异常值:使用中位数替换
for col in outliers:
    median = df[col].median()
    df.loc[df.index.isin(outliers[col]['indices']), col] = median
```

#### 2.3 重复值处理

```python
duplicates = df.duplicated().sum()
print(f"重复行: {duplicates}")
if duplicates > 0:
    df = df.drop_duplicates()
```

### Step 3: 标准化/归一化

#### Min-Max 归一化

\begin{equation}
x' = \frac{x - x_{min}}{x_{max} - x_{min}}
\end{equation}

```python
from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()
numeric_cols = df.select_dtypes(include=[np.number]).columns
df[numeric_cols] = scaler.fit_transform(df[numeric_cols])

From hongdotien10-hash/mathmodel-toolkit, MIT.

More from hongdotien10-hash/mathmodel-toolkit

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Jul 22, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from hongdotien10-hash

Cite this page

数据预处理 skill. Agent Mart. https://agentmart.dev/skills/hongdotien10-hash-4e38b5 (last updated 2026-10-24)