Skip to content

Commit

Permalink
Merge pull request #1017 from ashis2004/3
Browse files Browse the repository at this point in the history
Automated Financial Reporting with Deep Learning added
  • Loading branch information
invigorzz313 authored Jul 30, 2024
2 parents b045f92 + b9b12c7 commit a2f5022
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 0 deletions.
78 changes: 78 additions & 0 deletions Automated Financial Reporting with Deep Learning/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import streamlit as st
import pandas as pd
import numpy as np
import tensorflow as tf
from sklearn.preprocessing import MinMaxScaler

# Load the dataset
df = pd.read_csv('financial_data.csv')
df['Date'] = pd.to_datetime(df['Date'])

# Load the trained model
model = tf.keras.models.load_model('financial_model.h5')

# Normalize the data using the same scaler as during training
scaler = MinMaxScaler()
data_scaled = scaler.fit_transform(df.drop('Date', axis=1))

# Prepare features and target
X = data_scaled[:, :-1]
y = data_scaled[:, -1]

# Make predictions
y_pred = model.predict(X)
y_pred_original = scaler.inverse_transform(np.c_[X, y_pred])[:, -1]

# Add predictions to the DataFrame
df['Predicted_Equity'] = y_pred_original

# Streamlit app
st.title("Automated Financial Reporting with Deep Learning")

st.write("""
### Actual vs Predicted Equity Values
""")

# Display a sample of the actual vs predicted values
comparison = pd.DataFrame({
'Actual': df['Equity'],
'Predicted': df['Predicted_Equity']
})

st.write(comparison.head())

# Plot the actual vs predicted values
st.line_chart(comparison)

# Display the model's performance metrics
st.write(f"Test Loss: 0.08456173539161682, Test MAE: 0.2604014575481415")

st.write("""
### Training Metrics
""")

# Display the training metrics
training_metrics = {
"Epoch": list(range(1, 11)),
"Training Loss": [0.4236, 0.3555, 0.3024, 0.2610, 0.2237, 0.1883, 0.1559, 0.1281, 0.1029, 0.0861],
"Training MAE": [0.5733, 0.5171, 0.4694, 0.4267, 0.3849, 0.3473, 0.3104, 0.2799, 0.2553, 0.2352],
"Validation Loss": [0.3441, 0.2862, 0.2406, 0.2011, 0.1643, 0.1300, 0.1004, 0.0776, 0.0596, 0.0456],
"Validation MAE": [0.5352, 0.4826, 0.4356, 0.3896, 0.3425, 0.3015, 0.2623, 0.2264, 0.1929, 0.1670]
}

metrics_df = pd.DataFrame(training_metrics)
st.line_chart(metrics_df[['Training Loss', 'Validation Loss']])
st.line_chart(metrics_df[['Training MAE', 'Validation MAE']])

st.write("""
### Summary Statistics
""")

# Display summary statistics
summary = df.describe()
st.write(summary)

# Save the report to a CSV file
df.to_csv('financial_report.csv', index=False)
summary.to_csv('financial_summary.csv')
st.write("Financial report and summary generated successfully. Check the generated CSV files for details.")
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Date,Revenue,Expenses,Profit,Assets,Liabilities,Equity
2020-01-31,24981.6047538945,13200.654190149195,11780.950563745304,309093.13175279764,106968.09887549352,202125.03287730413
2020-02-29,48028.57225639665,7772.816832882905,40255.75542351374,271016.40734341985,57377.38947090656,213639.0178725133
2020-03-31,39279.7576724562,19543.769416468378,19735.988255987824,110167.65069763808,171912.86679597938,-61745.216098341305
2020-04-30,33946.33936788146,16626.992350416716,17319.347017464745,143156.5707973218,150535.8046457723,-7379.233848450502
2020-05-31,16240.745617697461,19092.484123462837,-2851.7385057653755,112571.6742746937,60295.75024999787,52275.92402469582
2020-06-30,16239.780813448106,18422.410256414732,-2182.629442966627,354564.16450551216,105729.29284732229,248834.87165818986
2020-07-31,12323.34448672798,13968.499682166277,-1645.1551954382976,225742.3924305307,231653.17719333075,-5910.78476280006
2020-08-31,44647.045830997406,18828.11352534675,25818.932305650655,303428.27646588115,97912.3781333945,205515.89833248666
2020-09-30,34044.60046972835,6327.387530778793,27717.212938949557,463026.5895704372,78978.97441824462,384047.6151521926
2020-10-31,38322.90311184182,7939.742936287178,30383.160175554644,199716.89165954996,147890.5520555126,51826.33960403735
2020-11-30,10823.379771832098,5678.409333658071,5144.970438174028,264153.1692142519,247130.09082212014,17023.078392131778
2020-12-31,48796.39408647977,9879.954961448966,38916.4391250308,402220.4554172195,98411.05430230008,303809.4011149194
2021-01-31,43297.70563201687,10830.15934534223,32467.54628667464,191519.266196649,184427.10948117572,7092.156715473277
2021-02-28,18493.564427131045,9070.235476608439,9423.328950522606,130791.9639315172,202323.92306574353,-71531.95913422633
2021-03-31,17272.998688284024,17431.06263727894,-158.06394899491715,215900.5811655072,97527.50879847993,118373.07236702727
2021-04-30,17336.18039413735,10351.29990040384,6984.880493733512,164488.51490160177,195643.26972237192,-31154.754820770147
2021-05-31,22169.68971838151,9214.017645310712,12955.672073070797,471879.06093702925,123556.62654385064,348322.4343931786
2021-06-30,30990.257265289514,13140.441247373727,17849.816017915786,423248.1518257668,176461.1661187159,246786.9857070509
2021-07-31,27277.80074568463,7113.86337462144,20163.93737106319,353361.5026041694,176705.94215217893,176655.5604519905
2021-08-31,21649.165607921677,17032.954711310595,4616.210896611083,448584.2360750871,157154.9368149517,291429.2992601354
2021-09-30,34474.11578889518,6118.259655196563,28355.856133698617,421468.8307596458,68057.95401088166,353410.87674876413
2021-10-31,15579.754426081672,19803.304049007762,-4223.54962292609,174628.02355441434,217060.4991178476,-42432.475563433254
2021-11-30,21685.78594140873,16583.67153944986,5102.114401958868,457023.5993959911,114156.01299434717,342867.58640164393
2021-12-31,24654.47373174767,7980.735223012586,16673.73850873508,315736.89676626027,87303.70207997086,228433.1946862894
2022-01-31,28242.799368681437,5082.831756854036,23159.9676118274,422976.06206562504,58155.02831095278,364821.0337546723
2022-02-28,41407.03845572054,17231.92142682251,24175.11702889803,458436.5199693973,168178.58863764838,290257.9313317489
2022-03-31,17986.95128633439,15602.860157714256,2384.0911286201354,227201.38998874556,185512.87236845648,41688.51762028909
2022-04-30,30569.377536544464,15935.107520614809,14634.270015929655,144020.7698110707,53317.56578557123,90703.20402549946
2022-05-31,33696.5827544817,16569.055200289185,17127.527554192515,191174.06501677667,152418.6116598562,38755.45335692048
2022-06-30,11858.016508799908,6110.669776011356,5747.346732788553,270843.1154505025,95299.15503958758,175543.9604109149
2022-07-31,34301.79407605753,10376.98592816409,23924.80814789344,427205.90636899724,179034.55808189,248171.34828710725
2022-08-31,16820.964947491662,6738.035892876946,10082.929054614717,444292.23330253735,84873.28580099829,359418.9475015391
2022-09-30,12602.06371941118,17946.551388133903,-5344.487668722722,102780.85221247628,188187.5476204932,-85406.69540801691
2022-10-31,47955.42149013333,14349.471902413368,33605.949587719966,304298.9210310263,127347.06926010748,176951.85177091882
2022-11-30,48625.28132298237,9963.470372789738,38661.81095019264,266964.4012595116,237345.9977473469,29618.40351216469
2022-12-31,42335.89392465845,5953.375254290355,36382.518670368096,188843.1241882921,77504.18882919865,111338.93535909345
2023-01-31,22184.55076693483,9664.734825734933,12519.815941199897,147946.14693347312,118213.2702100517,29732.876723421417
2023-02-28,13906.884560255356,9877.749830401206,4029.1347298541496,235046.0685614512,72694.7042481178,162351.36431333338
2023-03-31,37369.321060486276,15944.09267507096,21425.228385415314,477163.8815650077,234938.72365571256,242225.1579092951
2023-04-30,27606.099749584053,14563.362070328198,13042.737679255855,229281.1728083021,225467.8706761962,3813.3021321058914
2023-05-31,14881.529393791152,18308.1911386449,-3426.661744853747,307516.2486973464,101588.32554303113,205927.9231543153
2023-06-30,29807.076404450807,12083.223877429238,17723.85252702157,381207.5835580711,181996.8092068358,199210.7743512353
2023-07-31,11375.540844608735,6793.913689074526,4581.627155534209,245451.8409517176,213444.44004024318,32007.400911474426
2023-08-31,46372.81608315128,15698.671808344925,30674.144274806356,488712.83308838424,161040.16231989246,327672.6707684918
2023-09-30,20351.19926400068,16411.775729253462,3939.4235347472168,484978.9179768445,155930.11567120132,329048.80230564316
2023-10-31,36500.891374159284,13419.157963542444,23081.733410616842,200712.91833014565,98370.45818009034,102342.46015005531
2023-11-30,22468.443043576437,16564.507699318416,5903.935344258021,298899.4023569542,68620.55356117984,230278.84879577433
2023-12-31,30802.720847112432,12406.933945465862,18395.78690164657,220351.32392670785,229443.15159066534,-9091.82766395749
Loading

0 comments on commit a2f5022

Please sign in to comment.