Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
oegedijk committed Feb 18, 2023
1 parent f703995 commit 6f59760
Show file tree
Hide file tree
Showing 13 changed files with 12,854 additions and 6,570 deletions.
350 changes: 218 additions & 132 deletions explainerdashboard/cli.py

Large diffs are not rendered by default.

3,321 changes: 2,280 additions & 1,041 deletions explainerdashboard/dashboard_components/classifier_components.py

Large diffs are not rendered by default.

1,853 changes: 1,265 additions & 588 deletions explainerdashboard/dashboard_components/composites.py

Large diffs are not rendered by default.

316 changes: 216 additions & 100 deletions explainerdashboard/dashboard_components/connectors.py

Large diffs are not rendered by default.

785 changes: 532 additions & 253 deletions explainerdashboard/dashboard_components/decisiontree_components.py

Large diffs are not rendered by default.

1,569 changes: 1,059 additions & 510 deletions explainerdashboard/dashboard_components/overview_components.py

Large diffs are not rendered by default.

2,416 changes: 1,697 additions & 719 deletions explainerdashboard/dashboard_components/regression_components.py

Large diffs are not rendered by default.

3,257 changes: 2,266 additions & 991 deletions explainerdashboard/dashboard_components/shap_components.py

Large diffs are not rendered by default.

618 changes: 385 additions & 233 deletions explainerdashboard/dashboard_methods.py

Large diffs are not rendered by default.

107 changes: 70 additions & 37 deletions explainerdashboard/datasets.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
__all__ = ['titanic_survive',
'titanic_fare',
'titanic_embarked',
'titanic_names',
'feature_descriptions',
'train_csv',
'test_csv']
__all__ = [
"titanic_survive",
"titanic_fare",
"titanic_embarked",
"titanic_names",
"feature_descriptions",
"train_csv",
"test_csv",
]

import numpy as np
import pandas as pd
from pathlib import Path

train_csv = Path(__file__).resolve().parent / 'datasets'/ 'titanic_train.csv'
test_csv = Path(__file__).resolve().parent / 'datasets'/'titanic_test.csv'
train_csv = Path(__file__).resolve().parent / "datasets" / "titanic_train.csv"
test_csv = Path(__file__).resolve().parent / "datasets" / "titanic_test.csv"
d_train = pd.read_csv(train_csv)
d_test = pd.read_csv(test_csv)

Expand All @@ -20,65 +22,96 @@
"Gender": "Gender of passenger",
"Deck": "The deck the passenger had their cabin on",
"PassengerClass": "The class of the ticket: 1st, 2nd or 3rd class",
"Fare": "The amount of money people paid for their ticket",
"Fare": "The amount of money people paid for their ticket",
"Embarked": "the port where the passenger boarded the Titanic. Either Southampton, Cherbourg or Queenstown",
"Age": "Age of the passenger",
"No_of_siblings_plus_spouses_on_board": "The sum of the number of siblings plus the number of spouses on board",
"No_of_parents_plus_children_on_board" : "The sum of the number of parents plus the number of children on board",
"No_of_parents_plus_children_on_board": "The sum of the number of parents plus the number of children on board",
}


def titanic_survive():
X_train = d_train.drop(['Survival', 'Name'], axis=1)
X_train = d_train.drop(["Survival", "Name"], axis=1)
X_train.index = d_train.Name
X_train.index.name = "Passenger"
y_train = d_train['Survival']
X_test = d_test.drop(['Survival', 'Name'], axis=1)
y_train = d_train["Survival"]
X_test = d_test.drop(["Survival", "Name"], axis=1)
X_test.index = d_test.Name
X_test.index.name = "Passenger"
y_test = d_test['Survival']
y_test = d_test["Survival"]
return X_train, y_train, X_test, y_test


def titanic_fare():
X_train = d_train.drop(['Fare', 'Name'], axis=1)
X_train = d_train.drop(["Fare", "Name"], axis=1)
X_train.index = d_train.Name
X_train.index.name = "Passenger"
y_train = d_train['Fare']
X_test = d_test.drop(['Fare', 'Name'], axis=1)
y_train = d_train["Fare"]
X_test = d_test.drop(["Fare", "Name"], axis=1)
X_test.index = d_test.Name
X_test.index.name = "Passenger"
y_test = d_test['Fare']
y_test = d_test["Fare"]
return X_train, y_train, X_test, y_test


def titanic_embarked():
d_train2 = d_train.copy()
d_train2 = d_train2[d_train2.Embarked_Unknown==0]
X_train = d_train2.drop(['Embarked_Cherbourg', 'Embarked_Queenstown',
'Embarked_Southampton', 'Embarked_Unknown', 'Name'], axis=1)
d_train2 = d_train2[d_train2.Embarked_Unknown == 0]
X_train = d_train2.drop(
[
"Embarked_Cherbourg",
"Embarked_Queenstown",
"Embarked_Southampton",
"Embarked_Unknown",
"Name",
],
axis=1,
)
X_train.index = d_train2.Name
X_train.index.name = "Passenger"

y_train = pd.Series(np.where(d_train2.Embarked_Queenstown==1, 0,
np.where(d_train2.Embarked_Southampton==1, 1,
np.where(d_train2.Embarked_Cherbourg==1, 2, 3))),

name="Embarked")
X_test = d_test.drop(['Embarked_Cherbourg', 'Embarked_Queenstown',
'Embarked_Southampton', 'Embarked_Unknown', 'Name'], axis=1)
y_train = pd.Series(
np.where(
d_train2.Embarked_Queenstown == 1,
0,
np.where(
d_train2.Embarked_Southampton == 1,
1,
np.where(d_train2.Embarked_Cherbourg == 1, 2, 3),
),
),
name="Embarked",
)
X_test = d_test.drop(
[
"Embarked_Cherbourg",
"Embarked_Queenstown",
"Embarked_Southampton",
"Embarked_Unknown",
"Name",
],
axis=1,
)
X_test.index = d_test.Name
X_test.index.name = "Passenger"
y_test = pd.Series(np.where(d_test.Embarked_Queenstown==1, 0,
np.where(d_test.Embarked_Southampton==1, 1,
np.where(d_test.Embarked_Cherbourg==1, 2, 3))),

name="Embarked")
y_test = pd.Series(
np.where(
d_test.Embarked_Queenstown == 1,
0,
np.where(
d_test.Embarked_Southampton == 1,
1,
np.where(d_test.Embarked_Cherbourg == 1, 2, 3),
),
),
name="Embarked",
)
return X_train, y_train, X_test, y_test


def titanic_names(train_only=False, test_only=False):
if train_only:
return d_train['Name'].values.tolist()
return d_train["Name"].values.tolist()
if test_only:
return d_test['Name'].values.tolist()
return (d_train['Name'].values.tolist(), d_test['Name'].values.tolist())
return d_test["Name"].values.tolist()
return (d_train["Name"].values.tolist(), d_test["Name"].values.tolist())

0 comments on commit 6f59760

Please sign in to comment.