Edwin Salguero commited on
Commit ·
f35bff2
0
Parent(s):
Initial commit: FRED_ML project without binary files
Browse filesFiles changed (43)
- .gitattributesAdded+35
- .gitignoreAdded+78
- LICENSEAdded+21
- README.mdAdded+150
- __pycache__/config.cpython-39.pycAdded
- __pycache__/fred_data_collector_v2.cpython-39.pycAdded
- config/__pycache__/settings.cpython-39.pycAdded
- config/pipeline.yamlAdded+16
- config/settings.pyAdded+10
- data/exports/fred_data_20250710_221702.csvAdded
- data/exports/fred_data_20250710_223022.csvAdded
- data/exports/fred_data_20250710_223149.csvAdded
- data/exports/regression_summary.txtAdded+28
- requirements.txtAdded+13
- scripts/run_advanced_analytics.pyAdded+56
- scripts/run_eda.pyAdded+80
- scripts/run_fred_pipeline.pyAdded+10
- scripts/run_segmentation.pyAdded+91
- scripts/run_statistical_modeling.pyAdded+104
- scripts/run_time_series.pyAdded+80
- src/__init__.pyAdded+21
- src/__pycache__/__init__.cpython-39.pycAdded
- src/analysis/__init__.pyAdded+7
- src/analysis/__pycache__/__init__.cpython-39.pycAdded
- src/analysis/__pycache__/advanced_analytics.cpython-39.pycAdded
- src/analysis/__pycache__/economic_analyzer.cpython-39.pycAdded
- src/analysis/advanced_analytics.pyAdded+517
- src/analysis/economic_analyzer.pyAdded+201
- src/core/__init__.pyAdded+7
- src/core/__pycache__/__init__.cpython-39.pycAdded
- src/core/__pycache__/base_pipeline.cpython-39.pycAdded
- src/core/__pycache__/fred_client.cpython-39.pycAdded
- src/core/__pycache__/fred_pipeline.cpython-39.pycAdded
- src/core/base_pipeline.pyAdded+38
- src/core/fred_client.pyAdded+288
- src/core/fred_pipeline.pyAdded+88
- src/utils/__init__.pyAdded+7
- src/utils/examples.pyAdded+139
- src/visualization/__init__.pyAdded+5
- tests/__pycache__/test_fred_api.cpython-39-pytest-7.4.0.pycAdded
- tests/__pycache__/test_fredapi_library.cpython-39-pytest-7.4.0.pycAdded
- tests/test_fred_api.pyAdded+115
- tests/test_fredapi_library.pyAdded+84
1234567891011121314151617181920212223242526272829303132333435*.7z filter=lfs diff=lfs merge=lfs -text*.arrow filter=lfs diff=lfs merge=lfs -text*.bin filter=lfs diff=lfs merge=lfs -text*.bz2 filter=lfs diff=lfs merge=lfs -text*.ckpt filter=lfs diff=lfs merge=lfs -text*.ftz filter=lfs diff=lfs merge=lfs -text*.gz filter=lfs diff=lfs merge=lfs -text*.h5 filter=lfs diff=lfs merge=lfs -text*.joblib filter=lfs diff=lfs merge=lfs -text*.lfs.* filter=lfs diff=lfs merge=lfs -text*.mlmodel filter=lfs diff=lfs merge=lfs -text*.model filter=lfs diff=lfs merge=lfs -text*.msgpack filter=lfs diff=lfs merge=lfs -text*.npy filter=lfs diff=lfs merge=lfs -text*.npz filter=lfs diff=lfs merge=lfs -text*.onnx filter=lfs diff=lfs merge=lfs -text*.ot filter=lfs diff=lfs merge=lfs -text*.parquet filter=lfs diff=lfs merge=lfs -text*.pb filter=lfs diff=lfs merge=lfs -text*.pickle filter=lfs diff=lfs merge=lfs -text*.pkl filter=lfs diff=lfs merge=lfs -text*.pt filter=lfs diff=lfs merge=lfs -text*.pth filter=lfs diff=lfs merge=lfs -text*.rar filter=lfs diff=lfs merge=lfs -text*.safetensors filter=lfs diff=lfs merge=lfs -textsaved_model/**/* filter=lfs diff=lfs merge=lfs -text*.tar.* filter=lfs diff=lfs merge=lfs -text*.tar filter=lfs diff=lfs merge=lfs -text*.tflite filter=lfs diff=lfs merge=lfs -text*.tgz filter=lfs diff=lfs merge=lfs -text*.wasm filter=lfs diff=lfs merge=lfs -text*.xz filter=lfs diff=lfs merge=lfs -text*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778# Python__pycache__/*.py[cod]*$py.class*.so.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/*.egg-info/.installed.cfg*.eggMANIFEST
# Virtual environments.env.venvenv/venv/ENV/env.bak/venv.bak/
# IDEs.vscode/.idea/*.swp*.swo*~
# OS.DS_Store.DS_Store?._*.Spotlight-V100.Trashesehthumbs.dbThumbs.db
# Jupyter Notebook.ipynb_checkpoints
# Data filesdata/exports/*.pngdata/exports/*.jpgdata/exports/*.jpegdata/exports/*.gifdata/exports/*.svgdata/exports/*.pdfdata/processed/*.csvdata/raw/*
# Logslogs/*.log*.log
# Model files*.pkl*.pickle*.joblib*.h5*.hdf5*.model
# Temporary files*.tmp*.temptemp/tmp/ 123456789101112131415161718192021MIT License
Copyright (c) 2025 Edwin Salguero
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150# FRED Economic Data Analysis Tool
A comprehensive Python tool for collecting, analyzing, and visualizing Federal Reserve Economic Data (FRED) using the FRED API.
## Features
- **Data Collection**: Fetch economic indicators from FRED API- **Data Analysis**: Generate summary statistics and insights- **Visualization**: Create time series plots and charts- **Data Export**: Save data to CSV format- **Flexible Configuration**: Easy customization of indicators and date ranges
## Setup
### 1. Install Dependencies
```bashpip install -r requirements.txt```
### 2. API Key Configuration
Your FRED API key is already configured in `config.py`:- API Key: `acf8bbec7efe3b6dfa6ae083e7152314`
### 3. Project Structure
```economic_output_datasets/├── config.py # Configuration settings├── fred_data_collector.py # Main data collection script├── requirements.txt # Python dependencies├── README.md # This file├── data/ # Output directory for CSV files└── plots/ # Output directory for visualizations```
## Usage
### Basic Usage
Run the main script to collect and analyze economic data:
```bashpython fred_data_collector.py```
This will:- Fetch data for key economic indicators (GDP, Unemployment Rate, CPI, Federal Funds Rate, 10-Year Treasury Rate)- Generate summary statistics- Create visualizations- Save data to CSV files
### Custom Analysis
You can customize the analysis by modifying the script:
```pythonfrom fred_data_collector import FREDDataCollector
# Initialize collectorcollector = FREDDataCollector()
# Custom series and date rangecustom_series = ['GDP', 'UNRATE', 'CPIAUCSL']start_date = '2020-01-01'end_date = '2024-01-01'
# Run analysisdf, summary = collector.run_analysis( series_ids=custom_series, start_date=start_date, end_date=end_date)```
## Available Economic Indicators
The tool includes these common economic indicators:
| Series ID | Description ||-----------|-------------|| GDP | Gross Domestic Product || UNRATE | Unemployment Rate || CPIAUCSL | Consumer Price Index || FEDFUNDS | Federal Funds Rate || DGS10 | 10-Year Treasury Rate || DEXUSEU | US/Euro Exchange Rate || PAYEMS | Total Nonfarm Payrolls || INDPRO | Industrial Production || M2SL | M2 Money Stock || PCE | Personal Consumption Expenditures |
## Output Files
### Data Files- CSV files saved in the `data/` directory- Timestamped filenames (e.g., `fred_economic_data_20241201_143022.csv`)
### Visualization Files- PNG plots saved in the `plots/` directory- High-resolution charts with economic indicator time series
## API Rate Limits
The FRED API has rate limits:- 120 requests per minute- 1000 requests per day
The tool includes error handling for rate limit issues.
## Configuration
Edit `config.py` to customize:- API key (if needed)- Default date ranges- Output directories- Default indicators
## Dependencies
- `fredapi`: FRED API client- `pandas`: Data manipulation- `numpy`: Numerical computing- `matplotlib`: Plotting- `seaborn`: Statistical visualization- `jupyter`: Interactive notebooks (optional)
## Error Handling
The tool includes comprehensive error handling for:- API connection issues- Invalid series IDs- Rate limit exceeded- Data format errors
## Contributing
To add new features:1. Extend the `FREDDataCollector` class2. Add new methods for specific analysis3. Update the configuration as needed
## License
This project is for educational and research purposes. Please respect FRED API terms of service.
## Support
For issues with the FRED API, visit: https://fred.stlouisfed.org/docs/api/ 12345678910111213141516fred: api_key: "acf8bbec7efe3b6dfa6ae083e7152314" series: - GDP - UNRATE - CPIAUCSL - FEDFUNDS - DGS10 start_date: "2010-01-01" end_date: "2024-01-01" output_dir: "data/processed" export_dir: "data/exports" schedule: "0 6 * * *" # Every day at 6am UTClogging: level: INFO file: logs/pipeline.log 12345678910# FRED API ConfigurationFRED_API_KEY = "acf8bbec7efe3b6dfa6ae083e7152314"
# Data settingsDEFAULT_START_DATE = "2010-01-01"DEFAULT_END_DATE = "2024-01-01"
# Output settingsOUTPUT_DIR = "data"PLOTS_DIR = "plots" 12345678910111213141516171819202122232425262728 OLS Regression Results ==============================================================================Dep. Variable: GDP R-squared: 0.971Model: OLS Adj. R-squared: 0.970Method: Least Squares F-statistic: 839.9Date: Thu, 10 Jul 2025 Prob (F-statistic): 5.55e-76Time: 22:30:42 Log-Likelihood: -903.30No. Observations: 105 AIC: 1817.Df Residuals: 100 BIC: 1830.Df Model: 4 Covariance Type: nonrobust ============================================================================== coef std err t P>|t| [0.025 0.975]------------------------------------------------------------------------------const -328.8855 630.799 -0.521 0.603 -1580.374 922.603UNRATE -21.7142 79.789 -0.272 0.786 -180.013 136.584CPIAUCSL 85.7935 2.036 42.144 0.000 81.755 89.832FEDFUNDS 492.3433 92.591 5.317 0.000 308.646 676.041DGS10 -883.8622 122.881 -7.193 0.000 -1127.655 -640.070==============================================================================Omnibus: 12.409 Durbin-Watson: 2.138Prob(Omnibus): 0.002 Jarque-Bera (JB): 13.297Skew: 0.746 Prob(JB): 0.00130Kurtosis: 3.902 Cond. No. 812.==============================================================================
Notes:[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.12345678910111213fredapi==0.4.2pandas==2.1.4numpy==1.24.3matplotlib==3.7.2seaborn==0.12.2jupyter==1.0.0python-dotenv==1.0.0requests==2.31.0PyYAML==6.0.2APScheduler==3.10.4scikit-learn==1.3.0scipy==1.11.1statsmodels==0.14.0 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556#!/usr/bin/env python"""Advanced Analytics Runner for FRED Economic DataRuns comprehensive statistical analysis, modeling, and insights extraction."""
import osimport sysimport globsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))
from analysis.advanced_analytics import AdvancedAnalytics
def find_latest_data(): """Find the most recent FRED data file.""" data_files = glob.glob('data/processed/fred_data_*.csv') if not data_files: raise FileNotFoundError("No FRED data files found. Run the pipeline first.") # Get the most recent file latest_file = max(data_files, key=os.path.getctime) print(f"Using data file: {latest_file}") return latest_file
def main(): """Run the complete advanced analytics workflow.""" print("=" * 80) print("FRED ECONOMIC DATA - ADVANCED ANALYTICS") print("=" * 80) try: # Find the latest data file data_file = find_latest_data() # Initialize analytics analytics = AdvancedAnalytics(data_path=data_file) # Run complete analysis results = analytics.run_complete_analysis() print("\n" + "=" * 80) print("ANALYTICS COMPLETE!") print("=" * 80) print("Generated outputs:") print(" 📊 data/exports/insights_report.txt - Comprehensive insights") print(" 📈 data/exports/clustering_analysis.png - Clustering results") print(" 📉 data/exports/time_series_decomposition.png - Time series decomposition") print(" 🔮 data/exports/time_series_forecast.png - Time series forecast") print("\nKey findings have been saved to data/exports/insights_report.txt") except Exception as e: print(f"Error running analytics: {e}") sys.exit(1)
if __name__ == "__main__": main() 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980#!/usr/bin/env python"""Run EDA: Distributions, skewness, kurtosis, correlations, PCA/t-SNE"""import osimport sysimport globsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))import pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsfrom sklearn.decomposition import PCAfrom sklearn.preprocessing import StandardScaler
# Find latest processed data filedef find_latest_data(): data_files = glob.glob('data/processed/fred_data_*.csv') if not data_files: raise FileNotFoundError("No FRED data files found. Run the pipeline first.") return max(data_files, key=os.path.getctime)
def main(): print("="*60) print("FRED EDA: Distributions, Skewness, Kurtosis, Correlations, PCA") print("="*60) data_file = find_latest_data() print(f"Using data file: {data_file}") df = pd.read_csv(data_file, index_col=0, parse_dates=True) df_clean = df.dropna() # 1. Distributions, Skewness, Kurtosis desc = df.describe() skew = df.skew() kurt = df.kurtosis() print("\nDescriptive Statistics:\n", desc) print("\nSkewness:") print(skew) print("\nKurtosis:") print(kurt) # Plot distributions for col in df.columns: plt.figure(figsize=(8,4)) sns.histplot(df[col].dropna(), kde=True) plt.title(f"Distribution of {col}") plt.savefig(f"data/exports/distribution_{col}.png", dpi=200, bbox_inches='tight') plt.close() # 2. Correlation matrices pearson_corr = df.corr(method='pearson') spearman_corr = df.corr(method='spearman') print("\nPearson Correlation Matrix:\n", pearson_corr.round(3)) print("\nSpearman Correlation Matrix:\n", spearman_corr.round(3)) plt.figure(figsize=(8,6)) sns.heatmap(pearson_corr, annot=True, cmap='coolwarm', center=0) plt.title('Pearson Correlation Matrix') plt.tight_layout() plt.savefig('data/exports/pearson_corr_matrix.png', dpi=200) plt.close() plt.figure(figsize=(8,6)) sns.heatmap(spearman_corr, annot=True, cmap='coolwarm', center=0) plt.title('Spearman Correlation Matrix') plt.tight_layout() plt.savefig('data/exports/spearman_corr_matrix.png', dpi=200) plt.close() # 3. PCA for visualization scaler = StandardScaler() scaled = scaler.fit_transform(df_clean) pca = PCA(n_components=2) pca_result = pca.fit_transform(scaled) pca_df = pd.DataFrame(pca_result, columns=['PC1', 'PC2'], index=df_clean.index) plt.figure(figsize=(8,6)) plt.scatter(pca_df['PC1'], pca_df['PC2'], alpha=0.5) plt.xlabel('PC1') plt.ylabel('PC2') plt.title('PCA Projection (2D)') plt.tight_layout() plt.savefig('data/exports/pca_2d.png', dpi=200) plt.close() print("\nEDA complete. Outputs saved to data/exports/.")
if __name__ == "__main__": main() 12345678910#!/usr/bin/env pythonimport osimport syssys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))from core.fred_pipeline import FREDPipeline
if __name__ == "__main__": config_path = os.path.join(os.path.dirname(__file__), '..', 'config', 'pipeline.yaml') pipeline = FREDPipeline(config_path) pipeline.run() 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091#!/usr/bin/env python"""Run Segmentation: K-means clustering, elbow method, silhouette score, PCA visualization"""import osimport sysimport globsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsfrom sklearn.cluster import KMeansfrom sklearn.metrics import silhouette_scorefrom sklearn.decomposition import PCAfrom sklearn.preprocessing import StandardScaler
def find_latest_data(): data_files = glob.glob('data/processed/fred_data_*.csv') if not data_files: raise FileNotFoundError("No FRED data files found. Run the pipeline first.") return max(data_files, key=os.path.getctime)
def main(): print("="*60) print("FRED Segmentation: K-means, Elbow, Silhouette, PCA Visualization") print("="*60) data_file = find_latest_data() print(f"Using data file: {data_file}") df = pd.read_csv(data_file, index_col=0, parse_dates=True) df_clean = df.dropna() if df_clean.shape[0] < 10 or df_clean.shape[1] < 2: print("Not enough data for clustering (need at least 10 rows and 2 columns after dropna). Skipping.") return scaler = StandardScaler() scaled_data = scaler.fit_transform(df_clean) # Elbow and silhouette inertias = [] silhouette_scores = [] k_range = range(2, min(11, len(df_clean)//10+1)) for k in k_range: kmeans = KMeans(n_clusters=k, random_state=42) kmeans.fit(scaled_data) inertias.append(kmeans.inertia_) silhouette_scores.append(silhouette_score(scaled_data, kmeans.labels_)) # Plot elbow and silhouette plt.figure(figsize=(12,4)) plt.subplot(1,2,1) plt.plot(list(k_range), inertias, 'bo-') plt.xlabel('Number of Clusters (k)') plt.ylabel('Inertia') plt.title('Elbow Method') plt.grid(True) plt.subplot(1,2,2) plt.plot(list(k_range), silhouette_scores, 'ro-') plt.xlabel('Number of Clusters (k)') plt.ylabel('Silhouette Score') plt.title('Silhouette Analysis') plt.grid(True) plt.tight_layout() plt.savefig('data/exports/clustering_analysis.png', dpi=200) plt.close() # Choose optimal k optimal_k = list(k_range)[np.argmax(silhouette_scores)] print(f"Optimal number of clusters: {optimal_k}") print(f"Best silhouette score: {max(silhouette_scores):.3f}") # Final clustering kmeans_optimal = KMeans(n_clusters=optimal_k, random_state=42) cluster_labels = kmeans_optimal.fit_predict(scaled_data) df_clustered = df_clean.copy() df_clustered['Cluster'] = cluster_labels # Cluster stats cluster_stats = df_clustered.groupby('Cluster').agg(['mean', 'std']) print("\nCluster Characteristics:") print(cluster_stats.round(3)) # PCA visualization pca = PCA(n_components=2) pca_result = pca.fit_transform(scaled_data) plt.figure(figsize=(8,6)) scatter = plt.scatter(pca_result[:,0], pca_result[:,1], c=cluster_labels, cmap='tab10', alpha=0.7) plt.xlabel('PC1') plt.ylabel('PC2') plt.title('Clusters Visualized with PCA') plt.legend(*scatter.legend_elements(), title="Cluster") plt.tight_layout() plt.savefig('data/exports/clusters_pca.png', dpi=200) plt.close() print("\nSegmentation complete. Outputs saved to data/exports/.")
if __name__ == "__main__": main() 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104#!/usr/bin/env python"""Run Statistical Modeling: Linear regression, diagnostics, p-values, confidence intervals, plots"""import osimport sysimport globsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsfrom sklearn.linear_model import LinearRegressionfrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import StandardScalerimport statsmodels.api as smfrom scipy import statsfrom statsmodels.stats.diagnostic import het_breuschpaganfrom statsmodels.stats.outliers_influence import variance_inflation_factor
def find_latest_data(): data_files = glob.glob('data/processed/fred_data_*.csv') if not data_files: raise FileNotFoundError("No FRED data files found. Run the pipeline first.") return max(data_files, key=os.path.getctime)
def main(): print("="*60) print("FRED Statistical Modeling: Linear Regression & Diagnostics") print("="*60) data_file = find_latest_data() print(f"Using data file: {data_file}") df = pd.read_csv(data_file, index_col=0, parse_dates=True) df_clean = df.dropna() target_var = 'GDP' if target_var not in df_clean.columns: print(f"Target variable '{target_var}' not found in data.") return feature_cols = [col for col in df_clean.columns if col != target_var] X = df_clean[feature_cols] y = df_clean[target_var] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) # Fit linear regression model = LinearRegression() model.fit(X_train, y_train) y_pred_train = model.predict(X_train) y_pred_test = model.predict(X_test) # Model performance r2_train = model.score(X_train, y_train) r2_test = model.score(X_test, y_test) print(f"R² (Train): {r2_train:.4f} | R² (Test): {r2_test:.4f}") # Coefficients print("\nCoefficients:") for feature, coef in zip(feature_cols, model.coef_): print(f" {feature}: {coef:.4f}") print(f" Intercept: {model.intercept_:.4f}") # Statsmodels for p-values and CIs X_with_const = sm.add_constant(X_train) model_sm = sm.OLS(y_train, X_with_const).fit() print("\nStatistical Significance:") print(model_sm.summary().tables[1]) # Save summary table with open('data/exports/regression_summary.txt', 'w') as f: f.write(str(model_sm.summary())) # Residuals residuals = y_train - y_pred_train # Normality test _, p_value_norm = stats.normaltest(residuals) print(f"Normality test (p-value): {p_value_norm:.4f}") # VIF vif_data = [] for i in range(X_train.shape[1]): try: vif = variance_inflation_factor(X_train.values, i) vif_data.append(vif) except: vif_data.append(np.nan) print("\nVariance Inflation Factors:") for feature, vif in zip(feature_cols, vif_data): print(f" {feature}: {vif:.3f}") # Homoscedasticity try: _, p_value_het = het_breuschpagan(residuals, X_with_const) print(f"Homoscedasticity test (p-value): {p_value_het:.4f}") except: print("Homoscedasticity test failed") # Diagnostic plots plt.figure(figsize=(12,4)) plt.subplot(1,2,1) plt.scatter(y_pred_train, residuals, alpha=0.5) plt.axhline(0, color='red', linestyle='--') plt.xlabel('Fitted Values') plt.ylabel('Residuals') plt.title('Residuals vs Fitted') plt.subplot(1,2,2) stats.probplot(residuals, dist="norm", plot=plt) plt.title('Normal Q-Q') plt.tight_layout() plt.savefig('data/exports/regression_diagnostics.png', dpi=200) plt.close() print("\nStatistical modeling complete. Outputs saved to data/exports/.")
if __name__ == "__main__": main() 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980#!/usr/bin/env python"""Run Time Series Analysis: Decomposition, ARIMA forecasting, plots"""import osimport sysimport globsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'src'))import pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom statsmodels.tsa.seasonal import seasonal_decomposefrom statsmodels.tsa.arima.model import ARIMA
def find_latest_data(): data_files = glob.glob('data/processed/fred_data_*.csv') if not data_files: raise FileNotFoundError("No FRED data files found. Run the pipeline first.") return max(data_files, key=os.path.getctime)
def main(): print("="*60) print("FRED Time Series Analysis: Decomposition & ARIMA Forecasting") print("="*60) data_file = find_latest_data() print(f"Using data file: {data_file}") df = pd.read_csv(data_file, index_col=0, parse_dates=True) target_var = 'GDP' if target_var not in df.columns: print(f"Target variable '{target_var}' not found in data.") return ts_data = df[target_var].dropna() if len(ts_data) < 50: print("Insufficient data for time series analysis (need at least 50 points). Skipping.") return print(f"Time series length: {len(ts_data)} observations") print(f"Date range: {ts_data.index.min()} to {ts_data.index.max()}") # Decomposition try: if ts_data.index.freq is None: ts_monthly = ts_data.resample('M').mean() else: ts_monthly = ts_data decomposition = seasonal_decompose(ts_monthly, model='additive', period=12) fig, axes = plt.subplots(4, 1, figsize=(12, 10)) decomposition.observed.plot(ax=axes[0], title='Original Time Series') decomposition.trend.plot(ax=axes[1], title='Trend') decomposition.seasonal.plot(ax=axes[2], title='Seasonality') decomposition.resid.plot(ax=axes[3], title='Residuals') plt.tight_layout() plt.savefig('data/exports/time_series_decomposition.png', dpi=200, bbox_inches='tight') plt.close() print("Decomposition plot saved.") except Exception as e: print(f"Decomposition failed: {e}") # ARIMA Forecasting try: model = ARIMA(ts_monthly, order=(1, 1, 1)) fitted_model = model.fit() print(f"ARIMA Model Summary:\n{fitted_model.summary()}") forecast_steps = min(12, len(ts_monthly) // 4) forecast = fitted_model.forecast(steps=forecast_steps) conf_int = fitted_model.get_forecast(steps=forecast_steps).conf_int() plt.figure(figsize=(12, 6)) ts_monthly.plot(label='Historical Data') forecast.plot(label='Forecast', color='red') plt.fill_between(forecast.index, conf_int.iloc[:, 0], conf_int.iloc[:, 1], alpha=0.3, color='red', label='Confidence Interval') plt.title(f'{target_var} - ARIMA Forecast') plt.legend() plt.grid(True) plt.tight_layout() plt.savefig('data/exports/time_series_forecast.png', dpi=200, bbox_inches='tight') plt.close() print("Forecast plot saved.") except Exception as e: print(f"ARIMA modeling failed: {e}") print("\nTime series analysis complete. Outputs saved to data/exports/.")
if __name__ == "__main__": main() 123456789101112131415161718192021"""FRED Economic Data Analysis Package
A comprehensive tool for collecting, analyzing, and visualizing Federal Reserve Economic Data (FRED) using the FRED API.
Author: Economic Data TeamVersion: 1.0.0"""
__version__ = "1.0.0"__author__ = "Economic Data Team"__email__ = "data-team@company.com"
from .core.fred_client import FREDDataCollectorV2from .analysis.advanced_analytics import AdvancedAnalytics
__all__ = [ 'FREDDataCollectorV2', 'AdvancedAnalytics',] 1234567"""Economic data analysis and visualization tools."""
from .advanced_analytics import AdvancedAnalytics
__all__ = ['AdvancedAnalytics'] 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517#!/usr/bin/env python3"""Advanced Analytics Module for FRED Economic DataPerforms comprehensive statistical analysis, modeling, and insights extraction."""
import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsfrom scipy import statsfrom sklearn.preprocessing import StandardScalerfrom sklearn.decomposition import PCAfrom sklearn.cluster import KMeansfrom sklearn.metrics import silhouette_scorefrom sklearn.linear_model import LinearRegressionfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import r2_score, mean_squared_errorimport statsmodels.api as smfrom statsmodels.tsa.seasonal import seasonal_decomposefrom statsmodels.tsa.arima.model import ARIMAfrom statsmodels.stats.diagnostic import het_breuschpaganfrom statsmodels.stats.outliers_influence import variance_inflation_factorimport warningswarnings.filterwarnings('ignore')
class AdvancedAnalytics: """ Comprehensive analytics class for FRED economic data. Performs EDA, statistical modeling, segmentation, and time series analysis. """ def __init__(self, data_path=None, df=None): """Initialize with data path or DataFrame.""" if df is not None: self.df = df elif data_path: self.df = pd.read_csv(data_path, index_col=0, parse_dates=True) else: raise ValueError("Must provide either data_path or DataFrame") self.scaler = StandardScaler() self.results = {} def perform_eda(self): """Perform comprehensive Exploratory Data Analysis.""" print("=" * 60) print("EXPLORATORY DATA ANALYSIS") print("=" * 60) # Basic info print(f"\nDataset Shape: {self.df.shape}") print(f"Date Range: {self.df.index.min()} to {self.df.index.max()}") print(f"Variables: {list(self.df.columns)}") # Descriptive statistics print("\n" + "=" * 40) print("DESCRIPTIVE STATISTICS") print("=" * 40) desc_stats = self.df.describe() print(desc_stats) # Skewness and Kurtosis print("\n" + "=" * 40) print("SKEWNESS AND KURTOSIS") print("=" * 40) skewness = self.df.skew() kurtosis = self.df.kurtosis() for col in self.df.columns: print(f"{col}:") print(f" Skewness: {skewness[col]:.3f}") print(f" Kurtosis: {kurtosis[col]:.3f}") # Correlation Analysis print("\n" + "=" * 40) print("CORRELATION ANALYSIS") print("=" * 40) # Pearson correlation pearson_corr = self.df.corr(method='pearson') print("\nPearson Correlation Matrix:") print(pearson_corr.round(3)) # Spearman correlation spearman_corr = self.df.corr(method='spearman') print("\nSpearman Correlation Matrix:") print(spearman_corr.round(3)) # Store results self.results['eda'] = { 'descriptive_stats': desc_stats, 'skewness': skewness, 'kurtosis': kurtosis, 'pearson_corr': pearson_corr, 'spearman_corr': spearman_corr } return self.results['eda'] def perform_dimensionality_reduction(self, method='pca', n_components=2): """Perform dimensionality reduction for visualization.""" print("\n" + "=" * 40) print(f"DIMENSIONALITY REDUCTION ({method.upper()})") print("=" * 40) # Prepare data (remove NaN values) df_clean = self.df.dropna() if method.lower() == 'pca': # PCA pca = PCA(n_components=n_components) scaled_data = self.scaler.fit_transform(df_clean) pca_result = pca.fit_transform(scaled_data) print(f"Explained variance ratio: {pca.explained_variance_ratio_}") print(f"Total explained variance: {sum(pca.explained_variance_ratio_):.3f}") # Create DataFrame with PCA results pca_df = pd.DataFrame( pca_result, columns=[f'PC{i+1}' for i in range(n_components)], index=df_clean.index ) self.results['pca'] = { 'components': pca_df, 'explained_variance': pca.explained_variance_ratio_, 'feature_importance': pd.DataFrame( pca.components_.T, columns=[f'PC{i+1}' for i in range(n_components)], index=df_clean.columns ) } return self.results['pca'] return None def perform_statistical_modeling(self, target_var='GDP', test_size=0.2): """Perform linear regression with comprehensive diagnostics.""" print("\n" + "=" * 40) print("STATISTICAL MODELING - LINEAR REGRESSION") print("=" * 40) # Prepare data df_clean = self.df.dropna() if target_var not in df_clean.columns: print(f"Target variable '{target_var}' not found in dataset") return None # Prepare features and target feature_cols = [col for col in df_clean.columns if col != target_var] X = df_clean[feature_cols] y = df_clean[target_var] # Split data X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=test_size, random_state=42 ) # Fit linear regression model = LinearRegression() model.fit(X_train, y_train) # Predictions y_pred_train = model.predict(X_train) y_pred_test = model.predict(X_test) # Model performance r2_train = r2_score(y_train, y_pred_train) r2_test = r2_score(y_test, y_pred_test) rmse_train = np.sqrt(mean_squared_error(y_train, y_pred_train)) rmse_test = np.sqrt(mean_squared_error(y_test, y_pred_test)) print(f"\nModel Performance:") print(f"R² (Training): {r2_train:.4f}") print(f"R² (Test): {r2_test:.4f}") print(f"RMSE (Training): {rmse_train:.4f}") print(f"RMSE (Test): {rmse_test:.4f}") # Coefficients print(f"\nCoefficients:") for feature, coef in zip(feature_cols, model.coef_): print(f" {feature}: {coef:.4f}") print(f" Intercept: {model.intercept_:.4f}") # Statistical significance using statsmodels X_with_const = sm.add_constant(X_train) model_sm = sm.OLS(y_train, X_with_const).fit() print(f"\nStatistical Significance:") print(model_sm.summary().tables[1]) # Assumption tests print(f"\n" + "=" * 30) print("REGRESSION ASSUMPTIONS") print("=" * 30) # 1. Normality of residuals residuals = y_train - y_pred_train _, p_value_norm = stats.normaltest(residuals) print(f"Normality test (p-value): {p_value_norm:.4f}") # 2. Multicollinearity (VIF) vif_data = [] for i in range(X_train.shape[1]): try: vif = variance_inflation_factor(X_train.values, i) vif_data.append(vif) except: vif_data.append(np.nan) print(f"\nVariance Inflation Factors:") for feature, vif in zip(feature_cols, vif_data): print(f" {feature}: {vif:.3f}") # 3. Homoscedasticity try: _, p_value_het = het_breuschpagan(residuals, X_with_const) print(f"\nHomoscedasticity test (p-value): {p_value_het:.4f}") except: p_value_het = np.nan print(f"\nHomoscedasticity test failed") # Store results self.results['regression'] = { 'model': model, 'model_sm': model_sm, 'performance': { 'r2_train': r2_train, 'r2_test': r2_test, 'rmse_train': rmse_train, 'rmse_test': rmse_test }, 'coefficients': dict(zip(feature_cols, model.coef_)), 'assumptions': { 'normality_p': p_value_norm, 'homoscedasticity_p': p_value_het, 'vif': dict(zip(feature_cols, vif_data)) } } return self.results['regression'] def perform_clustering(self, max_k=10): """Perform clustering analysis with optimal k selection.""" print("\n" + "=" * 40) print("CLUSTERING ANALYSIS") print("=" * 40) # Prepare data df_clean = self.df.dropna() if df_clean.shape[0] < 10 or df_clean.shape[1] < 2: print("Not enough data for clustering (need at least 10 rows and 2 columns after dropna). Skipping.") self.results['clustering'] = None return None try: scaled_data = self.scaler.fit_transform(df_clean) except Exception as e: print(f"Scaling failed: {e}") self.results['clustering'] = None return None # Find optimal k using elbow method and silhouette score inertias = [] silhouette_scores = [] k_range = range(2, min(max_k + 1, len(df_clean) // 10 + 1)) if len(k_range) < 2: print("Not enough data for multiple clusters. Skipping clustering.") self.results['clustering'] = None return None try: for k in k_range: kmeans = KMeans(n_clusters=k, random_state=42) kmeans.fit(scaled_data) inertias.append(kmeans.inertia_) silhouette_scores.append(silhouette_score(scaled_data, kmeans.labels_)) # Plot elbow curve only if there are results if inertias and silhouette_scores: plt.figure(figsize=(12, 4)) plt.subplot(1, 2, 1) plt.plot(list(k_range), inertias, 'bo-') plt.xlabel('Number of Clusters (k)') plt.ylabel('Inertia') plt.title('Elbow Method') plt.grid(True) plt.subplot(1, 2, 2) plt.plot(list(k_range), silhouette_scores, 'ro-') plt.xlabel('Number of Clusters (k)') plt.ylabel('Silhouette Score') plt.title('Silhouette Analysis') plt.grid(True) plt.tight_layout() plt.savefig('data/exports/clustering_analysis.png', dpi=300, bbox_inches='tight') plt.show() # Choose optimal k (highest silhouette score) optimal_k = list(k_range)[np.argmax(silhouette_scores)] print(f"Optimal number of clusters: {optimal_k}") print(f"Best silhouette score: {max(silhouette_scores):.3f}") # Perform clustering with optimal k kmeans_optimal = KMeans(n_clusters=optimal_k, random_state=42) cluster_labels = kmeans_optimal.fit_predict(scaled_data) # Add cluster labels to data df_clustered = df_clean.copy() df_clustered['Cluster'] = cluster_labels # Cluster characteristics print(f"\nCluster Characteristics:") cluster_stats = df_clustered.groupby('Cluster').agg(['mean', 'std']) print(cluster_stats.round(3)) # Store results self.results['clustering'] = { 'optimal_k': optimal_k, 'silhouette_score': max(silhouette_scores), 'cluster_labels': cluster_labels, 'clustered_data': df_clustered, 'cluster_stats': cluster_stats, 'inertias': inertias, 'silhouette_scores': silhouette_scores } return self.results['clustering'] except Exception as e: print(f"Clustering failed: {e}") self.results['clustering'] = None return None def perform_time_series_analysis(self, target_var='GDP'): """Perform comprehensive time series analysis.""" print("\n" + "=" * 40) print("TIME SERIES ANALYSIS") print("=" * 40) if target_var not in self.df.columns: print(f"Target variable '{target_var}' not found") self.results['time_series'] = None return None # Prepare time series data ts_data = self.df[target_var].dropna() if len(ts_data) < 50: print("Insufficient data for time series analysis (need at least 50 points). Skipping.") self.results['time_series'] = None return None print(f"Time series length: {len(ts_data)} observations") print(f"Date range: {ts_data.index.min()} to {ts_data.index.max()}") # 1. Time Series Decomposition print(f"\nTime Series Decomposition:") try: # Resample to monthly data if needed if ts_data.index.freq is None: ts_monthly = ts_data.resample('M').mean() else: ts_monthly = ts_data decomposition = seasonal_decompose(ts_monthly, model='additive', period=12) # Plot decomposition fig, axes = plt.subplots(4, 1, figsize=(12, 10)) decomposition.observed.plot(ax=axes[0], title='Original Time Series') decomposition.trend.plot(ax=axes[1], title='Trend') decomposition.seasonal.plot(ax=axes[2], title='Seasonality') decomposition.resid.plot(ax=axes[3], title='Residuals') plt.tight_layout() plt.savefig('data/exports/time_series_decomposition.png', dpi=300, bbox_inches='tight') plt.show() except Exception as e: print(f"Decomposition failed: {e}") # 2. ARIMA Modeling print(f"\nARIMA Modeling:") try: # Fit ARIMA model model = ARIMA(ts_monthly, order=(1, 1, 1)) fitted_model = model.fit() print(f"ARIMA Model Summary:") print(fitted_model.summary()) # Forecast forecast_steps = min(12, len(ts_monthly) // 4) forecast = fitted_model.forecast(steps=forecast_steps) conf_int = fitted_model.get_forecast(steps=forecast_steps).conf_int() # Plot forecast plt.figure(figsize=(12, 6)) ts_monthly.plot(label='Historical Data') forecast.plot(label='Forecast', color='red') plt.fill_between(forecast.index, conf_int.iloc[:, 0], conf_int.iloc[:, 1], alpha=0.3, color='red', label='Confidence Interval') plt.title(f'{target_var} - ARIMA Forecast') plt.legend() plt.grid(True) plt.tight_layout() plt.savefig('data/exports/time_series_forecast.png', dpi=300, bbox_inches='tight') plt.show() # Store results self.results['time_series'] = { 'model': fitted_model, 'forecast': forecast, 'confidence_intervals': conf_int, 'decomposition': decomposition if 'decomposition' in locals() else None } except Exception as e: print(f"ARIMA modeling failed: {e}") self.results['time_series'] = None return self.results.get('time_series') def generate_insights_report(self): """Generate comprehensive insights report in layman's terms.""" print("\n" + "=" * 60) print("COMPREHENSIVE INSIGHTS REPORT") print("=" * 60) insights = [] # EDA Insights if 'eda' in self.results and self.results['eda'] is not None: insights.append("EXPLORATORY DATA ANALYSIS INSIGHTS:") insights.append("-" * 40) # Correlation insights pearson_corr = self.results['eda']['pearson_corr'] high_corr_pairs = [] for i in range(len(pearson_corr.columns)): for j in range(i+1, len(pearson_corr.columns)): corr_val = pearson_corr.iloc[i, j] if abs(corr_val) > 0.7: high_corr_pairs.append((pearson_corr.columns[i], pearson_corr.columns[j], corr_val)) if high_corr_pairs: insights.append("Strong correlations found:") for var1, var2, corr in high_corr_pairs: insights.append(f" • {var1} and {var2}: {corr:.3f}") else: insights.append("No strong correlations (>0.7) found between variables.") else: insights.append("EDA could not be performed or returned no results.") # Regression Insights if 'regression' in self.results and self.results['regression'] is not None: insights.append("\nREGRESSION MODEL INSIGHTS:") insights.append("-" * 40) reg_results = self.results['regression'] r2_test = reg_results['performance']['r2_test'] insights.append(f"Model Performance:") insights.append(f" • The model explains {r2_test:.1%} of the variation in the target variable") if r2_test > 0.7: insights.append(" • This is considered a good model fit") elif r2_test > 0.5: insights.append(" • This is considered a moderate model fit") else: insights.append(" • This model has limited predictive power") # Assumption insights assumptions = reg_results['assumptions'] if assumptions['normality_p'] > 0.05: insights.append(" • Residuals are normally distributed (assumption met)") else: insights.append(" • Residuals are not normally distributed (assumption violated)") else: insights.append("Regression modeling could not be performed or returned no results.") # Clustering Insights if 'clustering' in self.results and self.results['clustering'] is not None: insights.append("\nCLUSTERING INSIGHTS:") insights.append("-" * 40) cluster_results = self.results['clustering'] optimal_k = cluster_results['optimal_k'] silhouette_score = cluster_results['silhouette_score'] insights.append(f"Optimal number of clusters: {optimal_k}") insights.append(f"Cluster quality score: {silhouette_score:.3f}") if silhouette_score > 0.5: insights.append(" • Clusters are well-separated and distinct") elif silhouette_score > 0.3: insights.append(" • Clusters show moderate separation") else: insights.append(" • Clusters may not be well-defined") else: insights.append("Clustering could not be performed or returned no results.") # Time Series Insights if 'time_series' in self.results and self.results['time_series'] is not None: insights.append("\nTIME SERIES INSIGHTS:") insights.append("-" * 40) insights.append(" • Time series decomposition shows trend, seasonality, and random components") insights.append(" • ARIMA model provides future forecasts with confidence intervals") insights.append(" • Forecasts can be used for planning and decision-making") else: insights.append("Time series analysis could not be performed or returned no results.") # Print insights for insight in insights: print(insight) # Save insights to file with open('data/exports/insights_report.txt', 'w') as f: f.write('\n'.join(insights)) return insights def run_complete_analysis(self): """Run the complete advanced analytics workflow.""" print("Starting comprehensive advanced analytics...") # 1. EDA self.perform_eda() # 2. Dimensionality reduction self.perform_dimensionality_reduction() # 3. Statistical modeling self.perform_statistical_modeling() # 4. Clustering self.perform_clustering() # 5. Time series analysis self.perform_time_series_analysis() # 6. Generate insights self.generate_insights_report() print("\n" + "=" * 60) print("ANALYSIS COMPLETE!") print("=" * 60) print("Check the following outputs:") print(" • data/exports/insights_report.txt - Comprehensive insights") print(" • data/exports/clustering_analysis.png - Clustering results") print(" • data/exports/time_series_decomposition.png - Time series decomposition") print(" • data/exports/time_series_forecast.png - Time series forecast") return self.results 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201#!/usr/bin/env python3"""Quick Start Guide for FRED Economic Data AnalysisDemonstrates how to load and analyze the collected data"""
import pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport sysimport ossys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from core.fred_client import FREDDataCollectorV2from datetime import datetime, timedelta
def load_latest_data(): """Load the most recent data file.""" import os import glob # Find the most recent data file data_files = glob.glob('data/fred_economic_data_*.csv') if not data_files: print("No data files found. Run the collector first.") return None latest_file = max(data_files, key=os.path.getctime) print(f"Loading data from: {latest_file}") df = pd.read_csv(latest_file, index_col=0, parse_dates=True) return df
def analyze_gdp_trends(df): """Analyze GDP trends.""" print("\n=== GDP Analysis ===") if 'GDP' not in df.columns: print("GDP data not available") return gdp_data = df['GDP'].dropna() print(f"GDP Data Points: {len(gdp_data)}") print(f"Date Range: {gdp_data.index.min()} to {gdp_data.index.max()}") print(f"Latest GDP: ${gdp_data.iloc[-1]:,.2f} billion") print(f"GDP Growth (last 5 years): {((gdp_data.iloc[-1] / gdp_data.iloc[-20]) - 1) * 100:.2f}%") # Plot GDP trend plt.figure(figsize=(12, 6)) gdp_data.plot(linewidth=2) plt.title('US GDP Over Time') plt.ylabel('GDP (Billions of Dollars)') plt.grid(True, alpha=0.3) plt.tight_layout() plt.show()
def analyze_unemployment(df): """Analyze unemployment trends.""" print("\n=== Unemployment Analysis ===") if 'UNRATE' not in df.columns: print("Unemployment data not available") return unrate_data = df['UNRATE'].dropna() print(f"Unemployment Data Points: {len(unrate_data)}") print(f"Current Unemployment Rate: {unrate_data.iloc[-1]:.1f}%") print(f"Average Unemployment Rate: {unrate_data.mean():.1f}%") print(f"Lowest Rate: {unrate_data.min():.1f}%") print(f"Highest Rate: {unrate_data.max():.1f}%") # Plot unemployment trend plt.figure(figsize=(12, 6)) unrate_data.plot(linewidth=2, color='red') plt.title('US Unemployment Rate Over Time') plt.ylabel('Unemployment Rate (%)') plt.grid(True, alpha=0.3) plt.tight_layout() plt.show()
def analyze_inflation(df): """Analyze inflation trends using CPI.""" print("\n=== Inflation Analysis (CPI) ===") if 'CPIAUCSL' not in df.columns: print("CPI data not available") return cpi_data = df['CPIAUCSL'].dropna() # Calculate year-over-year inflation cpi_yoy = cpi_data.pct_change(periods=12) * 100 print(f"CPI Data Points: {len(cpi_data)}") print(f"Current CPI: {cpi_data.iloc[-1]:.2f}") print(f"Current YoY Inflation: {cpi_yoy.iloc[-1]:.2f}%") print(f"Average YoY Inflation: {cpi_yoy.mean():.2f}%") # Plot inflation trend fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(12, 10)) cpi_data.plot(ax=ax1, linewidth=2, color='green') ax1.set_title('Consumer Price Index (CPI)') ax1.set_ylabel('CPI') ax1.grid(True, alpha=0.3) cpi_yoy.plot(ax=ax2, linewidth=2, color='orange') ax2.set_title('Year-over-Year Inflation Rate') ax2.set_ylabel('Inflation Rate (%)') ax2.grid(True, alpha=0.3) plt.tight_layout() plt.show()
def analyze_interest_rates(df): """Analyze interest rate trends.""" print("\n=== Interest Rate Analysis ===") rates_data = {} if 'FEDFUNDS' in df.columns: rates_data['Federal Funds Rate'] = df['FEDFUNDS'].dropna() if 'DGS10' in df.columns: rates_data['10-Year Treasury'] = df['DGS10'].dropna() if not rates_data: print("No interest rate data available") return for name, data in rates_data.items(): print(f"\n{name}:") print(f" Current Rate: {data.iloc[-1]:.2f}%") print(f" Average Rate: {data.mean():.2f}%") print(f" Range: {data.min():.2f}% - {data.max():.2f}%") # Plot interest rates plt.figure(figsize=(12, 6)) for name, data in rates_data.items(): data.plot(linewidth=2, label=name) plt.title('Interest Rates Over Time') plt.ylabel('Interest Rate (%)') plt.legend() plt.grid(True, alpha=0.3) plt.tight_layout() plt.show()
def correlation_analysis(df): """Analyze correlations between economic indicators.""" print("\n=== Correlation Analysis ===") # Select available indicators available_cols = [col for col in ['GDP', 'UNRATE', 'CPIAUCSL', 'FEDFUNDS', 'DGS10'] if col in df.columns] if len(available_cols) < 2: print("Need at least 2 indicators for correlation analysis") return # Calculate correlations corr_data = df[available_cols].corr() print("Correlation Matrix:") print(corr_data.round(3)) # Plot correlation heatmap plt.figure(figsize=(8, 6)) sns.heatmap(corr_data, annot=True, cmap='coolwarm', center=0, square=True, linewidths=0.5) plt.title('Economic Indicators Correlation Matrix') plt.tight_layout() plt.show()
def main(): """Run the quick start analysis.""" print("FRED Economic Data - Quick Start Analysis") print("=" * 50) # Load data df = load_latest_data() if df is None: return print(f"Data loaded successfully!") print(f"Shape: {df.shape}") print(f"Columns: {list(df.columns)}") print(f"Date range: {df.index.min()} to {df.index.max()}") # Run analyses analyze_gdp_trends(df) analyze_unemployment(df) analyze_inflation(df) analyze_interest_rates(df) correlation_analysis(df) print("\n=== Analysis Complete ===") print("Check the generated plots for visual insights!")
if __name__ == "__main__": main() 1234567"""Core functionality for FRED data collection and processing."""
from .fred_client import FREDDataCollectorV2
__all__ = ['FREDDataCollectorV2'] 1234567891011121314151617181920212223242526272829303132333435363738import abcimport loggingimport yamlimport os
class BasePipeline(abc.ABC): """ Abstract base class for all data pipelines. Handles config loading, logging, and pipeline orchestration. """ def __init__(self, config_path: str): self.config = self.load_config(config_path) self.logger = self.setup_logger()
@staticmethod def load_config(config_path: str): with open(config_path, 'r') as f: return yaml.safe_load(f)
def setup_logger(self): log_cfg = self.config.get('logging', {}) log_level = getattr(logging, log_cfg.get('level', 'INFO').upper(), logging.INFO) log_file = log_cfg.get('file', 'pipeline.log') os.makedirs(os.path.dirname(log_file), exist_ok=True) logging.basicConfig( level=log_level, format='%(asctime)s %(levelname)s %(name)s %(message)s', handlers=[ logging.FileHandler(log_file), logging.StreamHandler() ] ) return logging.getLogger(self.__class__.__name__)
@abc.abstractmethod def run(self): """Run the pipeline (to be implemented by subclasses).""" pass 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288#!/usr/bin/env python3"""FRED Data Collector v2A tool for collecting and analyzing Federal Reserve Economic Data (FRED)using direct API calls instead of the fredapi library"""
import osimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsimport requestsfrom datetime import datetime, timedeltaimport warningswarnings.filterwarnings('ignore')
import sysimport ossys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
from config.settings import FRED_API_KEY, DEFAULT_START_DATE, DEFAULT_END_DATE, OUTPUT_DIR, PLOTS_DIR
class FREDDataCollectorV2: def __init__(self, api_key=None): """Initialize the FRED data collector with API key.""" self.api_key = api_key or FRED_API_KEY self.base_url = "https://api.stlouisfed.org/fred" # Create output directories os.makedirs(OUTPUT_DIR, exist_ok=True) os.makedirs(PLOTS_DIR, exist_ok=True) # Common economic indicators self.indicators = { 'GDP': 'GDP', # Gross Domestic Product 'UNRATE': 'UNRATE', # Unemployment Rate 'CPIAUCSL': 'CPIAUCSL', # Consumer Price Index 'FEDFUNDS': 'FEDFUNDS', # Federal Funds Rate 'DGS10': 'DGS10', # 10-Year Treasury Rate 'DEXUSEU': 'DEXUSEU', # US/Euro Exchange Rate 'PAYEMS': 'PAYEMS', # Total Nonfarm Payrolls 'INDPRO': 'INDPRO', # Industrial Production 'M2SL': 'M2SL', # M2 Money Stock 'PCE': 'PCE' # Personal Consumption Expenditures } def get_series_info(self, series_id): """Get information about a FRED series.""" try: url = f"{self.base_url}/series" params = { 'series_id': series_id, 'api_key': self.api_key, 'file_type': 'json' } response = requests.get(url, params=params) if response.status_code == 200: data = response.json() series = data.get('seriess', []) if series: s = series[0] return { 'id': s['id'], 'title': s['title'], 'units': s.get('units', ''), 'frequency': s.get('frequency', ''), 'last_updated': s.get('last_updated', ''), 'notes': s.get('notes', '') } return None except Exception as e: print(f"Error getting info for {series_id}: {e}") return None def get_economic_data(self, series_ids, start_date=None, end_date=None): """Fetch economic data for specified series.""" start_date = start_date or DEFAULT_START_DATE end_date = end_date or DEFAULT_END_DATE data = {} for series_id in series_ids: try: print(f"Fetching data for {series_id}...") url = f"{self.base_url}/series/observations" params = { 'series_id': series_id, 'api_key': self.api_key, 'file_type': 'json', 'start_date': start_date, 'end_date': end_date } response = requests.get(url, params=params) if response.status_code == 200: response_data = response.json() observations = response_data.get('observations', []) if observations: # Convert to pandas Series dates = [] values = [] for obs in observations: try: date = pd.to_datetime(obs['date']) value = float(obs['value']) if obs['value'] != '.' else np.nan dates.append(date) values.append(value) except (ValueError, KeyError): continue if dates and values: series_data = pd.Series(values, index=dates, name=series_id) data[series_id] = series_data print(f"✓ Retrieved {len(series_data)} observations for {series_id}") else: print(f"✗ No valid data for {series_id}") else: print(f"✗ No observations found for {series_id}") else: print(f"✗ Error fetching {series_id}: HTTP {response.status_code}") except Exception as e: print(f"✗ Error fetching {series_id}: {e}") return data def create_dataframe(self, data_dict): """Convert dictionary of series data to a pandas DataFrame.""" if not data_dict: return pd.DataFrame() # Find the common date range all_dates = set() for series in data_dict.values(): all_dates.update(series.index) # Create a complete date range if all_dates: date_range = pd.date_range(min(all_dates), max(all_dates), freq='D') df = pd.DataFrame(index=date_range) # Add each series for series_id, series_data in data_dict.items(): df[series_id] = series_data df.index.name = 'Date' return df return pd.DataFrame() def save_data(self, df, filename): """Save data to CSV file.""" if df.empty: print("No data to save") return None filepath = os.path.join(OUTPUT_DIR, filename) df.to_csv(filepath) print(f"Data saved to {filepath}") return filepath def plot_economic_indicators(self, df, indicators_to_plot=None): """Create plots for economic indicators.""" if df.empty: print("No data to plot") return if indicators_to_plot is None: indicators_to_plot = [col for col in df.columns if col in df.columns] if not indicators_to_plot: print("No indicators to plot") return # Set up the plotting style plt.style.use('default') sns.set_palette("husl") # Create subplots n_indicators = len(indicators_to_plot) fig, axes = plt.subplots(n_indicators, 1, figsize=(15, 4*n_indicators)) if n_indicators == 1: axes = [axes] for i, indicator in enumerate(indicators_to_plot): if indicator in df.columns: ax = axes[i] df[indicator].dropna().plot(ax=ax, linewidth=2) # Get series info for title info = self.get_series_info(indicator) title = f'{indicator} - {info["title"]}' if info else indicator ax.set_title(title) ax.set_ylabel('Value') ax.grid(True, alpha=0.3) plt.tight_layout() plot_path = os.path.join(PLOTS_DIR, 'economic_indicators.png') plt.savefig(plot_path, dpi=300, bbox_inches='tight') plt.show() print(f"Plot saved to {plot_path}") def generate_summary_statistics(self, df): """Generate summary statistics for the economic data.""" if df.empty: return pd.DataFrame() summary = df.describe() # Add additional statistics summary.loc['missing_values'] = df.isnull().sum() summary.loc['missing_percentage'] = (df.isnull().sum() / len(df)) * 100 return summary def run_analysis(self, series_ids=None, start_date=None, end_date=None): """Run a complete analysis of economic indicators.""" if series_ids is None: series_ids = list(self.indicators.values()) print("=== FRED Economic Data Analysis v2 ===") print(f"API Key: {self.api_key[:8]}...") print(f"Date Range: {start_date or DEFAULT_START_DATE} to {end_date or DEFAULT_END_DATE}") print(f"Series to analyze: {series_ids}") print("=" * 50) # Fetch data data = self.get_economic_data(series_ids, start_date, end_date) if not data: print("No data retrieved. Please check your API key and series IDs.") return None, None # Create DataFrame df = self.create_dataframe(data) if df.empty: print("No data to analyze") return None, None # Save data timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") self.save_data(df, f'fred_economic_data_{timestamp}.csv') # Generate summary statistics summary = self.generate_summary_statistics(df) print("\n=== Summary Statistics ===") print(summary) # Create plots print("\n=== Creating Visualizations ===") self.plot_economic_indicators(df) return df, summary
def main(): """Main function to run the FRED data analysis.""" collector = FREDDataCollectorV2() # Example: Analyze key economic indicators key_indicators = ['GDP', 'UNRATE', 'CPIAUCSL', 'FEDFUNDS', 'DGS10'] try: df, summary = collector.run_analysis(series_ids=key_indicators) if df is not None: print("\n=== Analysis Complete ===") print(f"Data shape: {df.shape}") print(f"Date range: {df.index.min()} to {df.index.max()}") else: print("\n=== Analysis Failed ===") except Exception as e: print(f"Error during analysis: {e}")
if __name__ == "__main__": main() 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788from .base_pipeline import BasePipelineimport requestsimport pandas as pdimport osfrom datetime import datetime
class FREDPipeline(BasePipeline): """ FRED Data Pipeline: Extracts, transforms, and loads FRED data using config. """ def __init__(self, config_path: str): super().__init__(config_path) self.fred_cfg = self.config['fred'] self.api_key = self.fred_cfg['api_key'] self.series = self.fred_cfg['series'] self.start_date = self.fred_cfg['start_date'] self.end_date = self.fred_cfg['end_date'] self.output_dir = self.fred_cfg['output_dir'] self.export_dir = self.fred_cfg['export_dir'] os.makedirs(self.output_dir, exist_ok=True) os.makedirs(self.export_dir, exist_ok=True)
def extract(self): """Extract data from FRED API for all configured series.""" base_url = "https://api.stlouisfed.org/fred/series/observations" data = {} for series_id in self.series: params = { 'series_id': series_id, 'api_key': self.api_key, 'file_type': 'json', 'start_date': self.start_date, 'end_date': self.end_date } try: resp = requests.get(base_url, params=params) resp.raise_for_status() obs = resp.json().get('observations', []) dates, values = [], [] for o in obs: try: dates.append(pd.to_datetime(o['date'])) values.append(float(o['value']) if o['value'] != '.' else None) except Exception: continue data[series_id] = pd.Series(values, index=dates, name=series_id) self.logger.info(f"Extracted {len(values)} records for {series_id}") except Exception as e: self.logger.error(f"Failed to extract {series_id}: {e}") return data
def transform(self, data): """Transform raw data into a DataFrame, align dates, handle missing.""" if not data: self.logger.warning("No data to transform.") return pd.DataFrame() all_dates = set() for s in data.values(): all_dates.update(s.index) if not all_dates: return pd.DataFrame() date_range = pd.date_range(min(all_dates), max(all_dates), freq='D') df = pd.DataFrame(index=date_range) for k, v in data.items(): df[k] = v df.index.name = 'Date' self.logger.info(f"Transformed data to DataFrame with shape {df.shape}") return df
def load(self, df): """Save DataFrame to CSV in output_dir and export_dir.""" if df.empty: self.logger.warning("No data to load.") return None ts = datetime.now().strftime("%Y%m%d_%H%M%S") out_path = os.path.join(self.output_dir, f'fred_data_{ts}.csv') exp_path = os.path.join(self.export_dir, f'fred_data_{ts}.csv') df.to_csv(out_path) df.to_csv(exp_path) self.logger.info(f"Saved data to {out_path} and {exp_path}") return out_path, exp_path
def run(self): self.logger.info("Starting FRED data pipeline run...") data = self.extract() df = self.transform(data) self.load(df) self.logger.info("FRED data pipeline run complete.") 1234567"""Utility functions and helper modules."""
from .examples import *
__all__ = ['examples'] 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139#!/usr/bin/env python3"""Example usage of the FRED Data CollectorDemonstrates various ways to use the tool for economic data analysis"""
import sysimport ossys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from core.fred_client import FREDDataCollectorV2import pandas as pdfrom datetime import datetime, timedelta
def example_basic_usage(): """Basic usage example.""" print("=== Basic Usage Example ===") collector = FREDDataCollectorV2() # Get data for a single indicator gdp_data = collector.get_economic_data(['GDP'], '2020-01-01', '2024-01-01') df = collector.create_dataframe(gdp_data) print(f"GDP data shape: {df.shape}") print(f"Date range: {df.index.min()} to {df.index.max()}") print(f"Latest GDP value: ${df['GDP'].iloc[-1]:,.2f} billion") return df
def example_multiple_indicators(): """Example with multiple economic indicators.""" print("\n=== Multiple Indicators Example ===") collector = FREDDataCollectorV2() # Define indicators of interest indicators = ['UNRATE', 'CPIAUCSL', 'FEDFUNDS'] # Get data for the last 5 years end_date = datetime.now().strftime('%Y-%m-%d') start_date = (datetime.now() - timedelta(days=5*365)).strftime('%Y-%m-%d') data = collector.get_economic_data(indicators, start_date, end_date) df = collector.create_dataframe(data) # Generate summary statistics summary = collector.generate_summary_statistics(df) print("\nSummary Statistics:") print(summary) # Save data collector.save_data(df, 'example_multiple_indicators.csv') return df
def example_custom_analysis(): """Example of custom analysis.""" print("\n=== Custom Analysis Example ===") collector = FREDDataCollectorV2() # Focus on monetary policy indicators monetary_indicators = ['FEDFUNDS', 'DGS10', 'M2SL'] # Get data for the last 10 years end_date = datetime.now().strftime('%Y-%m-%d') start_date = (datetime.now() - timedelta(days=10*365)).strftime('%Y-%m-%d') data = collector.get_economic_data(monetary_indicators, start_date, end_date) df = collector.create_dataframe(data) # Calculate some custom metrics if 'FEDFUNDS' in df.columns and 'DGS10' in df.columns: # Calculate yield curve spread (10Y - Fed Funds) df['YIELD_SPREAD'] = df['DGS10'] - df['FEDFUNDS'] print(f"\nYield Curve Analysis:") print(f"Current Fed Funds Rate: {df['FEDFUNDS'].iloc[-1]:.2f}%") print(f"Current 10Y Treasury Rate: {df['DGS10'].iloc[-1]:.2f}%") print(f"Current Yield Spread: {df['YIELD_SPREAD'].iloc[-1]:.2f}%") # Check for inverted yield curve (negative spread) inverted_periods = df[df['YIELD_SPREAD'] < 0] if not inverted_periods.empty: print(f"Yield curve inverted for {len(inverted_periods)} periods") return df
def example_series_info(): """Example of getting series information.""" print("\n=== Series Information Example ===") collector = FREDDataCollectorV2() # Get information about different series series_to_check = ['GDP', 'UNRATE', 'CPIAUCSL'] for series_id in series_to_check: info = collector.get_series_info(series_id) if info: print(f"\n{series_id}:") print(f" Title: {info['title']}") print(f" Units: {info['units']}") print(f" Frequency: {info['frequency']}") print(f" Last Updated: {info['last_updated']}")
def example_error_handling(): """Example showing error handling.""" print("\n=== Error Handling Example ===") collector = FREDDataCollectorV2() # Try to get data for an invalid series ID invalid_series = ['INVALID_SERIES_ID'] data = collector.get_economic_data(invalid_series) print("Attempted to fetch invalid series - handled gracefully")
def main(): """Run all examples.""" print("FRED Data Collector - Example Usage") print("=" * 50) try: # Run examples example_basic_usage() example_multiple_indicators() example_custom_analysis() example_series_info() example_error_handling() print("\n=== All Examples Completed Successfully ===") except Exception as e: print(f"Error running examples: {e}")
if __name__ == "__main__": main() 12345"""Data visualization and plotting utilities."""
__all__ = [] 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115#!/usr/bin/env python3"""Simple FRED API test"""
import requestsimport sysimport ossys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from config.settings import FRED_API_KEY
def test_fred_api_direct(): """Test FRED API directly using requests.""" print("Testing FRED API directly...") # Test URL for GDP series url = f"https://api.stlouisfed.org/fred/series/observations" params = { 'series_id': 'GDP', 'api_key': FRED_API_KEY, 'file_type': 'json', 'start_date': '2023-01-01', 'end_date': '2023-12-31' } try: response = requests.get(url, params=params) if response.status_code == 200: data = response.json() observations = data.get('observations', []) if observations: print("✓ API connection successful!") print(f"✓ Retrieved {len(observations)} GDP observations") # Get the latest observation latest = observations[-1] print(f"✓ Latest GDP value: ${float(latest['value']):,.2f} billion") print(f"✓ Date: {latest['date']}") return True else: print("✗ No observations found") return False else: print(f"✗ API request failed with status code: {response.status_code}") print(f"Response: {response.text}") return False except Exception as e: print(f"✗ API connection failed: {e}") return False
def test_series_search(): """Test searching for series.""" print("\nTesting series search...") url = "https://api.stlouisfed.org/fred/series/search" params = { 'search_text': 'GDP', 'api_key': FRED_API_KEY, 'file_type': 'json' } try: response = requests.get(url, params=params) if response.status_code == 200: data = response.json() series = data.get('seriess', []) if series: print("✓ Series search successful!") print(f"✓ Found {len(series)} series matching 'GDP'") # Show first few results for i, s in enumerate(series[:3]): print(f" {i+1}. {s['id']}: {s['title']}") return True else: print("✗ No series found") return False else: print(f"✗ Search request failed: {response.status_code}") return False except Exception as e: print(f"✗ Search failed: {e}") return False
def main(): """Run simple API tests.""" print("Simple FRED API Test") print("=" * 30) print(f"API Key: {FRED_API_KEY[:8]}...") print() # Test direct API access api_ok = test_fred_api_direct() # Test series search search_ok = test_series_search() print("\n" + "=" * 30) if api_ok and search_ok: print("✓ All tests passed! Your API key is working correctly.") print("The issue is with the fredapi library, not your API key.") else: print("✗ Some tests failed. Please check your API key.") return api_ok and search_ok
if __name__ == "__main__": main() 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384#!/usr/bin/env python3"""Test script to verify FRED API key functionality"""
from fredapi import Fredimport sysimport ossys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from config.settings import FRED_API_KEY
def test_api_connection(): """Test the FRED API connection with the provided key.""" print("Testing FRED API connection...") try: # Initialize FRED client fred = Fred(api_key=FRED_API_KEY) # Test with a simple series (GDP) print("Fetching GDP data as a test...") gdp_data = fred.get_series('GDP', start='2023-01-01', end='2023-12-31') if not gdp_data.empty: print("✓ API connection successful!") print(f"✓ Retrieved {len(gdp_data)} GDP observations") print(f"✓ Latest GDP value: ${gdp_data.iloc[-1]:,.2f} billion") print(f"✓ Date range: {gdp_data.index.min()} to {gdp_data.index.max()}") return True else: print("✗ No data retrieved") return False except Exception as e: print(f"✗ API connection failed: {e}") return False
def test_series_info(): """Test getting series information.""" print("\nTesting series information retrieval...") try: fred = Fred(api_key=FRED_API_KEY) # Test getting info for GDP series_info = fred.get_series_info('GDP') print("✓ Series information retrieved successfully!") print(f" Title: {series_info.title}") print(f" Units: {series_info.units}") print(f" Frequency: {series_info.frequency}") print(f" Last Updated: {series_info.last_updated}") return True except Exception as e: print(f"✗ Failed to get series info: {e}") return False
def main(): """Run API tests.""" print("FRED API Key Test") print("=" * 30) print(f"API Key: {FRED_API_KEY[:8]}...") print() # Test connection connection_ok = test_api_connection() # Test series info info_ok = test_series_info() print("\n" + "=" * 30) if connection_ok and info_ok: print("✓ All tests passed! Your API key is working correctly.") print("You can now use the FRED data collector tool.") else: print("✗ Some tests failed. Please check your API key.") return connection_ok and info_ok
if __name__ == "__main__": main() .gitattributesAdded+35
.gitignoreAdded+78
LICENSEAdded+21
README.mdAdded+150
__pycache__/config.cpython-39.pycAdded
__pycache__/fred_data_collector_v2.cpython-39.pycAdded
config/__pycache__/settings.cpython-39.pycAdded
config/pipeline.yamlAdded+16
config/settings.pyAdded+10
data/exports/fred_data_20250710_221702.csvAdded
data/exports/fred_data_20250710_223022.csvAdded
data/exports/fred_data_20250710_223149.csvAdded
data/exports/regression_summary.txtAdded+28
requirements.txtAdded+13
scripts/run_advanced_analytics.pyAdded+56
scripts/run_eda.pyAdded+80
scripts/run_fred_pipeline.pyAdded+10
scripts/run_segmentation.pyAdded+91
scripts/run_statistical_modeling.pyAdded+104
scripts/run_time_series.pyAdded+80
src/__init__.pyAdded+21
src/__pycache__/__init__.cpython-39.pycAdded
src/analysis/__init__.pyAdded+7
src/analysis/__pycache__/__init__.cpython-39.pycAdded
src/analysis/__pycache__/advanced_analytics.cpython-39.pycAdded
src/analysis/__pycache__/economic_analyzer.cpython-39.pycAdded
src/analysis/advanced_analytics.pyAdded+517
src/analysis/economic_analyzer.pyAdded+201
src/core/__init__.pyAdded+7
src/core/__pycache__/__init__.cpython-39.pycAdded
src/core/__pycache__/base_pipeline.cpython-39.pycAdded
src/core/__pycache__/fred_client.cpython-39.pycAdded
src/core/__pycache__/fred_pipeline.cpython-39.pycAdded
src/core/base_pipeline.pyAdded+38
src/core/fred_client.pyAdded+288
src/core/fred_pipeline.pyAdded+88
src/utils/__init__.pyAdded+7
src/utils/examples.pyAdded+139
src/visualization/__init__.pyAdded+5
tests/__pycache__/test_fred_api.cpython-39-pytest-7.4.0.pycAdded
tests/__pycache__/test_fredapi_library.cpython-39-pytest-7.4.0.pycAdded
tests/test_fred_api.pyAdded+115
tests/test_fredapi_library.pyAdded+84