File size: 1,383 Bytes
c49b21b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Load normalized stock data
csv_path = 'data\\merged\\norm\\stocks_features_improved_normalized.csv'
df = pd.read_csv(csv_path)

# 1. Show basic info and head
print('Data shape:', df.shape)
print(df.head())

# 2. Feature distribution histograms
features = [
    'price_momentum', 'volume_price_ratio', 'daily_range', 'avg_sentiment', 'technical_strength'
]
existing_features = [f for f in features if f in df.columns]
if existing_features:
    df[existing_features].hist(bins=30, figsize=(12, 8))
    plt.suptitle('Feature Distributions')
    plt.tight_layout()
    plt.show()
else:
    print('No engineered features found for distribution plots.')

# 3. Correlation heatmap
if len(existing_features) > 1:
    plt.figure(figsize=(8, 6))
    sns.heatmap(df[existing_features].corr(), annot=True, cmap='coolwarm')
    plt.title('Feature Correlation Heatmap')
    plt.show()

# 4. Outlier boxplots for engineered features
for feat in existing_features:
    plt.figure(figsize=(6, 2))
    sns.boxplot(x=df[feat])
    plt.title(f'Boxplot: {feat}')
    plt.show()

# 5. Pairplot (if you have a target column, e.g., "target")
# Uncomment and adjust if you have a target/label
# sns.pairplot(df, vars=existing_features, hue='target')
# plt.show()

print('Visualization complete. You can add more plots as needed!')