diff --git a/F-DetectoR/README.md b/F-DetectoR/README.md new file mode 100644 index 00000000..a0e86847 --- /dev/null +++ b/F-DetectoR/README.md @@ -0,0 +1,16 @@ +# F-DETECTOR + +ML integrated web app to predict the genuinity of transactions by inputting the case details + +# LIBRARIES USED +- Scikit-learn +- Pandas +- Numpy +- pylab +- matplotlib + +# FRAMEWORKS USED +- FLASK + +# HOW TO CONTRIBUTE? +Feel free to suggest your opinions by creating an issue or mail us at gthackers4evri1@gmail.com diff --git a/F-DetectoR/__pycache__/forms.cpython-36.pyc b/F-DetectoR/__pycache__/forms.cpython-36.pyc new file mode 100644 index 00000000..74d6738c Binary files /dev/null and b/F-DetectoR/__pycache__/forms.cpython-36.pyc differ diff --git a/F-DetectoR/__pycache__/run.cpython-36.pyc b/F-DetectoR/__pycache__/run.cpython-36.pyc new file mode 100644 index 00000000..ca95698a Binary files /dev/null and b/F-DetectoR/__pycache__/run.cpython-36.pyc differ diff --git a/F-DetectoR/forms.py b/F-DetectoR/forms.py new file mode 100644 index 00000000..6a9993e1 --- /dev/null +++ b/F-DetectoR/forms.py @@ -0,0 +1,16 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, SubmitField +from wtforms.validators import DataRequired + + +class CheckForm(FlaskForm): + Step = StringField('Step: ',validators=[DataRequired()]) + Type = StringField('Type of transaction: ',validators=[DataRequired()]) + Amount = StringField('Amount of transaction: ',validators=[DataRequired()]) + D_name = StringField('Name of Despositor: ',validators=[DataRequired()]) + A_bal_before = StringField('Account balance of depositor before transaction: ',validators=[DataRequired()]) + A_bal_after = StringField('Account balance of depositor after transaction: ',validators=[DataRequired()]) + P_name = StringField('Name of Payee: ',validators=[DataRequired()]) + P_bal_before = StringField('Account balance of Payee before transaction: ',validators=[DataRequired()]) + P_bal_after = StringField('Account balance of Payee after transaction: ',validators=[DataRequired()]) + Submit=SubmitField('Submit') diff --git a/F-DetectoR/model.pkl b/F-DetectoR/model.pkl new file mode 100644 index 00000000..e31e2733 Binary files /dev/null and b/F-DetectoR/model.pkl differ diff --git a/F-DetectoR/model.py b/F-DetectoR/model.py new file mode 100644 index 00000000..77d1851f --- /dev/null +++ b/F-DetectoR/model.py @@ -0,0 +1,82 @@ +# from google.colab import drive +# drive.mount('/content/gdrive') + +import pandas as pd + +import numpy as np +import scipy.optimize as opt +from sklearn import preprocessing +# %matplotlib inline +import matplotlib.pyplot as plt +import pylab as pl + + +import pickle #Modifications for flask + +text = open("./paysim.csv", "r") + +#join() method combines all contents of +# csvfile.csv and formed as a string +text = ''.join([i for i in text]) + +# search and replace the contents +text = text.replace("PAYMENT", "1") +text = text.replace("TRANSFER", "2") +text = text.replace("CASH_IN", "3") +text = text.replace("CASH_OUT", "4") +text = text.replace("DEBIT", "5") +# output.csv is the output file opened in write mode +x = open("./output.csv", "w") + +# all the replaced text is written in the output.csv file +x.writelines(text) +x.close() + +churn_df = pd.read_csv('./output.csv') + +X = np.asarray(churn_df[['step', 'type', 'amount', 'oldbalanceOrg', 'newbalanceOrig', + 'oldbalanceDest', 'newbalanceDest']]) + +y = np.asarray(churn_df['isFraud']) + +from sklearn import preprocessing +X = preprocessing.StandardScaler().fit(X).transform(X) + +from sklearn.model_selection import train_test_split +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=4) + +from sklearn.linear_model import LogisticRegression +from sklearn.metrics import confusion_matrix +LR = LogisticRegression(C=0.01, solver='liblinear').fit(X_train, y_train) + +yhat = LR.predict(X_test) + +yhat_prob = LR.predict_proba(X_test) + +# from sklearn.metrics import jaccard_similarity_score +# jaccard_similarity_score(y_test, yhat) #it is an output + +# step=float(input()) +# transtype=float(input()) +# amount=float(input()) +# nameorig=str(input()) +# oldbalanceOrg=float(input()) +# newbalanceOrig=float(input()) +# namedest=str(input()) +# oldbalanceDest=float(input()) +# newbalanceDest=float(input()) + +# Z = [[step, transtype, amount, oldbalanceOrg, newbalanceOrig, oldbalanceDest, newbalanceDest]] + + +from sklearn.linear_model import LogisticRegression +from sklearn.metrics import confusion_matrix +LR = LogisticRegression(C=0.01, solver='liblinear').fit(X_train, y_train) + +pickle.dump(LR, open('model.pkl', 'wb')) #Flask modifications + +model = pickle.load(open('model.pkl', 'rb')) + + +yhat = LR.predict(Z) + diff --git a/F-DetectoR/requirements.txt b/F-DetectoR/requirements.txt new file mode 100644 index 00000000..6e9936b0 --- /dev/null +++ b/F-DetectoR/requirements.txt @@ -0,0 +1,27 @@ +beautifulsoup4==4.9.3 +click==7.1.2 +cycler==0.10.0 +Flask==1.1.2 +Flask-WTF==0.14.3 +google==3.0.0 +itsdangerous==1.1.0 +Jinja2==2.11.2 +joblib==1.0.0 +kiwisolver==1.3.1 +MarkupSafe==1.1.1 +matplotlib==3.3.3 +numpy==1.19.4 +pandas==1.1.5 +Pillow==8.0.1 +pyparsing==2.4.7 +python-dateutil==2.8.1 +pytz==2020.4 +scikit-learn==0.23.2 +scipy==1.5.4 +six==1.15.0 +sklearn==0.0 +soupsieve==2.1 +SQLAlchemy==1.3.22 +threadpoolctl==2.1.0 +Werkzeug==1.0.1 +WTForms==2.3.3 diff --git a/F-DetectoR/run.py b/F-DetectoR/run.py new file mode 100644 index 00000000..30ea7938 --- /dev/null +++ b/F-DetectoR/run.py @@ -0,0 +1,58 @@ +from flask import Flask, render_template, url_for, redirect, request +import numpy as np +import pickle +from forms import CheckForm + + +app = Flask(__name__) +app.config['SECRET_KEY']='GTHACKERS' + +model = pickle.load(open('model.pkl', 'rb')) + +@app.route('/') +def home(): + return render_template('GT home.html') + + +@app.route('/about') +def about(): + return render_template('about.html') + + +@app.route('/contact') +def contact(): + return render_template('contact.html') + +@app.route('/predict',methods=['GET','POST']) +def predict(): + # int_features = [1, 3, 565235956.44242, 13959898.5346, 5464.5434, 21545.54534354, 564.4323434] + form = CheckForm() + + if form.is_submitted(): + result = request.form.values() + + a = list(result) + a.remove('Submit') + a.remove(form.D_name.data) + a.remove(form.P_name.data) + + + a=[int(x) for x in a] + + + + final_features = [np.array(a)] + + + prediction=model.predict(final_features) + return render_template('answer.html',prediction=prediction) + + # final_features = [np.array(int_features)] + # prediction = model.predict(final_features) + + return render_template('formsection.html', form=form) + + + +if __name__ == '__main__': + app.run(debug=True) diff --git a/F-DetectoR/static/GThome.css b/F-DetectoR/static/GThome.css new file mode 100644 index 00000000..9394c8a9 --- /dev/null +++ b/F-DetectoR/static/GThome.css @@ -0,0 +1,233 @@ +.mediaViewInfo { + --web-view-name: Web 1920 – 1; + --web-view-id: Web_1920__1; + --web-scale-on-resize: true; + --web-enable-deep-linking: true; + overflow: hidden; +} +:root { + --web-view-ids: Web_1920__1; +} + +#Web_1920__1 { + /* position: absolute; + width: 1920px; + height: 1080px; */ + display: flex; + align-items: center; + justify-content: center; + width: 100vw; + height: 100vh; + background-color: rgba(254,255,255,1); + overflow-x: hidden; + --web-view-name: Web 1920 – 1; + --web-view-id: Web_1920__1; + --web-scale-on-resize: true; + --web-enable-deep-linking: true; +} + +.container_1 { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + width: 100vh; +} + +body { + margin: auto 0; + zoom: 75%; +} +.zone { + + cursor:pointer; + /* display:inline-block; */ + color:black; + font-size:2em; + /* border-radius:4px; */ + /* border:5px solid black; */ + transition: all 0.3s linear; + z-index: 1; +} + +.title { + z-index: 1; + margin-right: auto; + font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif; + font-size: 3vh; + text-align: center; +} +.main-nav { + display: flex; + list-style:none; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + font-weight: 500; + margin-top: -50vh; + position: relative; + right: 50px; +} + +.title { + /* position: relative; + right: 40vw; + bottom: 43vh; + font-size: 50px; */ + display: flex; + margin-top: -85vh; + margin-right: 50vw; + +} + +li { + padding: 15px 50px; + margin-top: 30px; + margin-left: 50px; +} + +.push { + padding: 15px 50px; + border: 5px solid black; + border-radius: 20px; +} +.push:hover{ + background-color: rgb(143, 81, 143); +} + + +#Ellipse_1_j { + fill: url(#Ellipse_1_j); +} +.Ellipse_1_j { + position: absolute; + overflow: visible; + width: 3929px; + height: 2502px; + left: -10px; + top: -1342px; + /* display: flex; + align-items: center; + justify-content: center; + height: 100vh; + width: 100vw; */ + +} +#Ellipse_2_l { + opacity: 0.75; + fill: url(#Ellipse_2_l); +} +.Ellipse_2_l { + filter: drop-shadow(0px 3px 6px rgba(0, 0, 0, 0.161)); + position: absolute; + overflow: visible; + width: 4097px; + height: 2694px; + left: -6px; + top: -1342px; +} +#Ellipse_3_n { + fill: url(#Ellipse_3_n); +} +.Ellipse_3_n { + filter: drop-shadow(3px 3px 12px rgba(0, 0, 0, 0.361)); + position: absolute; + overflow: visible; + width: 208px; + height: 208px; + left: 50px; + top: 858px; +} +#GT { + filter: drop-shadow(3px 3px 12px rgba(0, 0, 0, 0.361)); + left: 93px; + top: 913px; + position: absolute; + overflow: hidden; + width: 91px; + height: 61px; + text-align: center; + font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif; + font-style: normal; + font-weight: normal; + font-size: 50px; + color: rgba(23,37,42,1); +} +.one{ + color: inherit; + text-decoration: none; +} + + +.forms-container { + position: relative; + left: 100vh; + bottom: 75vh; + +} + +.answer-container { + + position: relative; + left: 98vh; + bottom: 50vh; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + font-size: 5rem; + +} + +p { + height: 60px; + font-size: 2rem; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} + +u { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + font-weight: bolder; + font-size: 30px; +} + +.form-size { + height: 30px; + width: 500px; + font-size: 30px; +} + +.submit-size { + width: 180px; + height: 60px; + font-size: 30px; + font-weight: bold; + border-radius: 30px; + border-width: 8px; +} + +.homepage-text { + z-index: 1; + font-family: Nunito; + font-weight: bold; + font-size: 40px; + position: relative; + left: 100vh; + bottom: 50vh; +} + +.btn-start { + color: black; + padding: 30px 0px 0px 35px; + font-family: Nunito; + font-weight: bolder; + font-size: 40px; + height: 10vh; + width: 25vh; + border: 5px solid black; + border-radius: 50px; + position: relative; + left: 120vh; + bottom: 40vh; + cursor: pointer; + +} + +a { + text-decoration: none; +} \ No newline at end of file diff --git a/F-DetectoR/static/logo.ico b/F-DetectoR/static/logo.ico new file mode 100644 index 00000000..a43e2e66 Binary files /dev/null and b/F-DetectoR/static/logo.ico differ diff --git a/F-DetectoR/templates/GT home.html b/F-DetectoR/templates/GT home.html new file mode 100644 index 00000000..dfc35ff2 --- /dev/null +++ b/F-DetectoR/templates/GT home.html @@ -0,0 +1,71 @@ + + + + + + +F-DETECTORS + + + + + +
+
+ + + + + + + + + +
+ +
+ F-DETECTORS +
+ + + + + + + + + + + + + + + + + + + +
+ GT +
+
+{% block content %} +
+ As the digital payment revolution continues to evolve,
+ the need for early fraud detection is critical for the survival of your business.
+ In an effort to combat this growing concern,
we are committed to elevate the security + and integrity of Online Transactions. +
+ +
Get Started
+{% endblock content %} + + \ No newline at end of file diff --git a/F-DetectoR/templates/about.html b/F-DetectoR/templates/about.html new file mode 100644 index 00000000..6b310b92 --- /dev/null +++ b/F-DetectoR/templates/about.html @@ -0,0 +1,65 @@ + + + + + + + + F-DETECTORS + + + + + + + +
+
+ + + + + + + + + +
+ +
+ F-DETECTORS +
+ + + + + + + + + + + + + + + + + + +
+ GT +
+
+ + + \ No newline at end of file diff --git a/F-DetectoR/templates/answer.html b/F-DetectoR/templates/answer.html new file mode 100644 index 00000000..fc762881 --- /dev/null +++ b/F-DetectoR/templates/answer.html @@ -0,0 +1,17 @@ +{% extends "GT home.html" %} + + +{% block content %} + +
+ {% if prediction[0]==0 %} +

Safe

+ {% else %} +

Fraudulent

+ {% endif %} + +
+ + + +{% endblock content %} \ No newline at end of file diff --git a/F-DetectoR/templates/contact.html b/F-DetectoR/templates/contact.html new file mode 100644 index 00000000..e31b5d62 --- /dev/null +++ b/F-DetectoR/templates/contact.html @@ -0,0 +1,65 @@ + + + + + + + + F-DETECTORS + + + + + + + +
+
+ + + + + + + + + +
+ +
+ F-DETECTORS +
+ + + + + + + + + + + + + + + + + + +
+ GT +
+
+ + + \ No newline at end of file diff --git a/F-DetectoR/templates/formsection.html b/F-DetectoR/templates/formsection.html new file mode 100644 index 00000000..53deeb27 --- /dev/null +++ b/F-DetectoR/templates/formsection.html @@ -0,0 +1,60 @@ + + + +{% extends "GT home.html" %} + +{% block content %} + +
+

Enter the details of the transcation

+
+

+ {{form.Step.label}} + {{form.Step(class="form-size")}} +

+ +

+ {{form.Type.label}} + {{form.Type(class="form-size")}} +

+

+ {{form.Amount.label}} + {{form.Amount(class="form-size")}} + +

+

+ {{form.D_name.label}} + {{form.D_name(class="form-size")}} +

+

+ {{form.A_bal_before.label}} + {{form.A_bal_before(class="form-size")}} +

+

+ {{form.A_bal_after.label}} + {{form.A_bal_after(class="form-size")}} +

+

+ {{form.P_name.label}} + {{form.P_name(class="form-size")}} +

+

+ {{form.P_bal_before.label}} + {{form.P_bal_before(class="form-size")}} +

+

+ {{form.P_bal_after.label}} + {{form.P_bal_after(class="form-size")}} +

+

+ + {{form.Submit(class="submit-size")}} +

+ +
+ +
+ + +{% endblock content %} + diff --git a/GTHACKERS.docx b/GTHACKERS.docx new file mode 100644 index 00000000..eb7aa4d2 Binary files /dev/null and b/GTHACKERS.docx differ diff --git a/GTHACKERS/F-DetectoR b/GTHACKERS/F-DetectoR new file mode 160000 index 00000000..d32ad649 --- /dev/null +++ b/GTHACKERS/F-DetectoR @@ -0,0 +1 @@ +Subproject commit d32ad6499dcaf3cd210a08a412833c4ee93a9286 diff --git a/GTHACKERS/GTHACKERS.docx b/GTHACKERS/GTHACKERS.docx new file mode 100644 index 00000000..eb7aa4d2 Binary files /dev/null and b/GTHACKERS/GTHACKERS.docx differ diff --git a/GTHACKERS/GTHACKERS.txt b/GTHACKERS/GTHACKERS.txt new file mode 100644 index 00000000..370d30ef --- /dev/null +++ b/GTHACKERS/GTHACKERS.txt @@ -0,0 +1,30 @@ +PROJECT DESCRIPTION + + +A case filtering assistant to filter out between fraud and non-fraud cases on money transactions which +may or may not involve money laundering and other fraud means.This model can be used by goverment,banking +and investigation agencies to filter out cases by inputting the case details through a user friendly website +from which the model will predict whether that particular case is expected fraud or not.The ML model working +behind this assistant has been trained properly so that it has accuracy of more than 90%.The above features are +available in the current version and future upgradations to be added can be found in the presentation. + +Contents of Project directory + + +>__pychache__ +>static +>templates +>forms.py +>model.pkl +>model.py +>README.md +>requirements.txt +>run.py + +Ways to Host Project on Local Host + +1.clone the repo +2.open the project folder in a text editor +3.open a new terminal and navigate to project folder also ensure all libraries are installed like flask +4.then type in terminal 'export FLASK_APP = run.py' +5.now type 'flask run' and you will get a link as output,paste it in a browser and run the website in local host \ No newline at end of file