feat: Add time-domain feature extraction functionality
This commit adds code to the `03_feature_extraction.ipynb` notebook to print time-domain features. The features include mean, max, peak, peak-to-peak, RMS, variance, standard deviation, power, crest factor, form factor, pulse indicator, margin, kurtosis, and skewness. The features are calculated using the `FeatureExtractor` class and displayed in a pandas DataFrame.
This commit is contained in:
@@ -186,6 +186,103 @@
|
|||||||
"plt.grid(True)\n",
|
"plt.grid(True)\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Print Time-domain Features"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 23,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div>\n",
|
||||||
|
"<style scoped>\n",
|
||||||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||||||
|
" vertical-align: middle;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe tbody tr th {\n",
|
||||||
|
" vertical-align: top;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe thead th {\n",
|
||||||
|
" text-align: right;\n",
|
||||||
|
" }\n",
|
||||||
|
"</style>\n",
|
||||||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||||||
|
" <thead>\n",
|
||||||
|
" <tr style=\"text-align: right;\">\n",
|
||||||
|
" <th></th>\n",
|
||||||
|
" <th>Mean</th>\n",
|
||||||
|
" <th>Max</th>\n",
|
||||||
|
" <th>Peak (Pm)</th>\n",
|
||||||
|
" <th>Peak-to-Peak (Pk)</th>\n",
|
||||||
|
" <th>RMS</th>\n",
|
||||||
|
" <th>Variance</th>\n",
|
||||||
|
" <th>Standard Deviation</th>\n",
|
||||||
|
" <th>Power</th>\n",
|
||||||
|
" <th>Crest Factor</th>\n",
|
||||||
|
" <th>Form Factor</th>\n",
|
||||||
|
" <th>Pulse Indicator</th>\n",
|
||||||
|
" <th>Margin</th>\n",
|
||||||
|
" <th>Kurtosis</th>\n",
|
||||||
|
" <th>Skewness</th>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </thead>\n",
|
||||||
|
" <tbody>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>0</th>\n",
|
||||||
|
" <td>0.448061</td>\n",
|
||||||
|
" <td>1.579213</td>\n",
|
||||||
|
" <td>1.579213</td>\n",
|
||||||
|
" <td>2.048687</td>\n",
|
||||||
|
" <td>0.819284</td>\n",
|
||||||
|
" <td>0.470467</td>\n",
|
||||||
|
" <td>0.723008</td>\n",
|
||||||
|
" <td>0.671226</td>\n",
|
||||||
|
" <td>1.927553</td>\n",
|
||||||
|
" <td>1.828509</td>\n",
|
||||||
|
" <td>3.524548</td>\n",
|
||||||
|
" <td>2.067638</td>\n",
|
||||||
|
" <td>1.917716</td>\n",
|
||||||
|
" <td>0.412307</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </tbody>\n",
|
||||||
|
"</table>\n",
|
||||||
|
"</div>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
" Mean Max Peak (Pm) Peak-to-Peak (Pk) RMS Variance \\\n",
|
||||||
|
"0 0.448061 1.579213 1.579213 2.048687 0.819284 0.470467 \n",
|
||||||
|
"\n",
|
||||||
|
" Standard Deviation Power Crest Factor Form Factor Pulse Indicator \\\n",
|
||||||
|
"0 0.723008 0.671226 1.927553 1.828509 3.524548 \n",
|
||||||
|
"\n",
|
||||||
|
" Margin Kurtosis Skewness \n",
|
||||||
|
"0 2.067638 1.917716 0.412307 "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 23,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"# Extract features using our class\n",
|
||||||
|
"extracted = FeatureExtractor(mock_df['SampleData'])\n",
|
||||||
|
"\n",
|
||||||
|
"# Format with pandas DataFramw\n",
|
||||||
|
"features = pd.DataFrame(extracted.features, index=[0])\n",
|
||||||
|
"features\n"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
Reference in New Issue
Block a user