机器学习环境搭建
目标
用最小可用环境支持前 1 个月学习,先保证能跑代码、能画图、能训练基础模型。
基础环境
- Python 3.10+
- Jupyter 或 VSCode
- Git
建议安装
pip install numpy pandas matplotlib scikit-learn jupyter notebook如果后续准备学 PyTorch:
pip install torch torchvision torchaudio建议验证
-
python --version -
pip --version -
jupyter notebook - 能在 Python 里导入
numpy - 能画一张简单折线图
最小验证代码
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3, 4])
y = x ** 2
print("x:", x)
print("y:", y)
plt.plot(x, y)
plt.title("first plot")
plt.show()建议目录结构
ml-study/
notebooks/
scripts/
data/
notes/常见问题
pip太慢:换国内源- 图显示不出来:确认 Jupyter/IDE 图形支持
- 包冲突:建议使用虚拟环境