What is Machine Learning?
Machine Learning (ML) is a subset of artificial intelligence that enables systems to learn and improve from experience without being explicitly programmed.
Types of Machine Learning
- Supervised Learning — learns from labeled data
- Unsupervised Learning — finds patterns in unlabeled data
- Reinforcement Learning — learns through trial and error
A Simple Example with scikit-learn
Here is a basic classification example:
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
# Load data
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
iris.data, iris.target, test_size=0.2, random_state=42
)
# Train model
clf = RandomForestClassifier(n_estimators=100)
clf.fit(X_train, y_train)
# Evaluate
predictions = clf.predict(X_test)
print(f"Accuracy: {accuracy_score(y_test, predictions):.2f}")
Popular Python ML Libraries
- scikit-learn — general-purpose ML
- TensorFlow — deep learning framework by Google
- PyTorch — deep learning framework by Meta
- pandas — data manipulation and analysis
Visit scikit-learn.org to get started.