This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
import pickle | |
dataset = pd.read_csv('sales.csv') | |
dataset['rate'].fillna(0, inplace=True) | |
dataset['sales_in_first_month'].fillna(dataset['sales_in_first_month'].mean(), inplace=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = 'http://localhost:5000/results' | |
r = requests.post(url,json={'rate':5, 'sales_in_first_month':200, 'sales_in_second_month':400}) | |
print(r.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from flask import Flask, request, jsonify, render_template | |
import pickle | |
app = Flask(__name__) | |
model = pickle.load(open('model.pkl', 'rb')) | |
@app.route('/') | |
def home(): | |
return render_template('index.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rate | sales_in_first_month | sales_in_second_month | sales_in_third_month | |
---|---|---|---|---|
2 | 500 | 300 | ||
4 | 300 | 650 | ||
four | 600 | 200 | 400 | |
nine | 450 | 320 | 650 | |
seven | 600 | 250 | 350 | |
five | 550 | 200 | 700 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(https://fonts.googleapis.com/css?family=Open+Sans); | |
html { width: 100%; height:100%; overflow:hidden; } | |
body { | |
width: 100%; | |
height:100%; | |
font-family: 'Helvetica'; | |
background: #000; | |
color: #fff; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html > | |
<head> | |
<meta charset="UTF-8"> | |
<title>Deployment Tutorial 1</title> | |
<link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'> | |
<link href='https://fonts.googleapis.com/css?family=Arimo' rel='stylesheet' type='text/css'> | |
<link href='https://fonts.googleapis.com/css?family=Hind:300' rel='stylesheet' type='text/css'> | |
<link href='https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'> | |
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i=0 | |
prop_class=[] | |
mis_class=[] | |
for i in range(len(Y_test)): | |
if(np.argmax(Y_test[i])==np.argmax(Y_pred_tta[i])): | |
prop_class.append(i) | |
if(len(prop_class)==8): | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import roc_auc_score, auc | |
from sklearn.metrics import roc_curve | |
roc_log = roc_auc_score(np.argmax(Y_test, axis=1), np.argmax(Y_pred_tta, axis=1)) | |
false_positive_rate, true_positive_rate, threshold = roc_curve(np.argmax(Y_test, axis=1), np.argmax(Y_pred_tta, axis=1)) | |
area_under_curve = auc(false_positive_rate, true_positive_rate) | |
plt.plot([0, 1], [0, 1], 'r--') | |
plt.plot(false_positive_rate, true_positive_rate, label='AUC = {:.3f}'.format(area_under_curve)) | |
plt.xlabel('False positive rate') | |
plt.ylabel('True positive rate') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import classification_report | |
classification_report( np.argmax(Y_test, axis=1), np.argmax(Y_pred_tta, axis=1)) | |
from sklearn.metrics import confusion_matrix | |
def plot_confusion_matrix(cm, classes, | |
normalize=False, | |
title='Confusion matrix', | |
cmap=plt.cm.Blues): | |
if normalize: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
history_df = pd.DataFrame(history.history) | |
history_df[['loss', 'val_loss']].plot() | |
history_df = pd.DataFrame(history.history) | |
history_df[['acc', 'val_acc']].plot() |
NewerOlder