Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from sklearn.ensemble import RandomForestClassifier
- from sklearn.model_selection import train_test_split
- from sklearn.preprocessing import LabelEncoder
- def fraud_pred(t_type, amount):
- data = pd.read_csv('dataset.csv')
- lab_encoder = LabelEncoder().fit(data["type"])
- data["type"] = lab_encoder.transform(data["type"])
- X, y = data[["type", "amount"]], data["isFraud"]
- algorithm = RandomForestClassifier(n_estimators=100, max_depth=3)
- algorithm.fit(X, y)
- prediction = algorithm.predict([[lab_encoder.transform([t_type])[0], amount]])[0]
- print(prediction)
- return "Fraud" if prediction == 1 else "Not fraud"
- fraud_pred("TRANSFER", 50000000.00)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement