Overview

Metbit — Python API

Preprocess spectra, build PCA/OPLS-DA models, and visualize results with clean, high‑level functions.

Install with pip install metbit and jump into a typical workflow below.

Key Features

Data Processing

Baseline, calibration, normalization, preprocessing.

nmr_preprocessspec_normscaler

Statistical Models

PCA/OPLS-DA, cross‑validation, VIP.

metbitoplspls

Visualization

Scores/loadings, boxplots, STOCSY, ellipses.

plottingboxplotSTOCSY

Utilities

Univariate stats, VIP helpers, paths.

utility

Typical Workflow

  1. Preprocess your spectra (optional)
  2. Fit an OPLS‑DA model
  3. Assess VIP and visualize results
import pandas as pd
from metbit.nmr_preprocess import nmr_preprocessing
from metbit.metbit import opls_da

prep = nmr_preprocessing(...)
X, y = prep.X, prep.y

model = opls_da(
  X, y,
  features_name=list(X.columns), n_components=2,
  scaling_method='pareto', kfold=3,
  estimator='opls', random_state=94, auto_ncomp=True
)
model.fit()
vip_fig = model.vip_plot(threshold=1.0)
vip_fig.show()

Where Next

Get Started →Browse API