Skip to content

Commit

Permalink
class CART init and fit
Browse files Browse the repository at this point in the history
  • Loading branch information
vmirly committed Nov 26, 2024
1 parent 9a4113d commit c39fde1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions decision_tree/cart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@
"y = np.array([0, 1, 1, 0])\n",
"print(gini_split(X, y, feature_index, threshold))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class CART():\n",
" def __init__(\n",
" self,\n",
" max_depth=3,\n",
" min_samples_split=2,\n",
" criterion='gini',\n",
" task_type='classification'\n",
" ):\n",
" self.max_depth = max_depth\n",
" self.min_samples_split = min_samples_split\n",
" self.criterion = criterion\n",
" self.task_type = task_type\n",
" self.tree = None\n",
"\n",
" def fit(self, X, y):\n",
" self.tree = self._build_tree(X, y)"
]
}
],
"metadata": {
Expand Down

0 comments on commit c39fde1

Please sign in to comment.