-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCryptoTransactionTracker.py
More file actions
25 lines (19 loc) · 980 Bytes
/
CryptoTransactionTracker.py
File metadata and controls
25 lines (19 loc) · 980 Bytes
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
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
# Load the dataset of transaction history
df = pd.read_csv('transaction_data.csv')
# Split the data into training and testing sets
train_data, test_data, train_labels, test_labels = train_test_split(df.drop(['Transaction ID', 'Label'], axis=1), df['Label'], test_size=0.2)
# Train a logistic regression model on the training data
model = LogisticRegression()
model.fit(train_data, train_labels)
# Use the model to predict the labels of the test data
predictions = model.predict(test_data)
# Print the accuracy of the model
accuracy = (predictions == test_labels).mean()
print(f'Accuracy: {accuracy}')
# Use the model to predict the label of a new transaction
new_transaction = [...insert values for new transaction features here...]
predicted_label = model.predict([new_transaction])
print(f'Predicted label for new transaction: {predicted_label}')