Svngoku/WAEMU_Banking_Analysis
收藏Hugging Face2024-06-08 更新2024-06-12 收录
下载链接:
https://hf-mirror.com/datasets/Svngoku/WAEMU_Banking_Analysis
下载链接
链接失效反馈官方服务:
资源简介:
---
dataset_info:
features:
- name: Countries_Num
dtype: int64
- name: id
dtype: int64
- name: Countries
dtype: string
- name: Banks
dtype: string
- name: Year
dtype: int64
- name: RIR
dtype: float64
- name: SFS
dtype: float64
- name: INF
dtype: float64
- name: ERA
dtype: float64
- name: INL
dtype: float64
- name: Zscore
dtype: float64
- name: DEBT
dtype: float64
- name: SIZE
dtype: float64
- name: CC
dtype: float64
- name: GE
dtype: float64
- name: PS
dtype: float64
- name: RQ
dtype: float64
- name: RL
dtype: float64
- name: VA
dtype: float64
- name: Analysis
dtype: string
- name: report
dtype: string
splits:
- name: train
num_bytes: 2355454
num_examples: 742
download_size: 672495
dataset_size: 2355454
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
language:
- en
size_categories:
- n<1K
license: mit
tags:
- finance
pretty_name: africa
---
# WAEMU Banking Analysis
## Overview
This project aims to analyze the financial health and performance of banks within the West African Economic and Monetary Union (UEMOA). Utilizing data-driven insights, the analysis covers various key financial and economic indicators, providing a comprehensive overview of each bank's stability, risk profile, and overall performance.
## Features
- **Automated Financial Analysis**: Generates detailed textual reports for each bank based on key financial indicators.
- **Integration with GPT-4o**: Leverages OpenAI's GPT-4o model to synthesize and present data in a readable and insightful format.
## Key Indicators Analyzed
- **Risk Index Rating (RIR)**
- **Solvency and Financial Stability (SFS)**
- **Inflation Rate (INF)**
- **Economic Risk Assessment (ERA)**
- **Internationalization Level (INL)**
- **Z-score**
- **Debt Level (DEBT)**
- **Size (SIZE)**
- **Capital Adequacy (CC)**
- **Governance and Ethics (GE)**
- **Profitability and Sustainability (PS)**
- **Regulatory Compliance (RQ)**
- **Liquidity Risk (RL)**
- **Value Added (VA)**
## How It Works
1. **Data Loading**: The project starts by loading the dataset containing financial data for banks in the UEMOA region.
2. **Textual Analysis Creation**: For each row in the dataset, a textual analysis is generated using a pre-defined format that includes all relevant financial indicators.
3. **GPT-4o Integration**: The GPT-4o model is used to provide detailed and nuanced insights based on the generated textual analysis.
4. **Dataset Conversion and Upload**: The final analyses are converted into a Hugging Face dataset and uploaded to the Hugging Face Hub for easy access.
### Dataset Code Factory
```py
import pandas as pd
import numpy as np
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI, ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from datasets import Dataset
import os
from dotenv import load_dotenv
_ = load_dotenv()
# Define the function to create the textual analysis for each row
def create_analysis(row):
analysis = (
f"This is the analysis of {row['Banks']} in {row['Countries']} for the year {row['Year']}. "
f"Risk Profile: Risk Index Rating at {row['RIR']:.2f}% and Liquidity Risk at {row['RL']:.2f}%. "
f"Financial Stability: Solvency and Financial Stability score of {row['SFS']:.2f}% and Capital Adequacy at {row['CC']:.2f}%. "
f"Economic Context: Inflation Rate of {row['INF']:.2f}% and Economic Risk Assessment at {row['ERA']:.2f}%. "
f"Performance Metrics: Profitability and Sustainability score of {row['PS']:.2f}% and Value Added at {row['VA']:.2f}%. "
f"Governance: Governance and Ethics score at {row['GE']:.2f}%, with Regulatory Compliance at {row['RQ']:.2f}%. "
)
return analysis
# Load the data
dataframe = pd.read_csv('WAEMU_Banking_Analysis - WAEMU_Banking_Updated.csv.csv', delimiter=',', encoding='utf-8')
def make_llm_analysis(dataframe):
# Create the analysis prompt
system_prompt = """You are a highly intelligent assistant specializing in financial and economic analysis within the banking sector.
Your task is to gather and synthesize information related to the financial health and performance of banks within the West African Economic and Monetary Union (UEMOA).
1. Ensure to gather data on key indicators such as Risk Index Rating, Solvency and Financial Stability, Inflation Rate, Economic Risk Assessment, Internationalization Level, Z-score, Debt level, Size, Capital Adequacy, Governance and Ethics, Profitability and Sustainability, Regulatory Compliance, Liquidity Risk, and Value Added.
2. When retrieving information, make multiple calls if necessary to ensure comprehensiveness and accuracy. Prioritize sources that are credible and up-to-date.
3. Synthesize the gathered information into a cohesive analysis for each bank, highlighting their financial health, risk profile, economic context, and overall performance in the following format:
4. Provide an overall assessment based on the gathered information using the following structure:
- Risk Profile: [Brief Summary of risk profile based on RIR and RL].
- Financial Stability: [Brief Summary of financial stability based on SFS and CC].
- Economic Context: [Brief Summary of economic context based on INF and ERA].
- Performance Metrics: [Brief Summary of performance metrics based on PS and VA].
- Governance: [Brief Summary of governance based on GE and RQ].
- Overall Assessment: [Brief summary of the bank's situation].
Be thorough in your research and ensure that the final analysis is insightful, in plain text and useful for decision-making purposes No markdown.
"""
# Create the OpenAI model
llm = ChatOpenAI(
model="gpt-4o",
)
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
system_prompt
),
("human", "{input}"),
]
)
chain = prompt | llm
# Create the analysis for each row in the dataframe
for i in range(len(dataframe)):
analysis = create_analysis(dataframe.iloc[i])
result = chain.invoke({
"input": analysis
})
dataframe.loc[i, 'report'] = result.content
return dataframe
def pandas_to_huggingface(dataframe):
# Convert the pandas dataframe to a Hugging Face dataset
dataset = Dataset.from_pandas(dataframe)
dataset.push_to_hub(
"Svngoku/WAEMU_Banking_Analysis",
token=os.getenv("HF_TOKEN")
)
# Call the function to generate the analysis
dataframe = make_llm_analysis(dataframe)
# Save the dataframe to a CSV file
dataframe.to_csv('WAEMU_Banking_Analysis_Results.csv', index=False)
# Convert the dataframe to a Hugging Face dataset
pandas_to_huggingface(dataframe)
```
## Cost, Compute & Time
- OpenAI `gpt-4o` : `8$` for more than 600k tokens generated in `input` and `output`
- more than 2h of processing.
- Mac M1 32GB RAM
## Contributing
We welcome contributions to enhance the functionality and coverage of this project. Please feel free to fork the repository, make your changes, and submit a pull request.
## License
This project is licensed under the MIT License.
提供机构:
Svngoku
原始信息汇总
数据集概述
数据集信息
- 名称: WAEMU Banking Analysis
- 特征:
- Countries_Num: int64
- id: int64
- Countries: string
- Banks: string
- Year: int64
- RIR: float64
- SFS: float64
- INF: float64
- ERA: float64
- INL: float64
- Zscore: float64
- DEBT: float64
- SIZE: float64
- CC: float64
- GE: float64
- PS: float64
- RQ: float64
- RL: float64
- VA: float64
- Analysis: string
- report: string
- 分割:
- train: 742个样本,数据大小2355454字节
- 下载大小: 672495字节
- 数据集大小: 2355454字节
- 语言: 英语
- 大小类别: 小于1K
- 许可证: MIT
- 标签: 金融
- 美观名称: africa
关键指标分析
- 风险指数评级 (RIR)
- 偿付能力和财务稳定性 (SFS)
- 通胀率 (INF)
- 经济风险评估 (ERA)
- 国际化水平 (INL)
- Z分数
- 债务水平 (DEBT)
- 规模 (SIZE)
- 资本充足性 (CC)
- 治理与伦理 (GE)
- 盈利性与可持续性 (PS)
- 监管合规性 (RQ)
- 流动性风险 (RL)
- 附加值 (VA)
数据集处理流程
- 数据加载: 加载包含UEMOA地区银行财务数据的集合。
- 文本分析生成: 对数据集中的每一行生成包含所有相关财务指标的文本分析。
- GPT-4o集成: 使用GPT-4o模型提供基于生成文本分析的详细见解。
- 数据集转换与上传: 最终分析转换为Hugging Face数据集并上传至Hugging Face Hub。



