Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions nbs/core/decision-tree.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
"import seaborn as sns\n",
"import sklearn.datasets as sk_datasets\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"from random_tree_models.decisiontree import (\n",
" DecisionTreeClassifier,\n",
" DecisionTreeRegressor,\n",
")\n",
"from random_tree_models.decisiontree.visualize import show_tree\n",
"from random_tree_models.scoring import MetricNames"
]
},
Expand Down Expand Up @@ -111,7 +115,7 @@
"metadata": {},
"outputs": [],
"source": [
"model = dtree.DecisionTreeClassifier(measure_name=MetricNames.gini, max_depth=4)"
"model = DecisionTreeClassifier(measure_name=MetricNames.gini, max_depth=4)"
]
},
{
Expand All @@ -138,7 +142,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model)"
"show_tree(model)"
]
},
{
Expand Down Expand Up @@ -216,7 +220,7 @@
"metadata": {},
"outputs": [],
"source": [
"model = dtree.DecisionTreeRegressor(measure_name=MetricNames.variance, max_depth=2)"
"model = DecisionTreeRegressor(measure_name=MetricNames.variance, max_depth=2)"
]
},
{
Expand All @@ -234,7 +238,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model)"
"show_tree(model)"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions nbs/core/extra-trees.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"import seaborn as sns\n",
"import sklearn.datasets as sk_datasets\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"import random_tree_models.extratrees as et\n",
"from random_tree_models.scoring import MetricNames\n",
"from random_tree_models.utils import ThresholdSelectionMethod"
"from random_tree_models.params import ThresholdSelectionMethod\n",
"from random_tree_models.decisiontree.visualize import show_tree"
]
},
{
Expand Down Expand Up @@ -143,7 +143,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down Expand Up @@ -249,7 +249,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions nbs/core/gradient-boosted-trees.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"import seaborn as sns\n",
"import sklearn.datasets as sk_datasets\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"from random_tree_models.decisiontree.visualize import show_tree\n",
"import random_tree_models.gradientboostedtrees as gbtree\n",
"from random_tree_models.scoring import MetricNames"
]
Expand Down Expand Up @@ -160,7 +160,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down Expand Up @@ -256,7 +256,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down
7 changes: 3 additions & 4 deletions nbs/core/isolation-forest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"import seaborn as sns\n",
"import sklearn.datasets as sk_datasets\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"from random_tree_models.decisiontree.visualize import show_tree\n",
"import random_tree_models.isolationforest as iforest\n",
"from random_tree_models.utils import ColumnSelectionMethod, ThresholdSelectionMethod"
"from random_tree_models.params import ColumnSelectionMethod, ThresholdSelectionMethod"
]
},
{
Expand Down Expand Up @@ -111,7 +111,6 @@
"source": [
"frac_subsamples = 2 / 3\n",
"frac_features = 1 # math.sqrt(X.shape[1]) / X.shape[1]\n",
"frac_subsamples, frac_features, X.shape[1]\n",
"\n",
"# threshold_method = ThresholdSelectionMethod.uniform # selects a random threshold from the linear space between the min and max values in X\n",
"threshold_method = (\n",
Expand Down Expand Up @@ -167,7 +166,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions nbs/core/random-forest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"import seaborn as sns\n",
"import sklearn.datasets as sk_datasets\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"from random_tree_models.decisiontree.visualize import show_tree\n",
"import random_tree_models.randomforest as rf\n",
"from random_tree_models.scoring import MetricNames"
"from random_tree_models.params import MetricNames"
]
},
{
Expand Down Expand Up @@ -135,7 +135,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down Expand Up @@ -238,7 +238,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions nbs/core/robust-random-cut-forest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
"import seaborn as sns\n",
"import sklearn.datasets as sk_datasets\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"from random_tree_models.decisiontree.visualize import show_tree\n",
"import random_tree_models.isolationforest as iforest\n",
"from random_tree_models.utils import ColumnSelectionMethod, ThresholdSelectionMethod"
"from random_tree_models.params import ColumnSelectionMethod, ThresholdSelectionMethod"
]
},
{
Expand Down Expand Up @@ -164,7 +164,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down
21 changes: 10 additions & 11 deletions nbs/core/xgboost.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"$$ \\text{loss}^{(t)} = \\sum_{i=1}^n l(y_i, \\hat{y}^{(t-1)}_i + f^{(t)}(x_i) ) + \\Omega \\left( f^{(t)} \\right) $$ "
"$$ \\text{loss} ^ {(t)} = \\sum_{i=1}^n l(y_i, \\hat{y}^{(t-1)}_i + f^{(t)}(x_i) ) + \\Omega \\left( f^{(t)} \\right) $$"
]
},
{
Expand All @@ -97,7 +97,7 @@
"metadata": {},
"source": [
"For the regularization the authors use\n",
"$$ \\Omega (f_t) = \\gamma N^{(t)}_\\text{leafs} + \\frac{1}{2} \\lambda \\sum^{N^{(t)}_\\text{leafs}}_j w_j^2$$\n",
"$$ \\Omega (f_t) = \\gamma N^{(t)}_\\text{leafs} + \\frac{1}{2} \\lambda \\sum^{N^{(t)}_\\text{leafs}}_j w_j^2 $$\n",
"\n",
"where $\\gamma$ is some constant and $w_j$ is a leaf weight (seems like the $\\gamma_{jm}$ from Friedman et al. but isn't clarified)"
]
Expand Down Expand Up @@ -284,10 +284,9 @@
"import sklearn.datasets as sk_datasets\n",
"from scipy import stats\n",
"\n",
"import random_tree_models.decisiontree as dtree\n",
"import random_tree_models.gradientboostedtrees as gbtree\n",
"from random_tree_models.decisiontree.visualize import show_tree\n",
"import random_tree_models.xgboost as xgboost\n",
"from random_tree_models.scoring import MetricNames"
"from random_tree_models.params import MetricNames"
]
},
{
Expand Down Expand Up @@ -355,7 +354,7 @@
"outputs": [],
"source": [
"model = xgboost.XGBoostClassifier(\n",
" measure_name=\"xgboost\", max_depth=2, n_trees=3, lam=0.0\n",
" measure_name=MetricNames.xgboost, max_depth=2, n_trees=3, lam=0.0\n",
")"
]
},
Expand All @@ -374,7 +373,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down Expand Up @@ -449,7 +448,7 @@
"outputs": [],
"source": [
"model = xgboost.XGBoostRegressor(\n",
" measure_name=\"xgboost\", max_depth=2, n_trees=3, lam=0.0\n",
" measure_name=MetricNames.xgboost, max_depth=2, n_trees=3, lam=0.0\n",
")"
]
},
Expand All @@ -468,7 +467,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down Expand Up @@ -610,7 +609,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down Expand Up @@ -719,7 +718,7 @@
"metadata": {},
"outputs": [],
"source": [
"dtree.show_tree(model.trees_[0])"
"show_tree(model.trees_[0])"
]
},
{
Expand Down
10 changes: 3 additions & 7 deletions nbs/dev/xgboost-profiling-histogramming-yay-or-nay.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@
"metadata": {},
"outputs": [],
"source": [
"execution_stats_reg_vanilla = get_class_stats(\n",
" False, None, n_samples_arr, n_features_arr\n",
")"
"execution_stats_reg_vanilla = get_class_stats(False, 256, n_samples_arr, n_features_arr)"
]
},
{
Expand Down Expand Up @@ -363,9 +361,7 @@
"metadata": {},
"outputs": [],
"source": [
"execution_stats_class_vanilla = get_reg_stats(\n",
" False, None, n_samples_arr, n_features_arr\n",
")"
"execution_stats_class_vanilla = get_reg_stats(False, 256, n_samples_arr, n_features_arr)"
]
},
{
Expand Down Expand Up @@ -499,7 +495,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.13.3"
}
},
"nbformat": 4,
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ build-backend = "maturin"
[dependency-groups]
test = [
"pytest>=7.3.1",
"dirty-equals>=0.9.0",
"inline-snapshot>=0.27.2",
]
nb = [
"ipywidgets>=8.0.6",
Expand All @@ -44,6 +46,6 @@ dev = [
"snakeviz>=2.2.0",
"pip-audit>=2.9.0",
"pytest-cov>=6.2.1",
{include-group = "nb"},
{include-group = "test"},
{include-group = "nb"},
{include-group = "test"},
]
Loading
Loading