Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 27 additions & 0 deletions Deityz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Pitch-to-SBI-Hackathon

#### Team Name - Deityz
#### Problem Statement - Real-Time High Scale Financial Fraud Risk Management
#### Team Leader Email - [email protected]

## A Brief of the Prototype:
There is a home.dart page which have the entries for predicting whether the payment we are about to make is fraudulent or not.

## Tech Stack:
Flutter, Firebase, Numpy, Pandas, Flask

## Step-by-Step Code Execution Instructions:
Requirements:
Flutter sdk
Android sdk

1. git clone repo
2. cd frauddetectionapp
3. run commands flutter clean & flutter pub get
4. run the main.dart which is in lib folder to check the results
5. same process for e-commerce app

## What I Learned:
This project helped our team to explore many parts of flutter including its integration with machine learning.
The project also included machine learning concepts.

Binary file added Deityz/api/age_encoder.pkl
Binary file not shown.
36 changes: 36 additions & 0 deletions Deityz/api/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# make an api which uses ml model pkl file which i have to predict the result and show it to flutter app
# import the necessary packages
from flask import Flask, request, jsonify
import pickle
import numpy as np
import pandas as pd


# initialize our Flask application
app = Flask(__name__)
# load the model from disk
model = pickle.load(open('/home/ambuj/projects/Fraud-Detection-on-Bank-Payment', 'rb'))

@app.route('/predict', methods=['POST'])
def predict():
try:
# Get data from the Flutter app as JSON
data = request.get_json()

# Extract the input features from the JSON data
input_data = data['input_data']

# Use your loaded model to make predictions
prediction = model.predict([input_data])

# Format the prediction as needed
response = {
'prediction': prediction.tolist()
}

return jsonify(response)
except Exception as e:
return jsonify({'error': str(e)})

if __name__ == '__main__':
app.run(debug=True)
72 changes: 72 additions & 0 deletions Deityz/api/api2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# api.py

import pickle

import numpy as np
from flask import Flask, jsonify, request
from sklearn.calibration import LabelEncoder

app = Flask(__name__)
model = pickle.load(open('log-reg-model2.pkl', 'rb'))
customer= pickle.load(open('customer_encoder.pkl', 'rb'))
gender = pickle.load(open('gender_encoder.pkl', 'rb'))
merchant = pickle.load(open('merchant_encoder.pkl', 'rb'))
category = pickle.load(open('category_encoder.pkl', 'rb'))
age = pickle.load(open('age_encoder.pkl', 'rb'))
@app.route('/predict', methods=['GET'])
def predict():
try:
input1 = request.args['input1']
input2 = request.args['input2']
input3 = request.args['input3']
input4 = request.args['input4']
input5 = request.args['input5']
input6 = float(request.args['input6'])

input1=210 #customer
input2=4 #age
input3=2 # gender
input4=30 # merchant
input5=12 #category
# Replace with your prediction logic here
# change the list of inputs to np array
# ['amount','category','merchant','gender','age','customer'] this is the order
arr = np.array([input6, input5, input4, input3,input2,input1]).reshape(1, -1)
prediction = str(model.predict(arr))

response_data = {'prediction': prediction}
return (response_data), 200
except Exception as e:
return {'error': str(e)}, 400


# from flask import Flask, request, jsonify
# import pickle
# from sklearn.calibration import LabelEncoder

# app = Flask(__name__)
# model = pickle.load(open('log-reg-model2.pkl', 'rb'))

# @app.route('/predict', methods=['GET'])
# def predict():
# try:
# input1 = request.args.get('input1')
# input2 = request.args.get('input2')
# input3 = request.args.get('input3')
# input4 = request.args.get('input4')
# input5 = request.args.get('input5')
# input6 = float(request.args.get('input6'))

# # You don't need to use LabelEncoder if your model doesn't require it.
# # If you do need to encode categorical data, use it appropriately.

# # Replace with your prediction logic here
# prediction = model.predict([[input1, input2, input3, input4, input5, input6]])

# response_data = {'prediction': str(prediction)}
# return jsonify(response_data), 200
# except Exception as e:
# return jsonify({'error': str(e)}), 400

if __name__ == '__main__':
app.run(debug=True)
Binary file added Deityz/api/category_encoder.pkl
Binary file not shown.
Binary file added Deityz/api/customer_encoder.pkl
Binary file not shown.
Binary file added Deityz/api/gender_encoder.pkl
Binary file not shown.
Binary file added Deityz/api/log-reg-model.pkl
Binary file not shown.
Binary file added Deityz/api/log-reg-model2.pkl
Binary file not shown.
Binary file added Deityz/api/merchant_encoder.pkl
Binary file not shown.
46 changes: 46 additions & 0 deletions Deityz/e-commerce app/app-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
10 changes: 10 additions & 0 deletions Deityz/e-commerce app/app-master/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 5464c5bac742001448fe4fc0597be939379f88ea
channel: stable

project_type: app
1 change: 1 addition & 0 deletions Deityz/e-commerce app/app-master/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

29 changes: 29 additions & 0 deletions Deityz/e-commerce app/app-master/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
13 changes: 13 additions & 0 deletions Deityz/e-commerce app/app-master/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
70 changes: 70 additions & 0 deletions Deityz/e-commerce app/app-master/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.pawan.ammaFood"
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
39 changes: 39 additions & 0 deletions Deityz/e-commerce app/app-master/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "306266811283",
"project_id": "fraud-detection-app-c1ea2",
"storage_bucket": "fraud-detection-app-c1ea2.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:306266811283:android:176c33b8f1fa1d79da5666",
"android_client_info": {
"package_name": "com.pawan.ammaFood"
}
},
"oauth_client": [
{
"client_id": "306266811283-al3jmtfhlcimfp9sb48o1q1jjb761flv.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBP30QrG4ZBkmqfKsY1HBTvt1x5H02NR_c"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "306266811283-al3jmtfhlcimfp9sb48o1q1jjb761flv.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.quick_order">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.quick_order">
<application
android:label="SLASH"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Loading