如何将python脚本更改为服务器 [英] how to change python script into a server

查看:87
本文介绍了如何将python脚本更改为服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理一个项目,该项目需要将服务器连接到 Android 项目.

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

我很困惑如何制作将成为服务器的 python 脚本(推理引擎脚本)

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.

推荐答案

如果您想要相同的 Web 服务,请尝试解决方案,请参考 Miguel 简单的网络服务

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)

这篇关于如何将python脚本更改为服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆