{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":39763,"databundleVersionId":11756775,"sourceType":"competition"}],"dockerImageVersionId":31012,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.metrics import mean_absolute_error\nfrom sklearn.preprocessing import StandardScaler\n\ntrain_data = pd.read_csv('/path/to/your/directory/waveform_data.csv')  # Update with the correct path\n\nprint(train_data.head())\nprint(train_data.info())\nprint(train_data.isnull().sum())\n\nplt.figure(figsize=(12, 6))\nplt.plot(train_data['x_1'])  # Replace 'x_1' with the actual column name\nplt.title('Seismic Waveform for x_1')\nplt.xlabel('Time')\nplt.ylabel('Amplitude')\nplt.grid()\nplt.show()\n\ntrain_data.fillna(train_data.mean(), inplace=True)\n\nscaler = StandardScaler()\nfeatures = train_data.drop(columns=['amplitude'])  # Replace 'amplitude' with the actual target column name\ntarget = train_data['amplitude']  # Replace with the actual target column name\n\nfeatures_scaled = scaler.fit_transform(features)\n\nX_train, X_val, y_train, y_val = train_test_split(features_scaled, target, test_size=0.2, random_state=42)\n\nmodel = LinearRegression()\nmodel.fit(X_train, y_train)\n\ny_pred = model.predict(X_val)\nmae = mean_absolute_error(y_val, y_pred)\nprint(f'Mean Absolute Error (Linear Regression): {mae}')\n\nrf_model = RandomForestRegressor(n_estimators=100, random_state=42)\nrf_model.fit(X_train, y_train)\n\ny_pred_rf = rf_model.predict(X_val)\nmae_rf = mean_absolute_error(y_val, y_pred_rf)\nprint(f'Mean Absolute Error (Random Forest): {mae_rf}')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-05-27T05:47:09.139759Z","iopub.execute_input":"2025-05-27T05:47:09.1401Z","iopub.status.idle":"2025-05-27T05:47:13.685723Z","shell.execute_reply.started":"2025-05-27T05:47:09.140066Z","shell.execute_reply":"2025-05-27T05:47:13.684242Z"}},"outputs":[],"execution_count":null}]}