| ... | @@ -168,16 +168,7 @@ Step 5: Handle Missing or Infinite Values |
... | @@ -168,16 +168,7 @@ Step 5: Handle Missing or Infinite Values |
|
|
After generating the synthetic data, any missing or invalid values (such as NaN or inf) are replaced with the respective feature's mean from the original dataset to ensure data integrity.
|
|
After generating the synthetic data, any missing or invalid values (such as NaN or inf) are replaced with the respective feature's mean from the original dataset to ensure data integrity.
|
|
|
|
|
|
|
|
|
|
|
|
|
### Replace NaN or infinite values in each column of synthetic data with mean values of respective columns
|
|
### Replace NaN or infinite values in each column of synthetic data with mean {width=809 height=194}
|
|
|
synthetic_data = synthetic_data.replace([np.inf, -np.inf], np.nan)
|
|
|
|
|
synthetic_data = synthetic_data.fillna({
|
|
|
|
|
'Open': data['Open'].mean(),
|
|
|
|
|
'High': data['High'].mean(),
|
|
|
|
|
'Low': data['Low'].mean(),
|
|
|
|
|
'Close': data['Close'].mean(),
|
|
|
|
|
'Adj Close': data['Adj Close'].mean(),
|
|
|
|
|
'Volume': abs(data['Volume'].mean())
|
|
|
|
|
})
|
|
|
|
|
Purpose: This step ensures that the synthetic data is clean and free of missing or extreme values that could interfere with model training.
|
|
Purpose: This step ensures that the synthetic data is clean and free of missing or extreme values that could interfere with model training.
|
|
|
Step 6: Create DataFrame for Synthetic Data
|
|
Step 6: Create DataFrame for Synthetic Data
|
|
|
The synthetic data for all features (Open, High, Low, Close, Adj Close, and Volume) is compiled into a DataFrame, which is then concatenated with the original data.
|
|
The synthetic data for all features (Open, High, Low, Close, Adj Close, and Volume) is compiled into a DataFrame, which is then concatenated with the original data.
|
| ... | |
... | |
| ... | | ... | |