0

I am currently working on a project where this project requires a server to be connected to the Android project.

I am confused how to make the python script (inference engine script) that gonna be a server

here the following script that i made :

import numpy as np
import pandas as pd
#from sklearn.ensemble import RandomForestClassifier
#from sklearn.neighbors import KNeighborsClassifier
from sklearn import tree

data = pd.read_csv('datawadek.csv')
y = data.KELAS
x = data.drop('KELAS', axis = 1)

#rf = RandomForestClassifier(n_estimators=20)
#nn =  KNeighborsClassifier()
cart = tree.DecisionTreeClassifier()

#rf.fit(x,y)
cart = cart.fit(x,y)

print (cart.predict([[1,1,2,3,3,1,1,2]]))

im still working on it and got stuck so if so if there are any suggestions or solutions please let me know.

by the way my project is to create an expert system application with data mining methods.

  • try python-flask, a micro web framework for python. If not you can implement the same using python SimpleHttpServer as well, but will be little cumbersome. – Jomin Nov 18 '19 at 09:14

1 Answers1

0

Try solution if you want a web service for the same, please refer to excellent guide from Miguel simple web service

#!flask/bin/python
from flask import Flask

app = Flask(__name__)

@app.route('/', methods=['GET','POST'])
def index(input):
    # input = [[1,1,2,3,3,1,1,2]]
    # do all processing here

    return cart.predict(input)

if __name__ == '__main__':
    app.run(debug=True)
s_mj
  • 530
  • 11
  • 28