예제 #1
0
def naiv_pred():
    flag=int(request.args.get('flag'))
    li=[]
    te=pd.read_csv("test.csv")
    if(flag):
        li.append(request.args.get('customerID'))
        li.append(request.args.get('Gender'))
        li.append(request.args.get('SeniorCitizen'))
        li.append(request.args.get('Partner'))
        li.append(request.args.get('Dependents'))
        li.append(request.args.get('tenure'))
        li.append(request.args.get('PhoneService'))
        li.append(request.args.get('MultipleLines'))
        li.append(request.args.get('InternetService'))
        li.append(request.args.get('OnlineSecurity'))
        li.append(request.args.get('OnlineBackup'))
        li.append(request.args.get('DeviceProtection'))
        li.append(request.args.get('TechSupport'))
        li.append(request.args.get('StreamingTV'))
        li.append(request.args.get('StreamingMovies'))
        li.append(request.args.get('Contract'))
        li.append(request.args.get('PaperlessBilling'))
        li.append(request.args.get('BaymentMrthod'))
        li.append(request.args.get('MonthlyCharges'))
        li.append(request.args.get('TotalCharges'))
        dic={}
        c=0
        for i in X.columns:
            dic[i]=[li[c]]
            c+=1
        te=pd.DataFrame(data=dic)
    te_c=prep.cleaning(te.copy())["data"]
    te["Churn"]=df["d"]["Churn"].inverse_transform(clf_naiv.get_pred(te_c))
    data={"pred":te.head(500).to_json()}
    return jsonify(data)
예제 #2
0
def prp():
    df=prep.cleaning(pd.read_csv("dataset.csv"))["data"]
    data={"data":df.head(500).to_json()}
    return jsonify(data)
예제 #3
0
import prep
import LR
import LOGR
import RF
import KNN
import SVM
import Dtree
import naiv
import pandas as pd
import json
from flask import Flask,jsonify,request,render_template
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA

df=prep.cleaning(pd.read_csv("dataset.csv")) #load the dataset

lda = LDA(n_components = 8)   #select 8 feature
X=df["data"].drop("Churn",axis=1)  
Y=df["data"]["Churn"]
lda.fit(X,Y)   #fit the data to select the best feature

clf_log=LOGR.LR(df["data"].copy(),"Churn",lda)  #intiate object from logisticRegression Class
clf_KNN=KNN.KNN(df["data"].copy(),"Churn",lda)  #intiate object from K-NN Class
clf_RF=RF.RF(df["data"].copy(),"Churn",lda)   #intiate object from RandomForest Class
clf_SVM=SVM.SV(df["data"].copy(),"Churn",lda)   #intiate object from RandomForest Class
clf_Dt=Dtree.DT(df["data"].copy(),"Churn",lda)   #intiate object from RandomForest Class
clf_naiv=naiv.RF(df["data"].copy(),"Churn",lda)   #intiate object from RandomForest Class

app = Flask(__name__)

@app.route("/",methods=["GET","POST"])
def hello():