Machine Learning works by finding patterns in data and using them to make predictions.
ML Workflow
- Collect data
- Clean and prepare data
- Choose a model
- Train the model
- Evaluate performance
- Make predictions
Machine Learning works by finding patterns in data and using them to make predictions.
# Simple ML example
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y)
# Train model
model = RandomForestClassifier()
model.fit(X_train, y_train)
# Predict
predictions = model.predict(X_test)
accuracy = accuracy_score(y_test, predictions)
print(f"Accuracy: {accuracy}")
# Simple ML concept def predict(weight, bias, x): return weight * x + bias # Training data: hours studied vs score hours = [1, 2, 3, 4, 5] scores = [2, 4, 5, 8, 9] # Simple training weight = 1.8 bias = 0.2 for h, s in zip(hours, scores): predicted = predict(weight, bias, h) print(f"Hours: {h}, Actual: {s}, Predicted: {predicted:.1f}")
What are the 6 steps of the ML workflow?
Collect data → Clean data → Choose model → Train → Evaluate → Predict
What does a machine learning model do?
ML models learn patterns from data to make predictions or decisions.
Training a model on labeled data where the correct answers are known. The model learns to map inputs to outputs.