This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import Required Libraries | |
from flask import Flask,render_template,request,send_file,send_from_directory,jsonify | |
import pickle | |
import numpy as np | |
# We need to initialise the Flask object to run the flask app | |
# By assigning parameters as static folder name,templates folder name | |
app = Flask(__name__,static_folder='static',template_folder='templates') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(function() { | |
$('#predict').click(function() { | |
event.preventDefault(); | |
var form_data = new FormData($('#myform')[0]); | |
console.log(form_data); | |
$.ajax({ | |
type: 'POST', | |
url: '/predict', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Iris Classifier</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | |
</head> | |
<body> | |
<h1><CENTER>Iris Classifier</CENTER></h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing the pickle library | |
import pickle | |
# Dumping the model object to save it as model.pkl file | |
pickle.dump(model,open('model.pkl','wb+')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing the necessary libraries | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.datasets import load_iris | |
from sklearn.model_selection import train_test_split | |
# Load the iris dataset from sklearn datasets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing Required Libraries | |
import pandas as pd | |
import numpy as np | |
# Reading the dataset with column as Sex | |
data=pd.read_csv('train.csv',usecols=['Sex']) | |
# Change column name to Gender |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.regression; | |
import androidx.appcompat.app.AppCompatActivity; | |
import org.tensorflow.lite.Interpreter; | |
import android.content.res.AssetFileDescriptor; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.EditText; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private float doInference(String inputString) { | |
float[] inputVal=new float[1]; | |
inputVal[0]=Float.parseFloat(inputString); | |
float[][] output=new float[1][1]; | |
tflite.run(inputVal,output); | |
return output[0][0]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private MappedByteBuffer loadModelFile() throws IOException { | |
AssetFileDescriptor fileDescriptor=this.getAssets().openFd("degree.tflite"); | |
FileInputStream inputStream=new FileInputStream(fileDescriptor.getFileDescriptor()); | |
FileChannel fileChannel=inputStream.getChannel(); | |
long startOffset=fileDescriptor.getStartOffset(); | |
long declareLength=fileDescriptor.getDeclaredLength(); | |
return fileChannel.map(FileChannel.MapMode.READ_ONLY,startOffset,declareLength); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/relativeLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<EditText |