Home Knowledge Base Scikit-Learn (sklearn)

Scikit-Learn (sklearn) is the most widely used Python library for classical machine learning — providing a consistent, elegant API (fit/predict/transform) across every major algorithm (classification, regression, clustering, dimensionality reduction), comprehensive preprocessing tools (scaling, encoding, imputation), model selection utilities (cross-validation, grid search, train/test split), and pipeline infrastructure that chains preprocessing and modeling into reproducible workflows, serving as the essential foundation that every ML practitioner learns first.

What Is Scikit-Learn?

Core Modules

ModulePurposeKey Classes
ClassificationPredict discrete labelsLogisticRegression, RandomForestClassifier, SVC, GradientBoostingClassifier
RegressionPredict continuous valuesLinearRegression, Ridge, Lasso, SVR, RandomForestRegressor
ClusteringGroup unlabeled dataKMeans, DBSCAN, AgglomerativeClustering
Dimensionality ReductionReduce feature spacePCA, TSNE, UMAP (via umap-learn)
PreprocessingTransform featuresStandardScaler, MinMaxScaler, OneHotEncoder, LabelEncoder
Model SelectionEvaluate and tune modelscross_val_score, GridSearchCV, RandomizedSearchCV, train_test_split
MetricsScore predictionsaccuracy_score, f1_score, roc_auc_score, mean_squared_error
PipelineChain steps into workflowsPipeline, ColumnTransformer, make_pipeline
Feature SelectionSelect informative featuresSelectKBest, RFE, mutual_info_classif
ImputationHandle missing valuesSimpleImputer, KNNImputer, IterativeImputer

The Consistent API

from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC

# Every model works identically:
for Model in [RandomForestClassifier, LogisticRegression, SVC]:
    model = Model()
    model.fit(X_train, y_train)      # Train
    predictions = model.predict(X_test)  # Predict
    score = model.score(X_test, y_test)  # Evaluate

The Pipeline

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

pipe = Pipeline([
    ('scaler', StandardScaler()),
    ('model', RandomForestClassifier(n_estimators=100))
])
pipe.fit(X_train, y_train)  # Scaler fits + model trains
pipe.predict(X_test)        # Scaler transforms + model predicts

Scikit-Learn is the foundation of practical machine learning in Python — providing the consistent fit/predict/transform API, comprehensive algorithm coverage, and pipeline infrastructure that every ML practitioner depends on, with documentation so clear and an interface so elegant that it has become the standard that other ML libraries model their APIs after.

scikit learnclassicalml

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.