Skip to content

Instantly share code, notes, and snippets.

View ksdkamesh99's full-sized avatar
💻
Sleep-Code-Eat

Sai Durga Kamesh Kota ksdkamesh99

💻
Sleep-Code-Eat
View GitHub Profile
# 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')
<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',
<!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>
# Importing the pickle library
import pickle
# Dumping the model object to save it as model.pkl file
pickle.dump(model,open('model.pkl','wb+'))
# 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
# 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
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;
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];
}
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);
}
<?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