This file contains hidden or 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 plotly.express as px | |
fig = px.scatter(x=data['tenure'], y=data['TotalCharges'], | |
color = data['Churn'], template = 'presentation', | |
opacity = 0.5, facet_col = data['Contract'], | |
title = 'Customer Churn by Tenure, Charges, and Contract Type', | |
labels = {'x' : 'Customer Tenure', 'y' : 'Total Charges $'}) | |
fig.show() |
This file contains hidden or 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 | |
def get_predictions(carat_weight, cut, color, clarity, polish, symmetry, report): | |
url = 'http://localhost:8000/predict?carat_weight={carat_weight}&cut={cut}&color={color}&clarity={clarity}&polish={polish}&symmetry={symmetry}&report={report}'\ | |
.format(carat_weight = carat_weight, cut = cut,\ | |
color = color, clarity = clarity, polish = polish, symmetry = symmetry, report = report) | |
x = requests.post(url) | |
print(x.text) |
This file contains hidden or 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
# 1. Library imports | |
import pandas as pd | |
from pycaret.regression import load_model, predict_model | |
from fastapi import FastAPI | |
import uvicorn | |
# 2. Create the app object | |
app = FastAPI() | |
#. Load trained Pipeline |
This file contains hidden or 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 gradio as gr | |
model = gr.inputs.Dropdown(list(compare_model_results['Model']), label="Model") | |
sepal_length = gr.inputs.Slider(minimum=1, maximum=10, default=data['sepal_length'].mean(), label = 'sepal_length') | |
sepal_width = gr.inputs.Slider(minimum=1, maximum=10, default=data['sepal_width'].mean(), label = 'sepal_width') | |
petal_length = gr.inputs.Slider(minimum=1, maximum=10, default=data['petal_length'].mean(), label = 'petal_length') | |
petal_width = gr.inputs.Slider(minimum=1, maximum=10, default=data['petal_width'].mean(), label = 'petal_width') | |
gr.Interface(predict, [model,sepal_length,sepal_width,petal_length,petal_width], "label", live=True).launch() |
This file contains hidden or 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
# creating a predict function to be passed into gradio UI | |
def predict(model, sepal_length, sepal_width, petal_length, petal_width): | |
df = pd.DataFrame.from_dict({'sepal_length': [sepal_length], 'sepal_width': [sepal_width], | |
'petal_length': [petal_length], 'petal_width': [petal_width]}) | |
model_index = list(compare_model_results['Model']).index(model) | |
model = best[model_index] | |
pred = predict_model(model, df, raw_score=True) | |
return {'Iris-setosa': pred['Score_Iris-setosa'][0].astype('float64'), |
This file contains hidden or 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 tqdm import tqdm | |
from pycaret.regression import * | |
all_ts = data['time_series'].unique() | |
all_results = [] | |
final_model = {} | |
for i in tqdm(all_ts): | |