Comprehensive Overview of Common ML Techniques
Comprehensive Overview of Common ML Techniques
1. Decision Trees
1. DecisionTreeClassifier: Creates a tree-based model for classification.
o Parameters:
o Code usage:
model.fit(X_train, y_train)
2. Random Forests
1. RandomForestClassifier: Constructs multiple decision trees and combines outputs
(ensemble learning).
o Parameters:
o Code usage:
model = RandomForestClassifier(n_estimators=100)
model.fit(X_train, y_train)
2. Feature Importance:
model.feature_importances_
o Parameters:
▪ C: Regularization parameter.
model.fit(X_train, y_train)
o Parameters:
model = KNeighborsClassifier(n_neighbors=5)
model.fit(X_train, y_train)
5. Logistic Regression
1. LogisticRegression: Models binary classification problems using the sigmoid function.
o Parameters:
model = LogisticRegression()
model.fit(X_train, y_train)
2. Predict Probabilities:
model.predict_proba(X_test)
6. Naive Bayes
1. GaussianNB: Implements the Gaussian Naive Bayes algorithm for continuous data.
model = GaussianNB()
model.fit(X_train, y_train)
model = MultinomialNB()
7. K-Means Clustering
1. KMeans: Performs clustering by minimizing within-cluster variance.
o Parameters:
model = KMeans(n_clusters=3)
model.fit(X)
labels = model.predict(X)
silhouette_score(X, labels)
o Parameters:
pca = PCA(n_components=2)
X_reduced = pca.fit_transform(X)
9. Neural Networks
Keras Example (Deep Learning)
model = Sequential([
MaxPooling2D((2, 2)),
Flatten(),
Dense(128, activation='relu'),
Dense(10, activation='softmax')
])
model = AdaBoostClassifier(n_estimators=50)
model.fit(X_train, y_train)
model = GradientBoostingClassifier()
model.fit(X_train, y_train)
2. Confusion Matrix:
from sklearn.metrics import confusion_matrix
confusion_matrix(y_test, y_pred)
auc(fpr, tpr)
Keras
1. Overview: A high-level neural networks API built on TensorFlow. Designed for fast
experimentation.
2. Key Features:
PyTorch
1. Overview: A deep learning framework with a dynamic computation graph, making it highly
flexible and easy to debug.
2. Key Features: