Skip to content

Commit

Permalink
🔧 fix small error, update project version
Browse files Browse the repository at this point in the history
  • Loading branch information
kaylode committed Apr 12, 2023
1 parent 9cbc62b commit 7c6bda8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages = ["theseus"]

[project]
name = "theseus"
version = "1.1.0"
version = "1.2.0"
description = "A general template for various Deep Learning tasks. Strongly relies on Pytorch"
readme = "README.md"
requires-python = ">=3.6"
Expand Down
2 changes: 1 addition & 1 deletion theseus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__author__ = "kaylode"
__license__ = "MIT"
__copyright__ = "Copyright 2020-present Kaylode"
__version__ = "1.1.0"
__version__ = "1.2.0"

from .base import *
from .registry import Registry
6 changes: 3 additions & 3 deletions theseus/base/metrics/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def __init__(self, label_type: str = "multiclass", **kwargs):
self.threshold = kwargs.get("threshold", 0.5)
self.reset()

def update(self, output: Dict[str, Any], batch: Dict[str, Any]):
def update(self, outputs: Dict[str, Any], batch: Dict[str, Any]):
"""
Perform calculation based on prediction and targets
"""
output = output["outputs"]
outputs = outputs["outputs"]
target = batch["targets"]

prediction = logits2labels(
output, label_type=self.type, threshold=self.threshold
outputs, label_type=self.type, threshold=self.threshold
)

correct = (prediction.view(-1) == target.view(-1)).sum()
Expand Down
16 changes: 16 additions & 0 deletions theseus/tabular/base/preprocessors/splitter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import os.path as osp
import random

from sklearn.model_selection import StratifiedKFold, train_test_split

Expand Down Expand Up @@ -27,6 +28,7 @@ def __init__(
"default",
"stratified",
"stratifiedkfold",
"unique",
], "splitter type not supported"

self.splitter_type = splitter_type
Expand All @@ -49,6 +51,10 @@ def __init__(
elif self.splitter_type == "default":
assert ratio is not None, "should specify ratio"
self.ratio = ratio
elif self.splitter_type == "unique":
assert ratio is not None, "should specify ratio"
self.splitter = random.sample
self.ratio = ratio

def run(self, df):
num_samples, num_features = df.shape
Expand All @@ -63,6 +69,16 @@ def run(self, df):
)
train_df.to_csv(osp.join(self.save_folder, "train.csv"), index=False)
val_df.to_csv(osp.join(self.save_folder, "val.csv"), index=False)
elif self.splitter_type == "unique":
unique_values = df[self.label_column].unique().tolist()
num_unique_samples = len(unique_values)
train_idx = self.splitter(
unique_values, int(num_unique_samples * self.ratio)
)
train_df = df[df[self.label_column].isin(train_idx)]
val_df = df[~df[self.label_column].isin(train_idx)]
train_df.to_csv(osp.join(self.save_folder, "train.csv"), index=False)
val_df.to_csv(osp.join(self.save_folder, "val.csv"), index=False)
else:
x, y = (
df.drop(self.label_column, axis=1).values,
Expand Down

3 comments on commit 7c6bda8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classification Report

Metrics

acc bl_acc weighted-f1 iters
0.25 0.25 0.2 10

Confusion Matrix

Confusion Matrix

Errorcases

Confusion Matrix

Hyperparameters Tuning

Leaderboard

number value datetime_start datetime_complete duration params_optimizer.args.lr best_key model_name state
0 0.75 1681289811103 1681289821686 10582 0.0006145759 bl_acc efficientnet_b0 COMPLETE
1 0.25 1681289821687 1681289832168 10481 0.0003717319 bl_acc efficientnet_b0 COMPLETE

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabular Classification Report

Metrics

acc bl_acc weighted-f1 weighted-precision weighted-recall iters
0.79688 0.76318 0.79182 0.79484 0.79688 0

SHAP train

SHAP

SHAP val

SHAP

Hyperparameters Tuning

Leaderboard

number value datetime_start datetime_complete duration params_gamma params_learning_rate params_max_depth params_n_estimators params_reg_alpha params_reg_lambda best_key model_name state
0 0.7760446979 1681289865077 1681289865325 247 0.6156461025 0.8184015301 3 478 0.5603691333 0.6541650996 bl_acc xgboost COMPLETE
1 0.7896636014 1681289865327 1681289865655 328 0.9319473826 0.2937529949 7 200 0.7813519053 0.875204917 bl_acc xgboost COMPLETE
2 0.78553137 1681289865657 1681289866002 344 0.3784746272 0.7893394762 8 225 0.7349142379 0.2778433881 bl_acc xgboost COMPLETE

Figures
History
Contour plot
Parallel
Importance
Slice

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic Report

Metrics

precision recall dice iters
0.19583 1 0.32743 2
0.19583 1 0.32743 4
0.19681 1 0.32881 6
0.24579 1 0.39452 8
0.53645 0.99993 0.69825 10

Prediction

Prediction

Please sign in to comment.