Python 最后,我将权重上传到一个无sql数据库,并在服务器上实现了分类功能。它运行得很快,而且很容易更新。请注意,这是不鼓励的,因此答案应该是搜索解决方案的终点(而不是另一个参考文献的中途停留,随着时间的推移,它往往会变得过时)。请考虑在这里添加一个独立的概要,将

Python 最后,我将权重上传到一个无sql数据库,并在服务器上实现了分类功能。它运行得很快,而且很容易更新。请注意,这是不鼓励的,因此答案应该是搜索解决方案的终点(而不是另一个参考文献的中途停留,随着时间的推移,它往往会变得过时)。请考虑在这里添加一个独立的概要,将,python,web-applications,scikit-learn,Python,Web Applications,Scikit Learn,最后,我将权重上传到一个无sql数据库,并在服务器上实现了分类功能。它运行得很快,而且很容易更新。请注意,这是不鼓励的,因此答案应该是搜索解决方案的终点(而不是另一个参考文献的中途停留,随着时间的推移,它往往会变得过时)。请考虑在这里添加一个独立的概要,将链接保持为reference@zthomas.nc你说的更好的解决方案是什么意思?从你的博客文章来看,这是最简单、最标准的方法。如果您正在寻找更好的部署解决方案,可以使用docker。若它是关于表示的,那个么将UI和后端部分拆分为Flask/R


最后,我将权重上传到一个无sql数据库,并在服务器上实现了分类功能。它运行得很快,而且很容易更新。请注意,这是不鼓励的,因此答案应该是搜索解决方案的终点(而不是另一个参考文献的中途停留,随着时间的推移,它往往会变得过时)。请考虑在这里添加一个独立的概要,将链接保持为reference@zthomas.nc你说的更好的解决方案是什么意思?从你的博客文章来看,这是最简单、最标准的方法。如果您正在寻找更好的部署解决方案,可以使用docker。若它是关于表示的,那个么将UI和后端部分拆分为Flask/ReactJs应用程序可能是合适的。我不明白你在找什么。@GensaGames Fair,也许我需要写下那篇博文的要点,让它成为一个答案
<form
 action="/plot" method="post"
 enctype="multipart/form-data"
>
Select a file: <input type="file" name="upload" />
<input type="submit" value="PCA & LDA" />
</form>
import matplotlib
matplotlib.use('Agg')

import matplotlib.pyplot as plt
import numpy as np
from cStringIO import StringIO

from bottle import route, run, request, static_file
import csv
from matplotlib.font_manager import FontProperties
import colorsys

from sklearn import datasets
from sklearn.decomposition import PCA
from sklearn.lda import LDA

html = '''
<html>
    <body>
        <img src="data:image/png;base64,{}" />
    </body>
</html>
'''

 @route('/')
 def root():
     return static_file('upload.html', root='.')

 @route('/plot', method='POST')
    def plot():

       # Get the data
       upload = request.files.get('upload')
       mydata = list(csv.reader(upload.file, delimiter=','))

       x = [row[0:-1] for row in mydata[1:len(mydata)]]

       classes =  [row[len(row)-1] for row in mydata[1:len(mydata)]]
       labels = list(set(classes))
       labels.sort()

       classIndices = np.array([labels.index(myclass) for myclass in classes])

       X = np.array(x).astype('float')
       y = classIndices
       target_names = labels

       #Apply dimensionality reduction
       pca = PCA(n_components=2)
       X_r = pca.fit(X).transform(X)

       lda = LDA(n_components=2)
       X_r2 = lda.fit(X, y).transform(X)

        #Create 2D visualizations
       fig = plt.figure()
       ax=fig.add_subplot(1, 2, 1)
       bx=fig.add_subplot(1, 2, 2)

       fontP = FontProperties()
       fontP.set_size('small')

       colors = np.random.rand(len(labels),3)

       for  c,i, target_name in zip(colors,range(len(labels)), target_names):
           ax.scatter(X_r[y == i, 0], X_r[y == i, 1], c=c, 
                      label=target_name,cmap=plt.cm.coolwarm)
           ax.legend(loc='upper center', bbox_to_anchor=(1.05, -0.05),
                     fancybox=True,shadow=True, ncol=len(labels),prop=fontP)
           ax.set_title('PCA')
           ax.tick_params(axis='both', which='major', labelsize=6)

       for c,i, target_name in zip(colors,range(len(labels)), target_names):
           bx.scatter(X_r2[y == i, 0], X_r2[y == i, 1], c=c, 
                      label=target_name,cmap=plt.cm.coolwarm)
           bx.set_title('LDA');
           bx.tick_params(axis='both', which='major', labelsize=6)

       # Encode image to png in base64
       io = StringIO()
       fig.savefig(io, format='png')
       data = io.getvalue().encode('base64')

       return html.format(data)

run(host='mindwriting.org', port=8079, debug=True)
from sklearn.externals import joblib
joblib.dump(clf, 'iris-svc.pkl')
FROM hexacta/sklearn-predict-http-api:latest
COPY iris-svc.pkl /usr/src/app/model.pkl
$ docker build -t iris-svc .
$ docker run -d -p 4000:8080 iris-svc
$ curl -H "Content-Type: application/json" -X POST -d '{"sepal length (cm)":4.4}' http://localhost:4000/predictproba
  [{"0":0.8284069169,"1":0.1077571623,"2":0.0638359208}]
$ curl -H "Content-Type: application/json" -X POST -d '[{"sepal length (cm)":4.4}, {"sepal length (cm)":15}]' http://localhost:4000/predict
  [0, 2]