クイックスタート#
始めるには インストールガイド をご確認ください。
ヒント
ケモメトリクスは初めてですか? ステップバイステップの チュートリアルページ で学習できます。
ヒント
手元のツールを探索したいですか? 探索の概要 をご覧ください。
データの読み込み#
これは、発酵プロセスからの中赤外スペクトルの訓練セット(X_train)と関連する参照値(y_train)を読み込みます。
from chemotools.datasets import load_fermentation_train
X_train, y_train = load_fermentation_train()
ヒント
利用可能なデータセットをお探しですか? データセットカタログ をご覧ください。
スペクトルの前処理#
訓練データに前処理ステップを読み込み、定義し、適用します。ここでは、Savitzky-Golayフィルターを使用して、サンプルスペクトルの1次導関数を計算します。
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)
ヒント
前処理手法についてもっと知りたいですか? 手法インデックス をお読みください。
パイプラインの構築#
前処理とモデリングのステップを1つのパイプラインに統合します。
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 ワークフローを構築しました 🎯