Python modulenotfounderror:没有名为';sklearn.线性模型.逻辑和x27;论蟒蛇瓶

Python modulenotfounderror:没有名为';sklearn.线性模型.逻辑和x27;论蟒蛇瓶,python,scikit-learn,Python,Scikit Learn,我的电脑运行有问题。它不断收到一个内部服务器错误。我不知道为什么,它一直这样做。我尝试了很多方法,但仍然没有成功。它一直在说“modulenotfounderror:没有名为'sklearn.linear_model.logistic'的模块”。有办法解决这个问题吗 from flask import Flask, render_template from flask import jsonify from datetime import datetime import numpy as np

我的电脑运行有问题。它不断收到一个内部服务器错误。我不知道为什么,它一直这样做。我尝试了很多方法,但仍然没有成功。它一直在说“modulenotfounderror:没有名为'sklearn.linear_model.logistic'的模块”。有办法解决这个问题吗

from flask import Flask, render_template 
from flask import jsonify
from datetime import datetime
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LogisticRegression
from mpl_toolkits import mplot3d
from sklearn.datasets import load_iris
from sklearn import datasets
import csv
import joblib


app = Flask(__name__) 

def predict(sepal_length, sepal_width, petal_length, petal_width):
    test_data = np.array([sepal_length, sepal_width, petal_length,petal_width])
    test_data = test_data.reshape(1,-1)
    file = open("data/iris.pkl","rb")
    trained_model = joblib.load(file)
    prediction = trained_model.predict(test_data)
    return prediction

@app.route("/iris/<sepal_length>/<sepal_width>/<petal_length>/<petal_width>")
def iris(sepal_length, sepal_width, petal_length, petal_width):
    result=predict(np.double(sepal_length),
                np.double(sepal_width),
                np.double(petal_length),
                np.double(petal_width))
    if result[0]==0:
        hasil='Setosa'
    elif result[0]==1:
        hasil='Versicolor'
    else:
        hasil='Virginica'
    return hasil
从烧瓶导入烧瓶,渲染\u模板
从flask导入jsonify
从日期时间导入日期时间
将numpy作为np导入
作为pd进口熊猫
导入matplotlib
matplotlib.use('Agg')
将matplotlib.pyplot作为plt导入
从sklearn.linear\u模型导入线性回归
从sklearn.linear_模型导入逻辑回归
从mpl_工具包导入mplot3d
从sklearn.dataset导入加载
从sklearn导入数据集
导入csv
导入作业库
app=烧瓶(名称)
def预测(萼片长度、萼片宽度、花瓣长度、花瓣宽度):
test\u data=np.数组([萼片长度、萼片宽度、花瓣长度、花瓣宽度])
测试数据=测试数据。重塑(1,-1)
文件=打开(“data/iris.pkl”、“rb”)
trained_model=joblib.load(文件)
预测=经过训练的模型。预测(测试数据)
收益预测
@应用程序路径(“/iris/”)
def虹膜(萼片长度、萼片宽度、花瓣长度、花瓣宽度):
结果=预测(np.双倍(萼片长度),
np.重瓣(萼片宽),
np.双瓣(花瓣长度),
np.双瓣(花瓣宽度))
如果结果[0]==0:
hasil='Setosa'
elif结果[0]==1:
hasil='Versicolor'
其他:
哈西尔·维吉尼亚'
返回哈西尔

检查scikit learn的版本,可能是0.21.x。升级版本

以下是scikit学习稳定版: