Build a Python program to detect credit card fraud. The program should ingest a batch of transactions, analyze the data, and output the predicted probability of each transaction being fraudulent.
Not applicable
import pandas as pd
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier

# Create a dataframe of the transactions
transactions = pd.DataFrame({
    'amount': [3.23, 5.41, 2.34, 8.45, 10.67, 16.23, 7.68, 18.9],
    'from_account': ['A', 'B', 'B', 'A', 'A', 'C', 'A', 'C'],
    'to_account': ['B', 'A', 'C', 'C', 'B', 'B', 'A', 'A'],
    'timestamp': [1523443123, 1523443642, 1523440452, 1523443167, 1523437395, 1523440491, 1523438586, 1523441126],
})

# Split the data into training and testing
X = transactions[['amount', 'from_account', 'to_account']]
y = transactions['timestamp']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Train a Random Forest Classifier
rfc = RandomForestClassifier(n_estimators=100)
rfc.fit(X_train, y_train)

# Make predictions for the test data
predictions = rfc.predict(X_test)

# Calculate the accuracy of our predictions
accuracy = confusion_matrix(y_test, predictions)
print("Accuracy:", accuracy)

# Calculate the probability of each transaction being fraudulent
pred_proba = rfc.predict_proba(X_test)
print("Fraud Probability:", pred_proba)