هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
Know what a model is
A model is a function learned from examples. Training finds its parameters from data; inference (prediction) uses it on new data.
| Word | Meaning |
|---|---|
| Dataset | The examples (rows) used to learn |
| Feature | One input column (age, price, number of logins) |
| Label | The right answer the model should learn (fraud yes/no) |
| Training | Fitting the model on the training data |
| Validation / test set | Data kept apart to measure the model honestly |
| Inference | Using the trained model on new data |
| Weights / artifact | The saved model file |
Know the main kinds of ML
The kind of problem decides the model type and the metrics.
| Kind | Example | Metric |
|---|---|---|
| Classification | Is this login an attack? | Accuracy, precision, recall, F1 |
| Regression | How many orders tomorrow? | MAE, RMSE |
| Clustering | Group similar servers by behaviour | Silhouette |
| Anomaly detection | Unusual traffic | Precision at top-N |
| Large language models | Summarise tickets, chat | Human rating, task success |
Train a tiny model
With scikit-learn, training is a few lines — the hard parts are data and operations.
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
import joblib
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = RandomForestClassifier(n_estimators=100, random_state=42).fit(X_train, y_train)
print("accuracy", accuracy_score(y_test, model.predict(X_test)))
joblib.dump(model, "model.joblib")Understand why ML needs operations
Code alone does not define an ML system — data and model change too. That is why normal CI/CD is not enough.
- The same code with new data gives a different model.
- A model that was good can get worse when the world changes (drift).
- Results must be reproducible: which data, code and settings made this model?
- Models need special hardware (GPUs) and serving infrastructure.
تذكّر
MLOps = DevOps practices (versioning, CI/CD, monitoring, IaC) applied to data and models too.