Junior — Middle
What machine learning algorithms have you applied in practice?
sobes.tech AI
Answer from AI
In practice, I have used several main machine learning algorithms:
- Linear regression for predicting numerical values, such as price or demand.
- Logistic regression for classification tasks, such as spam detection in emails.
- Decision trees and random forest for classification and regression, working well with tabular data.
- Support Vector Machine (SVM) for classification tasks with clear class separation.
- Clustering (K-means) for grouping data without labels.
- Neural networks (e.g., using TensorFlow or PyTorch) for more complex tasks, such as image or text processing.
An example of using logistic regression in Python with scikit-learn:
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
# Load data
X, y = load_iris(return_X_y=True)
# Split into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# Create and train the model
model = LogisticRegression(max_iter=200)
model.fit(X_train, y_train)
# Evaluate accuracy
accuracy = model.score(X_test, y_test)
print(f"Model accuracy: {accuracy:.2f}")