mirror of
https://github.com/frankwxu/AI4DigitalForensics.git
synced 2026-04-10 11:23:42 +00:00
fix cyfi445 lab 7
This commit is contained in:
@@ -217,14 +217,20 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 11,
|
"execution_count": null,
|
||||||
"id": "3aeb88da",
|
"id": "3aeb88da",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Scale features\n",
|
"# Scale features\n",
|
||||||
"scaler = StandardScaler()\n",
|
"scaler = StandardScaler()\n",
|
||||||
|
"# fit() computes the mean and std of each feature using the training data only.\n",
|
||||||
|
"# transform() applies the standardization formula to scale the data.\n",
|
||||||
|
"# fit_transform() does both in one step.\n",
|
||||||
"X_train = scaler.fit_transform(X_train)\n",
|
"X_train = scaler.fit_transform(X_train)\n",
|
||||||
|
"# Very important: we do not fit again on the test set.\n",
|
||||||
|
"# Instead, we use the same mean and std from the training set (stored inside scaler) to transform the test data.\n",
|
||||||
|
"# This prevents data leakage — making sure the test set stays “unseen” during training.\n",
|
||||||
"X_test = scaler.transform(X_test)\n",
|
"X_test = scaler.transform(X_test)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Convert to PyTorch tensors\n",
|
"# Convert to PyTorch tensors\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user