DEV Community· Kaviya Satheeshkumar·· 3 小時前AI 評分48
Python ML Cheat Sheet Repo:涵蓋完整機器學習流程的速查表
The Python ML Cheat Sheet Repo You'll Actually Use
AI 導讀
一個 GitHub Python ML 速查表 Repo 整理了 9 份涵蓋完整機器學習流程的 Markdown 速查表,內容包括 NumPy、Pandas、Scikit-learn、資料預處理、模型評估及深度學習等。毋須設定或執行 notebook,用戶可在 GitHub 開啟查閲,亦可複製到本機離線使用。
正文
Every ML beginner hits the same wall: you know what you want to do, but you can't remember the exact syntax.
Is it fit_transform or transform? Which scaler do I use for outliers? How do I plot a confusion matrix again?
I got tired of Googling the same things, so I built a repo that has all of it in one place.
🔗 github.com/Kavi274/python-ml-cheatsheets
What's Inside
9 cheat sheets covering the full ML workflow:
1. NumPy
Arrays, indexing, broadcasting, linear algebra — the foundation of everything.
python
a = np.array([[1, 2, 3], [4, 5, 6]])
a[a > 3] # [4, 5, 6]
a.reshape(3, 2)
np.dot(A, B) # matrix multiplication
2. Pandas
DataFrames, groupby, merge, datetime, string ops.
df.groupby("city").agg({"sales": "sum", "profit": "mean"})
df.isnull().sum()
pd.merge(df1, df2, on="id", how="left")
3. Scikit-learn
Every major model, pipelines, cross-validation, and hyperparameter tuning.
pipe = Pipeline([
("scaler", StandardScaler()),
("model", RandomForestClassifier())
])
pipe.fit(X_train, y_train)
4. Matplotlib & Seaborn
Every plot type with copy-paste code — histograms, heatmaps, ROC curves, feature importance.
sns.heatmap(df.corr(), annot=True, fmt=".2f", cmap="coolwarm")
5. Data Preprocessing
Missing values, scaling, encoding, class imbalance — the full cleaning pipeline.
num_pipeline = Pipeline([
("impute", SimpleImputer(strategy="median")),
("scale", StandardScaler())
])
6. Feature Engineering
Datetime features, target encoding, cyclical encoding, PCA, SHAP-based selection.
df["month_sin"] = np.sin(2 * np.pi * df["month"] / 12)
df["month_cos"] = np.cos(2 * np.pi * df["month"] / 12)
7. Model Evaluation
ROC, precision-recall curves, confusion matrix, optimal threshold, SHAP explainability, calibration.
fpr, tpr, _ = roc_curve(y_test, y_prob)
roc_auc = auc(fpr, tpr)
8. Deep Learning (Keras)
CNNs, RNNs, transfer learning, callbacks, tf.data pipelines.
base_model = keras.applications.EfficientNetB0(
include_top=False, weights="imagenet"
)
base_model.trainable = False
9. Statistics for ML
Distributions, hypothesis tests, A/B testing, Bayes' theorem.
stat, p = stats.ttest_ind(group1, group2, equal_var=False)
print(f"p={p:.4f} — {'Significant' if p < 0.05 else 'Not significant'}")
---
How to Use It
No setup. No notebooks to run. Every cheat sheet is plain Markdown — just open it on GitHub and hit Ctrl+F.
Clone it locally if you want it offline:
git clone https://github.com/Kavi274/python-ml-cheatsheets.git
---
What's Next
Planning to add:
- PyTorch
- XGBoost / LightGBM
- Time Series (Prophet, statsmodels)
- HuggingFace Transformers
PRs are welcome — if you know a topic well, add a cheat sheet!
---
If this saves you even one Google search, consider leaving a ⭐ on GitHub — it helps others find it.
🔗 https://github.com/Kavi274/python-ml-cheatsheets
來源:DEV Community · dev.to