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
X_train, X_test, y_train, y_test \ | |
= train_test_split(X, y, test_size=0.1, random_state=1) | |
X_train, X_valid, y_train, y_valid \ | |
= train_test_split(X_train, y_train, test_size=0.1, random_state=1) | |
X_train.shape, X_test.shape, X_valid.shape | |
((4131, 8), (511, 8), (459, 8)) |
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 sqlalchemy import create_engine | |
engine = create_engine("sqlite:///car_prediction_dataset.sqlite3") | |
query = """ | |
SELECT | |
year, | |
price, | |
km_traveled, | |
tax, | |
enginesize, |
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
%%sql | |
results << SELECT | |
year, | |
price, | |
km_traveled, | |
tax, | |
enginesize, | |
km_per_liters, | |
mi.model, | |
transmission, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# find the distribution of website sessions in morning, afternoon, evening and night | |
%%sql | |
result << | |
SELECT | |
CASE | |
WHEN HOUR(created_at) BETWEEN 7 AND 12 THEN 'morning' | |
WHEN HOUR(created_at) BETWEEN 12 AND 16 THEN 'afternoon' | |
WHEN HOUR(created_at) BETWEEN 16 AND 20 THEN 'evening' | |
ELSE 'night' | |
END AS divide, |
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 have stored my credentials in a json file | |
import json | |
import pandas as pd | |
import plotly.express as px | |
with open("creds.json","r") as f: | |
creds = json.load(f) | |
# my username | |
user = creds['user'] | |
# my password | |
password = creds['password'] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
A = interactive(scatter_plot_int, | |
x = widgets.Dropdown( | |
options = ['person_age','person_income','person_emp_length','loan_amnt','loan_int_rate','loan_percent_income','cb_person_cred_hist_length'] | |
), | |
y = widgets.Dropdown( | |
options = ['person_age','person_income','person_emp_length','loan_amnt','loan_int_rate','loan_percent_income','cb_person_cred_hist_length'] | |
) | |
) | |
B = interactive(scatter_plot_int_with_hue, |
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
def interactive_crosstab(index = 'loan_grade', column = 'loan_intent'): | |
crosstab = pd.crosstab(df[index], df[column]).style.text_gradient(cmap = 'icefire').applymap(lambda x : 'font-size:22.2px; font-weight:bold') | |
return (crosstab.set_table_styles([ | |
{ | |
"selector":"thead", | |
"props": [("background-color", "#d0d0df"), | |
("color", "black"), | |
("font-size", "20px"), ("font-style", "bold")] | |
}, | |
{ |
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
def visualize_pivot_tables(index = 'person_home_ownership', column = 'loan_grade', values = 'loan_amnt', axis = 0): | |
color_palette = sns.color_palette("vlag_r", as_cmap=True) | |
t = pd.pivot_table(data = df, index = index, columns = column, values = values) | |
return t.style.background_gradient(color_palette,axis = axis).applymap(lambda x : 'font-size:17.2px; font-weight:bold; opacity:0.9') | |
E = interact(visualize_pivot_tables, | |
index = widgets.Dropdown( | |
options = ['person_home_ownership', 'loan_intent', 'loan_grade','cb_person_default_on_file','loan_status'] | |
), | |
column = widgets.Dropdown( |