用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/personamanagmentlayer/pcl --skill data-science-expert命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | data-science-expert |
| version | 1.0.0 |
| description | Expert-level data science, analytics, visualization, and statistical modeling |
| category | ai |
| tags | ["data-science","analytics","visualization","statistics","pandas","numpy"] |
| allowed-tools | ["Read","Write","Edit","Bash(python:*)"] |
Expert guidance for data science, analytics, statistical modeling, and data visualization.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from typing import Dict, List
class DataCleaner:
"""Clean and preprocess data"""
def __init__(self, df: pd.DataFrame):
self.df = df.copy()
self.cleaning_log = []
def handle_missing_values(self, strategy: str = 'drop',
fill_value=None) -> pd.DataFrame:
"""Handle missing values"""
missing_before = self.df.isnull().sum().sum()
if strategy == 'drop':
self.df = self.df.dropna()
elif strategy == 'fill':
if fill_value is not None:
self.df = self.df.fillna(fill_value)
else:
# Fill numeric with median, categorical with mode
for col in self.df.columns:
.df[col].dtype [, ]:
.df[col].fillna(.df[col].median(), inplace=)
:
.df[col].fillna(.df[col].mode()[], inplace=)
missing_after = .df.isnull().().()
.cleaning_log.append()
.df
() -> pd.DataFrame:
before = (.df)
.df = .df.drop_duplicates()
after = (.df)
.cleaning_log.append()
.df
() -> pd.DataFrame:
before = (.df)
col columns:
method == :
Q1 = .df[col].quantile()
Q3 = .df[col].quantile()
IQR = Q3 - Q1
lower = Q1 - threshold * IQR
upper = Q3 + threshold * IQR
.df = .df[(.df[col] >= lower) & (.df[col] <= upper)]
method == :
z_scores = np.(stats.zscore(.df[col]))
.df = .df[z_scores < threshold]
after = (.df)
.cleaning_log.append()
.df
:
():
.df = df
() -> pd.DataFrame:
.df.describe(include=).T
() -> pd.DataFrame:
numeric_cols = .df.select_dtypes(include=[np.number]).columns
.df[numeric_cols].corr(method=method)
():
columns :
columns = .df.select_dtypes(include=[np.number]).columns
n_cols = (columns)
n_rows = (n_cols + ) //
fig, axes = plt.subplots(n_rows, , figsize=(, *n_rows))
axes = axes.flatten()
idx, col (columns):
sns.histplot(.df[col], kde=, ax=axes[idx])
axes[idx].set_title()
plt.tight_layout()
fig
():
corr = .correlation_analysis()
plt.figure(figsize=(, ))
sns.heatmap(corr, annot=, fmt=, cmap=,
center=, square=, linewidths=)
plt.title()
plt.gcf()
from sklearn.preprocessing import StandardScaler, LabelEncoder, OneHotEncoder
from sklearn.feature_selection import SelectKBest, f_classif, mutual_info_classif
class FeatureEngineer:
"""Engineer features for machine learning"""
def __init__(self, df: pd.DataFrame):
self.df = df.copy()
self.transformers = {}
def create_interaction_features(self, col1: str, col2: str) -> pd.Series:
"""Create interaction features"""
self.df[f'{col1}_x_{col2}'] = self.df[col1] * self.df[col2]
return self.df[f'{col1}_x_{col2}']
def create_polynomial_features(self, col: str, degree: int = 2) -> pd.DataFrame:
"""Create polynomial features"""
for d in range(2, degree + 1):
self.df[f'{col}_pow_{d}'] = self.df[col] ** d
return self.df
() -> pd.Series:
.df[] = pd.qcut(.df[col], q=n_bins,
labels=, duplicates=)
.df[]
() -> pd.DataFrame:
method == :
le = LabelEncoder()
.df[] = le.fit_transform(.df[col])
.transformers[col] = le
method == :
dummies = pd.get_dummies(.df[col], prefix=col, drop_first=)
.df = pd.concat([.df, dummies], axis=)
.df
() -> pd.DataFrame:
method == :
scaler = StandardScaler()
method == :
sklearn.preprocessing MinMaxScaler
scaler = MinMaxScaler()
.df[columns] = scaler.fit_transform(.df[columns])
.transformers[] = scaler
.df
() -> []:
method == :
scorer = f_classif
method == :
scorer = mutual_info_classif
selector = SelectKBest(scorer, k=k)
selector.fit(X, y)
selected_features = X.columns[selector.get_support()].tolist()
selected_features
from statsmodels.tsa.seasonal import seasonal_decompose
from statsmodels.tsa.stattools import adfuller
from statsmodels.tsa.arima.model import ARIMA
class TimeSeriesAnalyzer:
"""Analyze time series data"""
def __init__(self, data: pd.Series, freq: str = 'D'):
self.data = data
self.freq = freq
def decompose(self, model: str = 'additive'):
"""Decompose time series"""
result = seasonal_decompose(self.data, model=model, period=30)
return {
'trend': result.trend,
'seasonal': result.seasonal,
'residual': result.resid
}
def test_stationarity(self) -> dict:
"""Test for stationarity using Augmented Dickey-Fuller"""
result = adfuller(self.data.dropna())
return {
'adf_statistic': result[0],
'p_value': result[1],
'critical_values': result[4],
'is_stationary': result[1] < 0.05
}
def () -> pd.Series:
method == :
.data.diff().dropna()
method == :
np.log(.data)
method == :
np.log(.data).diff().dropna()
():
model = ARIMA(.data, order=order)
fitted_model = model.fit()
{
: fitted_model,
: fitted_model.aic,
: fitted_model.bic,
: fitted_model.summary()
}
() -> pd.Series:
model.forecast(steps=steps)
from scipy import stats
class ABTest:
"""Conduct A/B tests"""
def __init__(self, control: np.ndarray, treatment: np.ndarray):
self.control = control
self.treatment = treatment
def ttest(self) -> dict:
"""Two-sample t-test"""
statistic, p_value = stats.ttest_ind(self.control, self.treatment)
# Calculate confidence interval for difference
diff_mean = self.treatment.mean() - self.control.mean()
se_diff = np.sqrt(self.control.var()/len(self.control) +
self.treatment.var()/len(self.treatment))
ci_lower = diff_mean - 1.96 * se_diff
ci_upper = diff_mean + 1.96 * se_diff
return {
't_statistic': statistic,
'p_value': p_value,
'mean_control': self.control.mean(),
'mean_treatment': self.treatment.mean(),
'difference': diff_mean,
'ci_95': (ci_lower, ci_upper),
'significant': p_value < 0.05
}
def proportion_test() -> :
n_control = (.control)
n_treatment = (.treatment)
p_control = conversions_control / n_control
p_treatment = conversions_treatment / n_treatment
p_pooled = (conversions_control + conversions_treatment) / (n_control + n_treatment)
se = np.sqrt(p_pooled * ( - p_pooled) * (/n_control + /n_treatment))
z = (p_treatment - p_control) / se
p_value = * ( - stats.norm.cdf((z)))
{
: p_control,
: p_treatment,
: (p_treatment - p_control) / p_control * ,
: z,
: p_value,
: p_value <
}
❌ Not exploring data before modeling ❌ Ignoring data quality issues ❌ Data leakage in feature engineering ❌ Over-engineering features ❌ Misleading visualizations ❌ Not documenting analysis steps ❌ Ignoring business context