快速开始#

请查看 安装指南 以开始使用。

提示

化学计量学新手?通过我们的分步 教程页面 来学习。

提示

想要探索触手可及的工具?请访问 探索概览

加载数据#

这将加载一个发酵过程中的中红外光谱训练集(X_train)及其相关的参考值(y_train)。

from chemotools.datasets import load_fermentation_train

X_train, y_train = load_fermentation_train()

提示

寻找可用的数据集?请查看 数据集目录

预处理光谱#

加载、定义并将预处理步骤应用于训练数据。这里我们使用 Savitzky-Golay 滤波器来计算样品光谱的一阶导数。

from chemotools.derivate import SavitzkyGolay

# Configure the preprocessing step
sg = SavitzkyGolay(window_size=3, polynomial_order=1, derivate_order=1)

# Fit and transform the training data
X_train_preprocessed = sg.fit_transform(X_train)

提示

想要了解更多预处理方法?请阅读 方法索引

构建管道#

将预处理和建模步骤组合到单个管道中。

from chemotools.derivate import SavitzkyGolay
from sklearn.cross_decomposition import PLSRegression
from sklearn.pipeline import make_pipeline

# Define the pipeline
pipeline = make_pipeline(
    SavitzkyGolay(window_size=3, polynomial_order=1, derivate_order=1),
    PLSRegression(n_components=2)
)

# Fit the pipeline to the training data
pipeline.fit(X_train, y_train)

# Prediction on the training data
y_train_pred = pipeline.predict(X_train)

提示

想要了解更多关于管道的信息?请打开 管道文章

提示

对模型优化感到好奇?请阅读 优化指南

恭喜!您刚刚在 Python 中构建了第一个 chemotools 工作流程 🎯