-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBank_reconciliation
52 lines (38 loc) · 2.06 KB
/
Bank_reconciliation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
# Load bank account transactions into a pandas DataFrame
bank_transactions = pd.read_csv('bank_transactions.csv')
# Load cash transactions into a pandas DataFrame
cash_transactions = pd.read_csv('cash_transactions.csv')
# Perform data preprocessing if needed (e.g., handle missing values, adjust data types)
# Create a labeled dataset for training the classifier
bank_transactions['label'] = 1 # Mark bank transactions as 1 (reconciled)
cash_transactions['label'] = 0 # Mark cash transactions as 0 (unreconciled)
dataset = pd.concat([bank_transactions, cash_transactions], ignore_index=True)
# Select features for training the classifier
features = ['amount', 'transaction_type'] # Adjust the column names based on your data
# Split the dataset into features (X) and labels (y)
X = dataset[features]
y = dataset['label']
# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Create a random forest classifier
classifier = RandomForestClassifier()
# Train the classifier using the training data
classifier.fit(X_train, y_train)
# Make predictions on the test data
predictions = classifier.predict(X_test)
# Evaluate the classifier performance
classification_metrics = classification_report(y_test, predictions)
# Apply the classifier to reconcile transactions in the bank account data
bank_transactions['reconciled'] = classifier.predict(bank_transactions[features])
# Generate a reconciliation report or output for further analysis or integration with the ERP accounting system
reconciliation_report = pd.DataFrame({
'Bank Transactions': bank_transactions,
'Cash Transactions': cash_transactions,
'Reconciliation Status': bank_transactions['reconciled']
})
# Save the reconciliation report to a file or integrate it into your ERP accounting system
reconciliation_report.to_csv('reconciliation_report.csv', index=False)