From b9b12c7d97a365e6721c36de2df0ea2fc5ee1588 Mon Sep 17 00:00:00 2001 From: "ap550083@gmail.com" Date: Mon, 29 Jul 2024 00:59:23 +0530 Subject: [PATCH] Automated Financial Reporting with Deep Learning added --- .../app.py | 78 +++++ .../financial_data.csv | 49 ++++ .../financial_model.h5 | 274 ++++++++++++++++++ .../financial_report.csv | 49 ++++ .../financial_summary.csv | 9 + .../readme.md | 26 ++ 6 files changed, 485 insertions(+) create mode 100644 Automated Financial Reporting with Deep Learning/app.py create mode 100644 Automated Financial Reporting with Deep Learning/financial_data.csv create mode 100644 Automated Financial Reporting with Deep Learning/financial_model.h5 create mode 100644 Automated Financial Reporting with Deep Learning/financial_report.csv create mode 100644 Automated Financial Reporting with Deep Learning/financial_summary.csv create mode 100644 Automated Financial Reporting with Deep Learning/readme.md diff --git a/Automated Financial Reporting with Deep Learning/app.py b/Automated Financial Reporting with Deep Learning/app.py new file mode 100644 index 0000000000..5244926744 --- /dev/null +++ b/Automated Financial Reporting with Deep Learning/app.py @@ -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.") diff --git a/Automated Financial Reporting with Deep Learning/financial_data.csv b/Automated Financial Reporting with Deep Learning/financial_data.csv new file mode 100644 index 0000000000..15b64d1809 --- /dev/null +++ b/Automated Financial Reporting with Deep Learning/financial_data.csv @@ -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 diff --git a/Automated Financial Reporting with Deep Learning/financial_model.h5 b/Automated Financial Reporting with Deep Learning/financial_model.h5 new file mode 100644 index 0000000000..b164131cf9 --- /dev/null +++ b/Automated Financial Reporting with Deep Learning/financial_model.h5 @@ -0,0 +1,274 @@ + + + + + + + financial_model.h5 (editing) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+
+
+ + +
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Automated Financial Reporting with Deep Learning/financial_report.csv b/Automated Financial Reporting with Deep Learning/financial_report.csv new file mode 100644 index 0000000000..17d100484a --- /dev/null +++ b/Automated Financial Reporting with Deep Learning/financial_report.csv @@ -0,0 +1,49 @@ +Date,Revenue,Expenses,Profit,Assets,Liabilities,Equity,Predicted_Equity +2020-01-31,24981.6047538945,13200.654190149196,11780.950563745304,309093.13175279764,106968.09887549352,202125.03287730413,68825.34615765153 +2020-02-29,48028.57225639665,7772.816832882905,40255.75542351374,271016.40734341985,57377.38947090656,213639.0178725133,155089.9978153562 +2020-03-31,39279.7576724562,19543.769416468374,19735.988255987824,110167.65069763808,171912.86679597938,-61745.216098341305,34224.57171260366 +2020-04-30,33946.33936788146,16626.992350416716,17319.347017464745,143156.5707973218,150535.8046457723,-7379.233848450502,33442.48438773654 +2020-05-31,16240.74561769746,19092.48412346284,-2851.7385057653755,112571.6742746937,60295.75024999787,52275.92402469582,-9813.170596191005 +2020-06-30,16239.780813448106,18422.41025641473,-2182.629442966627,354564.16450551216,105729.29284732229,248834.87165818983,65928.8808532161 +2020-07-31,12323.34448672798,13968.499682166275,-1645.1551954382976,225742.3924305307,231653.17719333075,-5910.78476280006,6045.587645266148 +2020-08-31,44647.045830997406,18828.11352534675,25818.93230565065,303428.27646588115,97912.3781333945,205515.89833248663,90091.20992465467 +2020-09-30,34044.60046972835,6327.387530778793,27717.21293894956,463026.5895704372,78978.97441824462,384047.6151521926,153608.5649266106 +2020-10-31,38322.90311184182,7939.742936287178,30383.160175554644,199716.89165955,147890.5520555126,51826.33960403735,90830.6532036149 +2020-11-30,10823.379771832098,5678.409333658071,5144.970438174028,264153.1692142519,247130.0908221201,17023.078392131778,50947.47348930979 +2020-12-31,48796.39408647977,9879.954961448966,38916.4391250308,402220.4554172195,98411.05430230008,303809.4011149194,172204.61481427395 +2021-01-31,43297.70563201687,10830.15934534223,32467.54628667464,191519.266196649,184427.1094811757,7092.156715473277,96594.09114556591 +2021-02-28,18493.564427131045,9070.23547660844,9423.328950522606,130791.9639315172,202323.92306574355,-71531.95913422633,-3798.765168847041 +2021-03-31,17272.998688284024,17431.06263727894,-158.06394899491715,215900.5811655072,97527.50879847992,118373.07236702729,20404.116319606324 +2021-04-30,17336.18039413735,10351.29990040384,6984.880493733512,164488.51490160177,195643.26972237192,-31154.754820770147,3233.3121525907877 +2021-05-31,22169.68971838151,9214.017645310712,12955.672073070797,471879.06093702925,123556.62654385064,348322.4343931786,134062.00611807386 +2021-06-30,30990.257265289518,13140.441247373728,17849.816017915786,423248.1518257668,176461.1661187159,246786.9857070509,139728.403672095 +2021-07-31,27277.80074568463,7113.86337462144,20163.93737106319,353361.5026041694,176705.94215217893,176655.5604519905,122052.41866203291 +2021-08-31,21649.16560792168,17032.954711310595,4616.210896611083,448584.2360750871,157154.9368149517,291429.2992601354,112845.78181133242 +2021-09-30,34474.11578889518,6118.259655196563,28355.856133698617,421468.8307596458,68057.95401088166,353410.87674876413,140617.94056145192 +2021-10-31,15579.754426081672,19803.30404900776,-4223.54962292609,174628.02355441434,217060.4991178476,-42432.47556343325,13758.395732984338 +2021-11-30,21685.78594140873,16583.67153944986,5102.114401958868,457023.5993959911,114156.01299434715,342867.586401644,111240.50210684934 +2021-12-31,24654.47373174767,7980.735223012586,16673.73850873508,315736.89676626027,87303.70207997086,228433.1946862894,73528.39121004388 +2022-01-31,28242.79936868144,5082.831756854036,23159.9676118274,422976.062065625,58155.02831095278,364821.0337546723,130507.07645124939 +2022-02-28,41407.03845572054,17231.92142682251,24175.11702889803,458436.5199693973,168178.58863764838,290257.9313317489,162627.16503945398 +2022-03-31,17986.95128633439,15602.860157714256,2384.091128620136,227201.3899887456,185512.87236845648,41688.51762028909,24356.056737308983 +2022-04-30,30569.377536544464,15935.107520614809,14634.270015929656,144020.7698110707,53317.56578557123,90703.20402549946,24995.99724248648 +2022-05-31,33696.5827544817,16569.055200289185,17127.527554192515,191174.06501677667,152418.6116598562,38755.45335692048,45241.593816670116 +2022-06-30,11858.016508799908,6110.669776011356,5747.346732788553,270843.1154505025,95299.15503958758,175543.9604109149,37155.42647400731 +2022-07-31,34301.79407605753,10376.98592816409,23924.80814789344,427205.9063689973,179034.55808189,248171.34828710725,152057.56963752082 +2022-08-31,16820.964947491662,6738.035892876946,10082.929054614717,444292.23330253735,84873.28580099829,359418.9475015391,105886.0160880802 +2022-09-30,12602.06371941118,17946.551388133903,-5344.487668722722,102780.85221247628,188187.5476204932,-85406.69540801691,-6540.4149581962965 +2022-10-31,47955.42149013333,14349.471902413368,33605.949587719966,304298.9210310263,127347.06926010748,176951.85177091882,123034.96658065131 +2022-11-30,48625.28132298237,9963.470372789738,38661.81095019264,266964.4012595116,237345.9977473469,29618.40351216469,141863.40413318126 +2022-12-31,42335.89392465845,5953.375254290355,36382.518670368096,188843.1241882921,77504.18882919865,111338.93535909343,122339.84624704311 +2023-01-31,22184.55076693483,9664.734825734931,12519.815941199897,147946.14693347312,118213.2702100517,29732.876723421417,13397.684187193208 +2023-02-28,13906.884560255356,9877.749830401206,4029.1347298541496,235046.0685614512,72694.7042481178,162351.36431333338,17816.37264147712 +2023-03-31,37369.32106048628,15944.09267507096,21425.228385415317,477163.8815650077,234938.72365571256,242225.1579092951,185564.37320410696 +2023-04-30,27606.099749584053,14563.362070328198,13042.737679255855,229281.1728083021,225467.8706761962,3813.3021321058914,55753.882784208734 +2023-05-31,14881.529393791152,18308.1911386449,-3426.661744853747,307516.2486973464,101588.32554303113,205927.9231543153,48652.47391110044 +2023-06-30,29807.076404450807,12083.223877429238,17723.85252702157,381207.5835580711,181996.8092068358,199210.7743512353,126011.48740696312 +2023-07-31,11375.540844608737,6793.913689074526,4581.627155534209,245451.8409517176,213444.4400402432,32007.400911474426,37880.51516271149 +2023-08-31,46372.81608315128,15698.671808344923,30674.14427480636,488712.8330883842,161040.16231989246,327672.6707684918,182176.21421550104 +2023-09-30,20351.19926400068,16411.775729253462,3939.4235347472168,484978.9179768445,155930.11567120132,329048.8023056432,125047.93903373237 +2023-10-31,36500.89137415928,13419.157963542444,23081.73341061684,200712.91833014565,98370.45818009034,102342.46015005533,60401.63608154071 +2023-11-30,22468.44304357644,16564.507699318416,5903.935344258021,298899.4023569542,68620.55356117984,230278.84879577436,44330.98673927653 +2023-12-31,30802.720847112432,12406.933945465862,18395.78690164657,220351.32392670785,229443.1515906653,-9091.82766395749,68183.33500982501 diff --git a/Automated Financial Reporting with Deep Learning/financial_summary.csv b/Automated Financial Reporting with Deep Learning/financial_summary.csv new file mode 100644 index 0000000000..27a0729111 --- /dev/null +++ b/Automated Financial Reporting with Deep Learning/financial_summary.csv @@ -0,0 +1,9 @@ +,Revenue,Expenses,Profit,Assets,Liabilities,Equity,Predicted_Equity +count,48.0,48.0,48.0,48.0,48.0,48.0,48.0 +mean,27970.52540395354,12615.581078624606,15354.944325328936,293620.7021179637,142168.69030742114,151452.01181054255,81342.38359427034 +std,11684.317642560598,4552.29525882751,12722.1875860061,119731.38501451364,57834.78672426573,138729.4317754825,56935.44935264 +min,10823.379771832098,5082.831756854036,-5344.487668722722,102780.85221247628,53317.56578557123,-85406.69540801691,-9813.170596191005 +25%,17320.38496767402,8797.860413209477,4980.638525621922,197667.48529382475,96970.42035875683,29704.258420607235,34029.04988138688 +50%,27441.95024763434,13170.547718761463,15654.004262332368,270929.76139696117,149213.17835064244,176099.7604314527,71176.8686838477 +75%,36717.99879574103,16572.709285079356,23987.385368144587,421845.6385861406,184698.5502029959,248337.2291298779,127135.38466803469 +max,48796.39408647977,19803.30404900776,40255.75542351374,488712.8330883842,247130.0908221201,384047.6151521926,185564.37320410696 diff --git a/Automated Financial Reporting with Deep Learning/readme.md b/Automated Financial Reporting with Deep Learning/readme.md new file mode 100644 index 0000000000..1df0f53b78 --- /dev/null +++ b/Automated Financial Reporting with Deep Learning/readme.md @@ -0,0 +1,26 @@ +# Automated Financial Reporting with Deep Learning + +## Overview +This project aims to automate the generation of financial reports using deep learning, reducing manual effort and errors. The project involves creating a synthetic dataset, training a deep learning model, and generating financial reports. + +## Dataset +The dataset contains the following columns: +- `Date`: The date of the observation. +- `Revenue`: The revenue for the period. +- `Expenses`: The expenses for the period. +- `Profit`: The profit for the period. +- `Assets`: The total assets value. +- `Liabilities`: The total liabilities value. +- `Equity`: The total equity value. + +## Project Structure +- `financial_data.csv`: The synthetic dataset file. +- `generate_dataset.py`: Script to generate the synthetic dataset. +- `train_model.py`: Script to train the deep learning model. +- `evaluate_model.py`: Script to evaluate the trained model. +- `generate_report.py`: Script to generate financial reports. + +## Setup +1. Install the required packages: + ```bash + pip install pandas numpy scikit-learn tensorflow