diff --git a/notebooks/benchmark.ipynb b/notebooks/benchmark.ipynb index b87cf36..ef41f09 100644 --- a/notebooks/benchmark.ipynb +++ b/notebooks/benchmark.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -29,7 +29,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -39,13 +39,13 @@ "from sklearn.model_selection import train_test_split\n", "from sklearn import tree\n", "from sklearn.metrics import classification_report, confusion_matrix, f1_score\n", - "from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier\n", + "from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier, BaggingClassifier\n", "from stree import Stree" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -64,13 +64,15 @@ }, { "cell_type": "code", - "execution_count": 6, - "metadata": {}, + "execution_count": 4, + "metadata": { + "tags": [] + }, "outputs": [ { "output_type": "stream", "name": "stdout", - "text": "2020-06-15 10:17:17\n" + "text": "2020-06-27 23:33:07\n" } ], "source": [ @@ -86,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -98,8 +100,10 @@ }, { "cell_type": "code", - "execution_count": 8, - "metadata": {}, + "execution_count": 6, + "metadata": { + "tags": [] + }, "outputs": [ { "output_type": "stream", @@ -114,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -126,8 +130,10 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, + "execution_count": 8, + "metadata": { + "tags": [] + }, "outputs": [ { "output_type": "stream", @@ -151,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -162,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -172,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -182,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -192,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -202,12 +208,12 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ - "# Gradient Boosting\n", - "gradient = GradientBoostingClassifier(random_state=random_state)" + "# Bagging\n", + "bagging = BaggingClassifier(random_state=random_state)" ] }, { @@ -219,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -244,20 +250,22 @@ }, { "cell_type": "code", - "execution_count": 18, - "metadata": {}, + "execution_count": 16, + "metadata": { + "tags": [] + }, "outputs": [ { "output_type": "stream", "name": "stdout", - "text": "************************** Linear Tree **********************\nTrain Model Linear Tree took: 13.91 seconds\n=========== Linear Tree - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 1.000000 1.000000 1.000000 199020\n 1 1.000000 1.000000 1.000000 344\n\n accuracy 1.000000 199364\n macro avg 1.000000 1.000000 1.000000 199364\nweighted avg 1.000000 1.000000 1.000000 199364\n\n=========== Linear Tree - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999578 0.999613 0.999596 85295\n 1 0.772414 0.756757 0.764505 148\n\n accuracy 0.999192 85443\n macro avg 0.885996 0.878185 0.882050 85443\nweighted avg 0.999184 0.999192 0.999188 85443\n\nConfusion Matrix in Train\n[[199020 0]\n [ 0 344]]\nConfusion Matrix in Test\n[[85262 33]\n [ 36 112]]\n************************** Random Forest **********************\nTrain Model Random Forest took: 173.1 seconds\n=========== Random Forest - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 1.000000 1.000000 1.000000 199020\n 1 1.000000 1.000000 1.000000 344\n\n accuracy 1.000000 199364\n macro avg 1.000000 1.000000 1.000000 199364\nweighted avg 1.000000 1.000000 1.000000 199364\n\n=========== Random Forest - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999660 0.999965 0.999812 85295\n 1 0.975410 0.804054 0.881481 148\n\n accuracy 0.999625 85443\n macro avg 0.987535 0.902009 0.940647 85443\nweighted avg 0.999618 0.999625 0.999607 85443\n\nConfusion Matrix in Train\n[[199020 0]\n [ 0 344]]\nConfusion Matrix in Test\n[[85292 3]\n [ 29 119]]\n************************** Stree (SVM Tree) **********************\nTrain Model Stree (SVM Tree) took: 38.4 seconds\n=========== Stree (SVM Tree) - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 0.999623 0.999864 0.999744 199020\n 1 0.908784 0.781977 0.840625 344\n\n accuracy 0.999488 199364\n macro avg 0.954204 0.890921 0.920184 199364\nweighted avg 0.999467 0.999488 0.999469 199364\n\n=========== Stree (SVM Tree) - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999637 0.999918 0.999777 85295\n 1 0.943548 0.790541 0.860294 148\n\n accuracy 0.999555 85443\n macro avg 0.971593 0.895229 0.930036 85443\nweighted avg 0.999540 0.999555 0.999536 85443\n\nConfusion Matrix in Train\n[[198993 27]\n [ 75 269]]\nConfusion Matrix in Test\n[[85288 7]\n [ 31 117]]\n************************** AdaBoost model **********************\nTrain Model AdaBoost model took: 47.21 seconds\n=========== AdaBoost model - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 0.999392 0.999678 0.999535 199020\n 1 0.777003 0.648256 0.706815 344\n\n accuracy 0.999072 199364\n macro avg 0.888198 0.823967 0.853175 199364\nweighted avg 0.999008 0.999072 0.999030 199364\n\n=========== AdaBoost model - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999484 0.999707 0.999596 85295\n 1 0.806202 0.702703 0.750903 148\n\n accuracy 0.999192 85443\n macro avg 0.902843 0.851205 0.875249 85443\nweighted avg 0.999149 0.999192 0.999165 85443\n\nConfusion Matrix in Train\n[[198956 64]\n [ 121 223]]\nConfusion Matrix in Test\n[[85270 25]\n [ 44 104]]\n" + "text": "************************** Linear Tree **********************\nTrain Model Linear Tree took: 14.43 seconds\n=========== Linear Tree - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 1.000000 1.000000 1.000000 199020\n 1 1.000000 1.000000 1.000000 344\n\n accuracy 1.000000 199364\n macro avg 1.000000 1.000000 1.000000 199364\nweighted avg 1.000000 1.000000 1.000000 199364\n\n=========== Linear Tree - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999578 0.999613 0.999596 85295\n 1 0.772414 0.756757 0.764505 148\n\n accuracy 0.999192 85443\n macro avg 0.885996 0.878185 0.882050 85443\nweighted avg 0.999184 0.999192 0.999188 85443\n\nConfusion Matrix in Train\n[[199020 0]\n [ 0 344]]\nConfusion Matrix in Test\n[[85262 33]\n [ 36 112]]\n************************** Random Forest **********************\nTrain Model Random Forest took: 165.2 seconds\n=========== Random Forest - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 1.000000 1.000000 1.000000 199020\n 1 1.000000 1.000000 1.000000 344\n\n accuracy 1.000000 199364\n macro avg 1.000000 1.000000 1.000000 199364\nweighted avg 1.000000 1.000000 1.000000 199364\n\n=========== Random Forest - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999660 0.999965 0.999812 85295\n 1 0.975410 0.804054 0.881481 148\n\n accuracy 0.999625 85443\n macro avg 0.987535 0.902009 0.940647 85443\nweighted avg 0.999618 0.999625 0.999607 85443\n\nConfusion Matrix in Train\n[[199020 0]\n [ 0 344]]\nConfusion Matrix in Test\n[[85292 3]\n [ 29 119]]\n************************** Stree (SVM Tree) **********************\nTrain Model Stree (SVM Tree) took: 37.53 seconds\n=========== Stree (SVM Tree) - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 0.999623 0.999864 0.999744 199020\n 1 0.908784 0.781977 0.840625 344\n\n accuracy 0.999488 199364\n macro avg 0.954204 0.890921 0.920184 199364\nweighted avg 0.999467 0.999488 0.999469 199364\n\n=========== Stree (SVM Tree) - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999637 0.999918 0.999777 85295\n 1 0.943548 0.790541 0.860294 148\n\n accuracy 0.999555 85443\n macro avg 0.971593 0.895229 0.930036 85443\nweighted avg 0.999540 0.999555 0.999536 85443\n\nConfusion Matrix in Train\n[[198993 27]\n [ 75 269]]\nConfusion Matrix in Test\n[[85288 7]\n [ 31 117]]\n************************** AdaBoost model **********************\nTrain Model AdaBoost model took: 46.98 seconds\n=========== AdaBoost model - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 0.999392 0.999678 0.999535 199020\n 1 0.777003 0.648256 0.706815 344\n\n accuracy 0.999072 199364\n macro avg 0.888198 0.823967 0.853175 199364\nweighted avg 0.999008 0.999072 0.999030 199364\n\n=========== AdaBoost model - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999484 0.999707 0.999596 85295\n 1 0.806202 0.702703 0.750903 148\n\n accuracy 0.999192 85443\n macro avg 0.902843 0.851205 0.875249 85443\nweighted avg 0.999149 0.999192 0.999165 85443\n\nConfusion Matrix in Train\n[[198956 64]\n [ 121 223]]\nConfusion Matrix in Test\n[[85270 25]\n [ 44 104]]\n************************** Bagging model **********************\nTrain Model Bagging model took: 77.93 seconds\n=========== Bagging model - Train 199,364 samples =============\n precision recall f1-score support\n\n 0 0.999864 1.000000 0.999932 199020\n 1 1.000000 0.921512 0.959153 344\n\n accuracy 0.999865 199364\n macro avg 0.999932 0.960756 0.979542 199364\nweighted avg 0.999865 0.999865 0.999862 199364\n\n=========== Bagging model - Test 85,443 samples =============\n precision recall f1-score support\n\n 0 0.999637 0.999953 0.999795 85295\n 1 0.966942 0.790541 0.869888 148\n\n accuracy 0.999590 85443\n macro avg 0.983289 0.895247 0.934842 85443\nweighted avg 0.999580 0.999590 0.999570 85443\n\nConfusion Matrix in Train\n[[199020 0]\n [ 27 317]]\nConfusion Matrix in Test\n[[85291 4]\n [ 31 117]]\n" } ], "source": [ "# Train & Test models\n", "models = {\n", " 'Linear Tree':linear_tree, 'Random Forest': random_forest, 'Stree (SVM Tree)': stree, \n", - " 'AdaBoost model': adaboost\n", + " 'AdaBoost model': adaboost, 'Bagging model': bagging\n", "}\n", "\n", "best_f1 = 0\n", @@ -273,13 +281,15 @@ }, { "cell_type": "code", - "execution_count": 19, - "metadata": {}, + "execution_count": 17, + "metadata": { + "tags": [] + }, "outputs": [ { "output_type": "stream", "name": "stdout", - "text": "**************************************************************************************************************\n*The best f1 model is Random Forest, with a f1 score: 0.8815 in 173.095 seconds with 0.7 samples in train dataset\n**************************************************************************************************************\nModel: Linear Tree\t Time: 13.91 seconds\t f1: 0.7645\nModel: Random Forest\t Time: 173.09 seconds\t f1: 0.8815\nModel: Stree (SVM Tree)\t Time: 38.40 seconds\t f1: 0.8603\nModel: AdaBoost model\t Time: 47.21 seconds\t f1: 0.7509\n" + "text": "**************************************************************************************************************\n*The best f1 model is Random Forest, with a f1 score: 0.8815 in 165.193 seconds with 0.7 samples in train dataset\n**************************************************************************************************************\nModel: Linear Tree\t Time: 14.43 seconds\t f1: 0.7645\nModel: Random Forest\t Time: 165.19 seconds\t f1: 0.8815\nModel: Stree (SVM Tree)\t Time: 37.53 seconds\t f1: 0.8603\nModel: AdaBoost model\t Time: 46.98 seconds\t f1: 0.7509\nModel: Bagging model\t Time: 77.93 seconds\t f1: 0.8699\n" } ], "source": [ @@ -314,10 +324,11 @@ "******************************************************************************************************************\n", "Model: Linear Tree Time: 23.05 seconds\t f1: 0.7645\n", "Model: Random Forest\t Time: 218.97 seconds\t f1: 0.8815\n", - "Model: Stree (SVM Tree)\t Time: 49.45 seconds\t f1: 0.8467\n", + "Model: Stree (SVM Tree)\t Time: 49.45 seconds\t f1: 0.8603\n", "Model: AdaBoost model\t Time: 73.83 seconds\t f1: 0.7509\n", - "Model: Gradient Boost.\t Time: 388.69 seconds\t f1: 0.5259\n", "Model: Neural Network\t Time: 25.47 seconds\t f1: 0.8328\n", + "Model: Bagging model\t Time: 77.93 seconds\t f1: 0.8699\n", + "\n", "```" ] } diff --git a/notebooks/features.ipynb b/notebooks/features.ipynb index 811fcdd..13508af 100644 --- a/notebooks/features.ipynb +++ b/notebooks/features.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Test smple_weight, kernels, C, sklearn estimator" + "# Test sample_weight, kernels, C, sklearn estimator" ] }, { @@ -68,7 +68,7 @@ { "output_type": "stream", "name": "stdout", - "text": "Fraud: 0.173% 492\nValid: 99.827% 284315\nX.shape (5492, 28) y.shape (5492,)\nFraud: 9.068% 498\nValid: 90.932% 4994\n[0.09131113 0.09131113 0.09131113 0.09131113] [0.08919903 0.08919903 0.08919903 0.08919903]\n" + "text": "Fraud: 0.173% 492\nValid: 99.827% 284315\nX.shape (5492, 28) y.shape (5492,)\nFraud: 9.086% 499\nValid: 90.914% 4993\n[0.09157128 0.09157128 0.09157128 0.09157128] [0.08919903 0.08919903 0.08919903 0.08919903]\n" } ], "source": [ @@ -134,7 +134,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Test simple_weights\n", + "## Test sample_weights\n", "Compute accuracy with weights in samples. The weights are set based on the inverse of the number of samples of each class" ] }, @@ -148,7 +148,7 @@ { "output_type": "stream", "name": "stdout", - "text": "Accuracy of Train without weights 0.9901144640998959\nAccuracy of Train with weights 0.9924557752341311\nAccuracy of Tests without weights 0.9872572815533981\nAccuracy of Tests with weights 0.9824029126213593\n" + "text": "Accuracy of Train without weights 0.9875130072840791\nAccuracy of Train with weights 0.9919354838709677\nAccuracy of Tests without weights 0.9866504854368932\nAccuracy of Tests with weights 0.9872572815533981\n" } ], "source": [ @@ -177,7 +177,7 @@ { "output_type": "stream", "name": "stdout", - "text": "Time: 10.77s\tKernel: linear\tAccuracy_train: 0.986732570239334\tAccuracy_test: 0.9860436893203883\nTime: 1.56s\tKernel: rbf\tAccuracy_train: 0.9945369406867846\tAccuracy_test: 0.9896844660194175\nTime: 1.23s\tKernel: poly\tAccuracy_train: 0.9942767950052029\tAccuracy_test: 0.9860436893203883\n" + "text": "Time: 1.45s\tKernel: linear\tAccuracy_train: 0.9854318418314256\tAccuracy_test: 0.9842233009708737\nTime: 0.50s\tKernel: rbf\tAccuracy_train: 0.9940166493236212\tAccuracy_test: 0.9908980582524272\nTime: 0.42s\tKernel: poly\tAccuracy_train: 0.9945369406867846\tAccuracy_test: 0.9872572815533981\n" } ], "source": [ @@ -200,11 +200,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "tags": [] }, - "outputs": [], + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": "************** C=0.001 ****************************\nClassifier's accuracy (train): 0.9826\nClassifier's accuracy (test) : 0.9854\nroot feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down, - Leaf class=1 belief= 0.986348 impurity=0.0269 counts=(array([0, 1]), array([ 4, 289]))\nroot - Up, - Leaf class=0 belief= 0.982259 impurity=0.0349 counts=(array([0, 1]), array([3488, 63]))\n\n**************************************************\n************** C=0.01 ****************************\nClassifier's accuracy (train): 0.9826\nClassifier's accuracy (test) : 0.9860\nroot feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down, - Leaf class=1 belief= 0.986348 impurity=0.0269 counts=(array([0, 1]), array([ 4, 289]))\nroot - Up, - Leaf class=0 belief= 0.982259 impurity=0.0349 counts=(array([0, 1]), array([3488, 63]))\n\n**************************************************\n************** C=1 ****************************\nClassifier's accuracy (train): 0.9841\nClassifier's accuracy (test) : 0.9848\nroot feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0268\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([286]))\nroot - Down - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.4938\nroot - Down - Up - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([5]))\nroot - Down - Up - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([4]))\nroot - Up, - Leaf class=0 belief= 0.982812 impurity=0.0338 counts=(array([0, 1]), array([3488, 61]))\n\n**************************************************\n************** C=5 ****************************\nClassifier's accuracy (train): 0.9854\nClassifier's accuracy (test) : 0.9873\nroot feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0199\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([295]))\nroot - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([3]))\nroot - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0316\nroot - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.5000\nroot - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([1]))\nroot - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([1]))\nroot - Up - Up, - Leaf class=0 belief= 0.984199 impurity=0.0311 counts=(array([0, 1]), array([3488, 56]))\n\n**************************************************\n************** C=17 ****************************\nClassifier's accuracy (train): 0.9841\nClassifier's accuracy (test) : 0.9836\nroot feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0524\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([287]))\nroot - Down - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.3200\nroot - Down - Up - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([2]))\nroot - Down - Up - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([8]))\nroot - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0349\nroot - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.2975\nroot - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([2]))\nroot - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([9]))\nroot - Up - Up, - Leaf class=0 belief= 0.982749 impurity=0.0339 counts=(array([0, 1]), array([3475, 61]))\n\n**************************************************\n2.3880 secs\n" + } + ], "source": [ "t = time.time()\n", "for C in (.001, .01, 1, 5, 17):\n", @@ -228,7 +234,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": { "tags": [] }, @@ -236,7 +242,7 @@ { "output_type": "stream", "name": "stdout", - "text": "root feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1659\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0139\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([270]))\nroot - Down - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.2311\nroot - Down - Up - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([13]))\nroot - Down - Up - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([2]))\nroot - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0375\nroot - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.5000\nroot - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([1]))\nroot - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([1]))\nroot - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0370\nroot - Up - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.3200\nroot - Up - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([4]))\nroot - Up - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([1]))\nroot - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0348\nroot - Up - Up - Up - Down, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([3]))\nroot - Up - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0349\nroot - Up - Up - Up - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.4688\nroot - Up - Up - Up - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([10]))\nroot - Up - Up - Up - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([6]))\nroot - Up - Up - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0296\nroot - Up - Up - Up - Up - Up - Down, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([9]))\nroot - Up - Up - Up - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0296\nroot - Up - Up - Up - Up - Up - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.4800\nroot - Up - Up - Up - Up - Up - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([3]))\nroot - Up - Up - Up - Up - Up - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([2]))\nroot - Up - Up - Up - Up - Up - Up - Up, - Leaf class=0 belief= 0.985791 impurity=0.0280 counts=(array([0, 1]), array([3469, 50]))\n" + "text": "root feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0524\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([287]))\nroot - Down - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.3200\nroot - Down - Up - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([2]))\nroot - Down - Up - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([8]))\nroot - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0349\nroot - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.2975\nroot - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([2]))\nroot - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([9]))\nroot - Up - Up, - Leaf class=0 belief= 0.982749 impurity=0.0339 counts=(array([0, 1]), array([3475, 61]))\n" } ], "source": [ @@ -247,7 +253,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": { "tags": [] }, @@ -255,7 +261,7 @@ { "output_type": "stream", "name": "stdout", - "text": "root feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1659\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0139\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([270]))\nroot - Down - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.2311\nroot - Down - Up - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([13]))\nroot - Down - Up - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([2]))\nroot - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0375\nroot - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.5000\nroot - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([1]))\nroot - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([1]))\nroot - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0370\nroot - Up - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.3200\nroot - Up - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([4]))\nroot - Up - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([1]))\nroot - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0348\nroot - Up - Up - Up - Down, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([3]))\nroot - Up - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0349\nroot - Up - Up - Up - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.4688\nroot - Up - Up - Up - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([10]))\nroot - Up - Up - Up - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([6]))\nroot - Up - Up - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0296\nroot - Up - Up - Up - Up - Up - Down, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([9]))\nroot - Up - Up - Up - Up - Up - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0296\nroot - Up - Up - Up - Up - Up - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.4800\nroot - Up - Up - Up - Up - Up - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([3]))\nroot - Up - Up - Up - Up - Up - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([2]))\nroot - Up - Up - Up - Up - Up - Up - Up, - Leaf class=0 belief= 0.985791 impurity=0.0280 counts=(array([0, 1]), array([3469, 50]))\n" + "text": "root feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0524\nroot - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([287]))\nroot - Down - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.3200\nroot - Down - Up - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([2]))\nroot - Down - Up - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([8]))\nroot - Up feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.0349\nroot - Up - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.2975\nroot - Up - Down - Down, - Leaf class=1 belief= 1.000000 impurity=0.0000 counts=(array([1]), array([2]))\nroot - Up - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([9]))\nroot - Up - Up, - Leaf class=0 belief= 0.982749 impurity=0.0339 counts=(array([0, 1]), array([3475, 61]))\n" } ], "source": [ @@ -273,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": { "tags": [] }, @@ -281,7 +287,7 @@ { "output_type": "stream", "name": "stdout", - "text": "1 functools.partial(, 'Stree')\n2 functools.partial(, 'Stree')\n3 functools.partial(, 'Stree')\n4 functools.partial(, 'Stree')\n5 functools.partial(, 'Stree')\n6 functools.partial(, 'Stree')\n7 functools.partial(, 'Stree')\n8 functools.partial(, 'Stree')\n9 functools.partial(, 'Stree')\n10 functools.partial(, 'Stree', readonly_memmap=True)\n11 functools.partial(, 'Stree')\n12 functools.partial(, 'Stree')\n13 functools.partial(, 'Stree')\n14 functools.partial(, 'Stree')\n15 functools.partial(, 'Stree')\n16 functools.partial(, 'Stree')\n17 functools.partial(, 'Stree')\n18 functools.partial(, 'Stree')\n19 functools.partial(, 'Stree')\n20 functools.partial(, 'Stree')\n21 functools.partial(, 'Stree')\n22 functools.partial(, 'Stree')\n23 functools.partial(, 'Stree')\n24 functools.partial(, 'Stree', readonly_memmap=True)\n25 functools.partial(, 'Stree', readonly_memmap=True, X_dtype='float32')\n26 functools.partial(, 'Stree')\n27 functools.partial(, 'Stree')\n28 functools.partial(, 'Stree')\n29 functools.partial(, 'Stree')\n30 functools.partial(, 'Stree')\n31 functools.partial(, 'Stree')\n32 functools.partial(, 'Stree')\n33 functools.partial(, 'Stree')\n34 functools.partial(, 'Stree')\n35 functools.partial(, 'Stree')\n36 functools.partial(, 'Stree')\n37 functools.partial(, 'Stree')\n38 functools.partial(, 'Stree')\n39 functools.partial(, 'Stree')\n40 functools.partial(, 'Stree')\n41 functools.partial(, 'Stree')\n42 functools.partial(, 'Stree')\n43 functools.partial(, 'Stree')\n" + "text": "1 functools.partial(, 'Stree')\n2 functools.partial(, 'Stree')\n3 functools.partial(, 'Stree')\n4 functools.partial(, 'Stree')\n5 functools.partial(, 'Stree')\n6 functools.partial(, 'Stree')\n7 functools.partial(, 'Stree')\n8 functools.partial(, 'Stree')\n9 functools.partial(, 'Stree')\n10 functools.partial(, 'Stree', readonly_memmap=True)\n11 functools.partial(, 'Stree')\n12 functools.partial(, 'Stree')\n13 functools.partial(, 'Stree')\n14 functools.partial(, 'Stree')\n15 functools.partial(, 'Stree')\n16 functools.partial(, 'Stree')\n17 functools.partial(, 'Stree')\n18 functools.partial(, 'Stree')\n19 functools.partial(, 'Stree')\n20 functools.partial(, 'Stree')\n21 functools.partial(, 'Stree')\n22 functools.partial(, 'Stree')\n23 functools.partial(, 'Stree')\n24 functools.partial(, 'Stree', readonly_memmap=True)\n25 functools.partial(, 'Stree', readonly_memmap=True, X_dtype='float32')\n26 functools.partial(, 'Stree')\n27 functools.partial(, 'Stree')\n28 functools.partial(, 'Stree')\n29 functools.partial(, 'Stree')\n30 functools.partial(, 'Stree')\n31 functools.partial(, 'Stree')\n32 functools.partial(, 'Stree')\n33 functools.partial(, 'Stree')\n34 functools.partial(, 'Stree')\n35 functools.partial(, 'Stree')\n36 functools.partial(, 'Stree')\n37 functools.partial(, 'Stree')\n38 functools.partial(, 'Stree')\n39 functools.partial(, 'Stree')\n40 functools.partial(, 'Stree')\n41 functools.partial(, 'Stree')\n42 functools.partial(, 'Stree')\n43 functools.partial(, 'Stree')\n" } ], "source": [ @@ -296,7 +302,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -313,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": { "tags": [] }, @@ -321,7 +327,7 @@ { "output_type": "stream", "name": "stdout", - "text": "== Not Weighted ===\nSVC train score ..: 0.9820499479708636\nSTree train score : 0.9830905306971904\nSVC test score ...: 0.9842233009708737\nSTree test score .: 0.9848300970873787\n==== Weighted =====\nSVC train score ..: 0.9768470343392299\nSTree train score : 0.9758064516129032\nSVC test score ...: 0.975121359223301\nSTree test score .: 0.9781553398058253\n*SVC test score ..: 0.9433869483836175\n*STree test score : 0.9542572525345916\n" + "text": "== Not Weighted ===\nSVC train score ..: 0.9823100936524454\nSTree train score : 0.9830905306971904\nSVC test score ...: 0.9842233009708737\nSTree test score .: 0.9860436893203883\n==== Weighted =====\nSVC train score ..: 0.9799687825182102\nSTree train score : 0.9807492195629552\nSVC test score ...: 0.9848300970873787\nSTree test score .: 0.9830097087378641\n*SVC test score ..: 0.9487167285301864\n*STree test score : 0.9538538933228189\n" } ], "source": [ @@ -347,7 +353,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": { "tags": [] }, @@ -355,7 +361,7 @@ { "output_type": "stream", "name": "stdout", - "text": "root feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1659\nroot - Down feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.2701\nroot - Down - Down, - Leaf class=1 belief= 0.841270 impurity=0.2671 counts=(array([0, 1]), array([ 60, 318]))\nroot - Down - Up, - Leaf class=0 belief= 1.000000 impurity=0.0000 counts=(array([0]), array([1]))\nroot - Up, - Leaf class=0 belief= 0.990476 impurity=0.0189 counts=(array([0, 1]), array([3432, 33]))\n\n" + "text": "root feaures=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27) impurity=0.1664\nroot - Down, - Leaf class=1 belief= 0.888268 impurity=0.1985 counts=(array([0, 1]), array([ 40, 318]))\nroot - Up, - Leaf class=0 belief= 0.990247 impurity=0.0193 counts=(array([0, 1]), array([3452, 34]))\n\n" } ], "source": [ @@ -371,7 +377,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": { "tags": [] }, @@ -379,27 +385,7 @@ { "output_type": "stream", "name": "stdout", - "text": "****************************************\nmax_features None = 28\nTrain score : 0.9846514047866806\nTest score .: 0.9860436893203883\nTook 5.03 seconds\n****************************************\nmax_features auto = 5\nTrain score : 0.9802289281997919\nTest score .: 0.9824029126213593\nTook 2.20 seconds\n****************************************\nmax_features log2 = 4\nTrain score : 0.9765868886576483\nTest score .: 0.9769417475728155\nTook 0.91 seconds\n****************************************\nmax_features 7 = 7\nTrain score : 0.9768470343392299\nTest score .: 0.9781553398058253\nTook 4.55 seconds\n****************************************\n" - }, - { - "output_type": "error", - "ename": "KeyboardInterrupt", - "evalue": "", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m~/.virtualenvs/general/lib/python3.7/site-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_code\u001b[0;34m(self, code_obj, result, async_)\u001b[0m\n\u001b[1;32m 3330\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3331\u001b[0;31m \u001b[0mexec\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode_obj\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0muser_global_ns\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0muser_ns\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3332\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mclf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mStree\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrandom_state\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mrandom_state\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmax_features\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmax_features\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mclf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mXtrain\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mytrain\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"max_features {max_features} = {clf.max_features_}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Code/stree/stree/Strees.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, X, y, sample_weight)\u001b[0m\n\u001b[1;32m 470\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax_features_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_initialize_max_features\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 471\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtree_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msample_weight\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"root\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 472\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_build_predictor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Code/stree/stree/Strees.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, X, y, sample_weight, depth, title)\u001b[0m\n\u001b[1;32m 542\u001b[0m )\n\u001b[0;32m--> 543\u001b[0;31m \u001b[0mnode\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_up\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX_U\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my_u\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msw_u\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdepth\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtitle\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\" - Up\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 544\u001b[0m \u001b[0mnode\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_down\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX_D\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my_d\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msw_d\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdepth\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtitle\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\" - Down\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Code/stree/stree/Strees.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, X, y, sample_weight, depth, title)\u001b[0m\n\u001b[1;32m 514\u001b[0m \u001b[0mclf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_build_clf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 515\u001b[0;31m \u001b[0mXs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfeatures\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msplitter_\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_subspace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mX\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax_features_\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 516\u001b[0m \u001b[0;31m# solve WARNING: class label 0 specified in weight is not found\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Code/stree/stree/Strees.py\u001b[0m in \u001b[0;36mget_subspace\u001b[0;34m(self, dataset, labels, max_features)\u001b[0m\n\u001b[1;32m 271\u001b[0m \"\"\"\n\u001b[0;32m--> 272\u001b[0;31m \u001b[0mindices\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_subspaces_set\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmax_features\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 273\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdataset\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindices\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindices\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Code/stree/stree/Strees.py\u001b[0m in \u001b[0;36m_get_subspaces_set\u001b[0;34m(self, dataset, labels, max_features)\u001b[0m\n\u001b[1;32m 253\u001b[0m \u001b[0mfeatures\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 254\u001b[0;31m \u001b[0mfeatures_sets\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcombinations\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfeatures\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmax_features\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 255\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfeatures_sets\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: ", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " - ] + "text": "****************************************\nmax_features None = 28\nTrain score : 0.9841311134235172\nTest score .: 0.9848300970873787\nTook 0.35 seconds\n****************************************\nmax_features auto = 5\nTrain score : 0.981009365244537\nTest score .: 0.9830097087378641\nTook 0.71 seconds\n****************************************\nmax_features log2 = 4\nTrain score : 0.9763267429760666\nTest score .: 0.9775485436893204\nTook 0.32 seconds\n****************************************\nmax_features 7 = 7\nTrain score : 0.9750260145681582\nTest score .: 0.9775485436893204\nTook 2.35 seconds\n****************************************\nmax_features 0.5 = 14\nTrain score : 0.9820499479708636\nTest score .: 0.9824029126213593\nTook 84.80 seconds\n****************************************\nmax_features 0.1 = 2\nTrain score : 0.9513527575442248\nTest score .: 0.9526699029126213\nTook 0.25 seconds\n****************************************\nmax_features 0.7 = 19\nTrain score : 0.9841311134235172\nTest score .: 0.9830097087378641\nTook 14.16 seconds\n" } ], "source": [ @@ -413,63 +399,13 @@ " print(\"Test score .:\", clf.score(Xtest, ytest))\n", " print(f\"Took {time.time() - now:.2f} seconds\")" ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "tags": [ - "outputPrepend" - ] - }, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": "(6, 10, 14), (6, 10, 15), (6, 10, 16), (6, 10, 17), (6, 10, 18), (6, 10, 19), (6, 10, 20), (6, 10, 21), (6, 10, 22), (6, 10, 23), (6, 10, 24), (6, 10, 25), (6, 10, 26), (6, 10, 27), (6, 11, 12), (6, 11, 13), (6, 11, 14), (6, 11, 15), (6, 11, 16), (6, 11, 17), (6, 11, 18), (6, 11, 19), (6, 11, 20), (6, 11, 21), (6, 11, 22), (6, 11, 23), (6, 11, 24), (6, 11, 25), (6, 11, 26), (6, 11, 27), (6, 12, 13), (6, 12, 14), (6, 12, 15), (6, 12, 16), (6, 12, 17), (6, 12, 18), (6, 12, 19), (6, 12, 20), (6, 12, 21), (6, 12, 22), (6, 12, 23), (6, 12, 24), (6, 12, 25), (6, 12, 26), (6, 12, 27), (6, 13, 14), (6, 13, 15), (6, 13, 16), (6, 13, 17), (6, 13, 18), (6, 13, 19), (6, 13, 20), (6, 13, 21), (6, 13, 22), (6, 13, 23), (6, 13, 24), (6, 13, 25), (6, 13, 26), (6, 13, 27), (6, 14, 15), (6, 14, 16), (6, 14, 17), (6, 14, 18), (6, 14, 19), (6, 14, 20), (6, 14, 21), (6, 14, 22), (6, 14, 23), (6, 14, 24), (6, 14, 25), (6, 14, 26), (6, 14, 27), (6, 15, 16), (6, 15, 17), (6, 15, 18), (6, 15, 19), (6, 15, 20), (6, 15, 21), (6, 15, 22), (6, 15, 23), (6, 15, 24), (6, 15, 25), (6, 15, 26), (6, 15, 27), (6, 16, 17), (6, 16, 18), (6, 16, 19), (6, 16, 20), (6, 16, 21), (6, 16, 22), (6, 16, 23), (6, 16, 24), (6, 16, 25), (6, 16, 26), (6, 16, 27), (6, 17, 18), (6, 17, 19), (6, 17, 20), (6, 17, 21), (6, 17, 22), (6, 17, 23), (6, 17, 24), (6, 17, 25), (6, 17, 26), (6, 17, 27), (6, 18, 19), (6, 18, 20), (6, 18, 21), (6, 18, 22), (6, 18, 23), (6, 18, 24), (6, 18, 25), (6, 18, 26), (6, 18, 27), (6, 19, 20), (6, 19, 21), (6, 19, 22), (6, 19, 23), (6, 19, 24), (6, 19, 25), (6, 19, 26), (6, 19, 27), (6, 20, 21), (6, 20, 22), (6, 20, 23), (6, 20, 24), (6, 20, 25), (6, 20, 26), (6, 20, 27), (6, 21, 22), (6, 21, 23), (6, 21, 24), (6, 21, 25), (6, 21, 26), (6, 21, 27), (6, 22, 23), (6, 22, 24), (6, 22, 25), (6, 22, 26), (6, 22, 27), (6, 23, 24), (6, 23, 25), (6, 23, 26), (6, 23, 27), (6, 24, 25), (6, 24, 26), (6, 24, 27), (6, 25, 26), (6, 25, 27), (6, 26, 27), (7, 8, 9), (7, 8, 10), (7, 8, 11), (7, 8, 12), (7, 8, 13), (7, 8, 14), (7, 8, 15), (7, 8, 16), (7, 8, 17), (7, 8, 18), (7, 8, 19), (7, 8, 20), (7, 8, 21), (7, 8, 22), (7, 8, 23), (7, 8, 24), (7, 8, 25), (7, 8, 26), (7, 8, 27), (7, 9, 10), (7, 9, 11), (7, 9, 12), (7, 9, 13), (7, 9, 14), (7, 9, 15), (7, 9, 16), (7, 9, 17), (7, 9, 18), (7, 9, 19), (7, 9, 20), (7, 9, 21), (7, 9, 22), (7, 9, 23), (7, 9, 24), (7, 9, 25), (7, 9, 26), (7, 9, 27), (7, 10, 11), (7, 10, 12), (7, 10, 13), (7, 10, 14), (7, 10, 15), (7, 10, 16), (7, 10, 17), (7, 10, 18), (7, 10, 19), (7, 10, 20), (7, 10, 21), (7, 10, 22), (7, 10, 23), (7, 10, 24), (7, 10, 25), (7, 10, 26), (7, 10, 27), (7, 11, 12), (7, 11, 13), (7, 11, 14), (7, 11, 15), (7, 11, 16), (7, 11, 17), (7, 11, 18), (7, 11, 19), (7, 11, 20), (7, 11, 21), (7, 11, 22), (7, 11, 23), (7, 11, 24), (7, 11, 25), (7, 11, 26), (7, 11, 27), (7, 12, 13), (7, 12, 14), (7, 12, 15), (7, 12, 16), (7, 12, 17), (7, 12, 18), (7, 12, 19), (7, 12, 20), (7, 12, 21), (7, 12, 22), (7, 12, 23), (7, 12, 24), (7, 12, 25), (7, 12, 26), (7, 12, 27), (7, 13, 14), (7, 13, 15), (7, 13, 16), (7, 13, 17), (7, 13, 18), (7, 13, 19), (7, 13, 20), (7, 13, 21), (7, 13, 22), (7, 13, 23), (7, 13, 24), (7, 13, 25), (7, 13, 26), (7, 13, 27), (7, 14, 15), (7, 14, 16), (7, 14, 17), (7, 14, 18), (7, 14, 19), (7, 14, 20), (7, 14, 21), (7, 14, 22), (7, 14, 23), (7, 14, 24), (7, 14, 25), (7, 14, 26), (7, 14, 27), (7, 15, 16), (7, 15, 17), (7, 15, 18), (7, 15, 19), (7, 15, 20), (7, 15, 21), (7, 15, 22), (7, 15, 23), (7, 15, 24), (7, 15, 25), (7, 15, 26), (7, 15, 27), (7, 16, 17), (7, 16, 18), (7, 16, 19), (7, 16, 20), (7, 16, 21), (7, 16, 22), (7, 16, 23), (7, 16, 24), (7, 16, 25), (7, 16, 26), (7, 16, 27), (7, 17, 18), (7, 17, 19), (7, 17, 20), (7, 17, 21), (7, 17, 22), (7, 17, 23), (7, 17, 24), (7, 17, 25), (7, 17, 26), (7, 17, 27), (7, 18, 19), (7, 18, 20), (7, 18, 21), (7, 18, 22), (7, 18, 23), (7, 18, 24), (7, 18, 25), (7, 18, 26), (7, 18, 27), (7, 19, 20), (7, 19, 21), (7, 19, 22), (7, 19, 23), (7, 19, 24), (7, 19, 25), (7, 19, 26), (7, 19, 27), (7, 20, 21), (7, 20, 22), (7, 20, 23), (7, 20, 24), (7, 20, 25), (7, 20, 26), (7, 20, 27), (7, 21, 22), (7, 21, 23), (7, 21, 24), (7, 21, 25), (7, 21, 26), (7, 21, 27), (7, 22, 23), (7, 22, 24), (7, 22, 25), (7, 22, 26), (7, 22, 27), (7, 23, 24), (7, 23, 25), (7, 23, 26), (7, 23, 27), (7, 24, 25), (7, 24, 26), (7, 24, 27), (7, 25, 26), (7, 25, 27), (7, 26, 27), (8, 9, 10), (8, 9, 11), (8, 9, 12), (8, 9, 13), (8, 9, 14), (8, 9, 15), (8, 9, 16), (8, 9, 17), (8, 9, 18), (8, 9, 19), (8, 9, 20), (8, 9, 21), (8, 9, 22), (8, 9, 23), (8, 9, 24), (8, 9, 25), (8, 9, 26), (8, 9, 27), (8, 10, 11), (8, 10, 12), (8, 10, 13), (8, 10, 14), (8, 10, 15), (8, 10, 16), (8, 10, 17), (8, 10, 18), (8, 10, 19), (8, 10, 20), (8, 10, 21), (8, 10, 22), (8, 10, 23), (8, 10, 24), (8, 10, 25), (8, 10, 26), (8, 10, 27), (8, 11, 12), (8, 11, 13), (8, 11, 14), (8, 11, 15), (8, 11, 16), (8, 11, 17), (8, 11, 18), (8, 11, 19), (8, 11, 20), (8, 11, 21), (8, 11, 22), (8, 11, 23), (8, 11, 24), (8, 11, 25), (8, 11, 26), (8, 11, 27), (8, 12, 13), (8, 12, 14), (8, 12, 15), (8, 12, 16), (8, 12, 17), (8, 12, 18), (8, 12, 19), (8, 12, 20), (8, 12, 21), (8, 12, 22), (8, 12, 23), (8, 12, 24), (8, 12, 25), (8, 12, 26), (8, 12, 27), (8, 13, 14), (8, 13, 15), (8, 13, 16), (8, 13, 17), (8, 13, 18), (8, 13, 19), (8, 13, 20), (8, 13, 21), (8, 13, 22), (8, 13, 23), (8, 13, 24), (8, 13, 25), (8, 13, 26), (8, 13, 27), (8, 14, 15), (8, 14, 16), (8, 14, 17), (8, 14, 18), (8, 14, 19), (8, 14, 20), (8, 14, 21), (8, 14, 22), (8, 14, 23), (8, 14, 24), (8, 14, 25), (8, 14, 26), (8, 14, 27), (8, 15, 16), (8, 15, 17), (8, 15, 18), (8, 15, 19), (8, 15, 20), (8, 15, 21), (8, 15, 22), (8, 15, 23), (8, 15, 24), (8, 15, 25), (8, 15, 26), (8, 15, 27), (8, 16, 17), (8, 16, 18), (8, 16, 19), (8, 16, 20), (8, 16, 21), (8, 16, 22), (8, 16, 23), (8, 16, 24), (8, 16, 25), (8, 16, 26), (8, 16, 27), (8, 17, 18), (8, 17, 19), (8, 17, 20), (8, 17, 21), (8, 17, 22), (8, 17, 23), (8, 17, 24), (8, 17, 25), (8, 17, 26), (8, 17, 27), (8, 18, 19), (8, 18, 20), (8, 18, 21), (8, 18, 22), (8, 18, 23), (8, 18, 24), (8, 18, 25), (8, 18, 26), (8, 18, 27), (8, 19, 20), (8, 19, 21), (8, 19, 22), (8, 19, 23), (8, 19, 24), (8, 19, 25), (8, 19, 26), (8, 19, 27), (8, 20, 21), (8, 20, 22), (8, 20, 23), (8, 20, 24), (8, 20, 25), (8, 20, 26), (8, 20, 27), (8, 21, 22), (8, 21, 23), (8, 21, 24), (8, 21, 25), (8, 21, 26), (8, 21, 27), (8, 22, 23), (8, 22, 24), (8, 22, 25), (8, 22, 26), (8, 22, 27), (8, 23, 24), (8, 23, 25), (8, 23, 26), (8, 23, 27), (8, 24, 25), (8, 24, 26), (8, 24, 27), (8, 25, 26), (8, 25, 27), (8, 26, 27), (9, 10, 11), (9, 10, 12), (9, 10, 13), (9, 10, 14), (9, 10, 15), (9, 10, 16), (9, 10, 17), (9, 10, 18), (9, 10, 19), (9, 10, 20), (9, 10, 21), (9, 10, 22), (9, 10, 23), (9, 10, 24), (9, 10, 25), (9, 10, 26), (9, 10, 27), (9, 11, 12), (9, 11, 13), (9, 11, 14), (9, 11, 15), (9, 11, 16), (9, 11, 17), (9, 11, 18), (9, 11, 19), (9, 11, 20), (9, 11, 21), (9, 11, 22), (9, 11, 23), (9, 11, 24), (9, 11, 25), (9, 11, 26), (9, 11, 27), (9, 12, 13), (9, 12, 14), (9, 12, 15), (9, 12, 16), (9, 12, 17), (9, 12, 18), (9, 12, 19), (9, 12, 20), (9, 12, 21), (9, 12, 22), (9, 12, 23), (9, 12, 24), (9, 12, 25), (9, 12, 26), (9, 12, 27), (9, 13, 14), (9, 13, 15), (9, 13, 16), (9, 13, 17), (9, 13, 18), (9, 13, 19), (9, 13, 20), (9, 13, 21), (9, 13, 22), (9, 13, 23), (9, 13, 24), (9, 13, 25), (9, 13, 26), (9, 13, 27), (9, 14, 15), (9, 14, 16), (9, 14, 17), (9, 14, 18), (9, 14, 19), (9, 14, 20), (9, 14, 21), (9, 14, 22), (9, 14, 23), (9, 14, 24), (9, 14, 25), (9, 14, 26), (9, 14, 27), (9, 15, 16), (9, 15, 17), (9, 15, 18), (9, 15, 19), (9, 15, 20), (9, 15, 21), (9, 15, 22), (9, 15, 23), (9, 15, 24), (9, 15, 25), (9, 15, 26), (9, 15, 27), (9, 16, 17), (9, 16, 18), (9, 16, 19), (9, 16, 20), (9, 16, 21), (9, 16, 22), (9, 16, 23), (9, 16, 24), (9, 16, 25), (9, 16, 26), (9, 16, 27), (9, 17, 18), (9, 17, 19), (9, 17, 20), (9, 17, 21), (9, 17, 22), (9, 17, 23), (9, 17, 24), (9, 17, 25), (9, 17, 26), (9, 17, 27), (9, 18, 19), (9, 18, 20), (9, 18, 21), (9, 18, 22), (9, 18, 23), (9, 18, 24), (9, 18, 25), (9, 18, 26), (9, 18, 27), (9, 19, 20), (9, 19, 21), (9, 19, 22), (9, 19, 23), (9, 19, 24), (9, 19, 25), (9, 19, 26), (9, 19, 27), (9, 20, 21), (9, 20, 22), (9, 20, 23), (9, 20, 24), (9, 20, 25), (9, 20, 26), (9, 20, 27), (9, 21, 22), (9, 21, 23), (9, 21, 24), (9, 21, 25), (9, 21, 26), (9, 21, 27), (9, 22, 23), (9, 22, 24), (9, 22, 25), (9, 22, 26), (9, 22, 27), (9, 23, 24), (9, 23, 25), (9, 23, 26), (9, 23, 27), (9, 24, 25), (9, 24, 26), (9, 24, 27), (9, 25, 26), (9, 25, 27), (9, 26, 27), (10, 11, 12), (10, 11, 13), (10, 11, 14), (10, 11, 15), (10, 11, 16), (10, 11, 17), (10, 11, 18), (10, 11, 19), (10, 11, 20), (10, 11, 21), (10, 11, 22), (10, 11, 23), (10, 11, 24), (10, 11, 25), (10, 11, 26), (10, 11, 27), (10, 12, 13), (10, 12, 14), (10, 12, 15), (10, 12, 16), (10, 12, 17), (10, 12, 18), (10, 12, 19), (10, 12, 20), (10, 12, 21), (10, 12, 22), (10, 12, 23), (10, 12, 24), (10, 12, 25), (10, 12, 26), (10, 12, 27), (10, 13, 14), (10, 13, 15), (10, 13, 16), (10, 13, 17), (10, 13, 18), (10, 13, 19), (10, 13, 20), (10, 13, 21), (10, 13, 22), (10, 13, 23), (10, 13, 24), (10, 13, 25), (10, 13, 26), (10, 13, 27), (10, 14, 15), (10, 14, 16), (10, 14, 17), (10, 14, 18), (10, 14, 19), (10, 14, 20), (10, 14, 21), (10, 14, 22), (10, 14, 23), (10, 14, 24), (10, 14, 25), (10, 14, 26), (10, 14, 27), (10, 15, 16), (10, 15, 17), (10, 15, 18), (10, 15, 19), (10, 15, 20), (10, 15, 21), (10, 15, 22), (10, 15, 23), (10, 15, 24), (10, 15, 25), (10, 15, 26), (10, 15, 27), (10, 16, 17), (10, 16, 18), (10, 16, 19), (10, 16, 20), (10, 16, 21), (10, 16, 22), (10, 16, 23), (10, 16, 24), (10, 16, 25), (10, 16, 26), (10, 16, 27), (10, 17, 18), (10, 17, 19), (10, 17, 20), (10, 17, 21), (10, 17, 22), (10, 17, 23), (10, 17, 24), (10, 17, 25), (10, 17, 26), (10, 17, 27), (10, 18, 19), (10, 18, 20), (10, 18, 21), (10, 18, 22), (10, 18, 23), (10, 18, 24), (10, 18, 25), (10, 18, 26), (10, 18, 27), (10, 19, 20), (10, 19, 21), (10, 19, 22), (10, 19, 23), (10, 19, 24), (10, 19, 25), (10, 19, 26), (10, 19, 27), (10, 20, 21), (10, 20, 22), (10, 20, 23), (10, 20, 24), (10, 20, 25), (10, 20, 26), (10, 20, 27), (10, 21, 22), (10, 21, 23), (10, 21, 24), (10, 21, 25), (10, 21, 26), (10, 21, 27), (10, 22, 23), (10, 22, 24), (10, 22, 25), (10, 22, 26), (10, 22, 27), (10, 23, 24), (10, 23, 25), (10, 23, 26), (10, 23, 27), (10, 24, 25), (10, 24, 26), (10, 24, 27), (10, 25, 26), (10, 25, 27), (10, 26, 27), (11, 12, 13), (11, 12, 14), (11, 12, 15), (11, 12, 16), (11, 12, 17), (11, 12, 18), (11, 12, 19), (11, 12, 20), (11, 12, 21), (11, 12, 22), (11, 12, 23), (11, 12, 24), (11, 12, 25), (11, 12, 26), (11, 12, 27), (11, 13, 14), (11, 13, 15), (11, 13, 16), (11, 13, 17), (11, 13, 18), (11, 13, 19), (11, 13, 20), (11, 13, 21), (11, 13, 22), (11, 13, 23), (11, 13, 24), (11, 13, 25), (11, 13, 26), (11, 13, 27), (11, 14, 15), (11, 14, 16), (11, 14, 17), (11, 14, 18), (11, 14, 19), (11, 14, 20), (11, 14, 21), (11, 14, 22), (11, 14, 23), (11, 14, 24), (11, 14, 25), (11, 14, 26), (11, 14, 27), (11, 15, 16), (11, 15, 17), (11, 15, 18), (11, 15, 19), (11, 15, 20), (11, 15, 21), (11, 15, 22), (11, 15, 23), (11, 15, 24), (11, 15, 25), (11, 15, 26), (11, 15, 27), (11, 16, 17), (11, 16, 18), (11, 16, 19), (11, 16, 20), (11, 16, 21), (11, 16, 22), (11, 16, 23), (11, 16, 24), (11, 16, 25), (11, 16, 26), (11, 16, 27), (11, 17, 18), (11, 17, 19), (11, 17, 20), (11, 17, 21), (11, 17, 22), (11, 17, 23), (11, 17, 24), (11, 17, 25), (11, 17, 26), (11, 17, 27), (11, 18, 19), (11, 18, 20), (11, 18, 21), (11, 18, 22), (11, 18, 23), (11, 18, 24), (11, 18, 25), (11, 18, 26), (11, 18, 27), (11, 19, 20), (11, 19, 21), (11, 19, 22), (11, 19, 23), (11, 19, 24), (11, 19, 25), (11, 19, 26), (11, 19, 27), (11, 20, 21), (11, 20, 22), (11, 20, 23), (11, 20, 24), (11, 20, 25), (11, 20, 26), (11, 20, 27), (11, 21, 22), (11, 21, 23), (11, 21, 24), (11, 21, 25), (11, 21, 26), (11, 21, 27), (11, 22, 23), (11, 22, 24), (11, 22, 25), (11, 22, 26), (11, 22, 27), (11, 23, 24), (11, 23, 25), (11, 23, 26), (11, 23, 27), (11, 24, 25), (11, 24, 26), (11, 24, 27), (11, 25, 26), (11, 25, 27), (11, 26, 27), (12, 13, 14), (12, 13, 15), (12, 13, 16), (12, 13, 17), (12, 13, 18), (12, 13, 19), (12, 13, 20), (12, 13, 21), (12, 13, 22), (12, 13, 23), (12, 13, 24), (12, 13, 25), (12, 13, 26), (12, 13, 27), (12, 14, 15), (12, 14, 16), (12, 14, 17), (12, 14, 18), (12, 14, 19), (12, 14, 20), (12, 14, 21), (12, 14, 22), (12, 14, 23), (12, 14, 24), (12, 14, 25), (12, 14, 26), (12, 14, 27), (12, 15, 16), (12, 15, 17), (12, 15, 18), (12, 15, 19), (12, 15, 20), (12, 15, 21), (12, 15, 22), (12, 15, 23), (12, 15, 24), (12, 15, 25), (12, 15, 26), (12, 15, 27), (12, 16, 17), (12, 16, 18), (12, 16, 19), (12, 16, 20), (12, 16, 21), (12, 16, 22), (12, 16, 23), (12, 16, 24), (12, 16, 25), (12, 16, 26), (12, 16, 27), (12, 17, 18), (12, 17, 19), (12, 17, 20), (12, 17, 21), (12, 17, 22), (12, 17, 23), (12, 17, 24), (12, 17, 25), (12, 17, 26), (12, 17, 27), (12, 18, 19), (12, 18, 20), (12, 18, 21), (12, 18, 22), (12, 18, 23), (12, 18, 24), (12, 18, 25), (12, 18, 26), (12, 18, 27), (12, 19, 20), (12, 19, 21), (12, 19, 22), (12, 19, 23), (12, 19, 24), (12, 19, 25), (12, 19, 26), (12, 19, 27), (12, 20, 21), (12, 20, 22), (12, 20, 23), (12, 20, 24), (12, 20, 25), (12, 20, 26), (12, 20, 27), (12, 21, 22), (12, 21, 23), (12, 21, 24), (12, 21, 25), (12, 21, 26), (12, 21, 27), (12, 22, 23), (12, 22, 24), (12, 22, 25), (12, 22, 26), (12, 22, 27), (12, 23, 24), (12, 23, 25), (12, 23, 26), (12, 23, 27), (12, 24, 25), (12, 24, 26), (12, 24, 27), (12, 25, 26), (12, 25, 27), (12, 26, 27), (13, 14, 15), (13, 14, 16), (13, 14, 17), (13, 14, 18), (13, 14, 19), (13, 14, 20), (13, 14, 21), (13, 14, 22), (13, 14, 23), (13, 14, 24), (13, 14, 25), (13, 14, 26), (13, 14, 27), (13, 15, 16), (13, 15, 17), (13, 15, 18), (13, 15, 19), (13, 15, 20), (13, 15, 21), (13, 15, 22), (13, 15, 23), (13, 15, 24), (13, 15, 25), (13, 15, 26), (13, 15, 27), (13, 16, 17), (13, 16, 18), (13, 16, 19), (13, 16, 20), (13, 16, 21), (13, 16, 22), (13, 16, 23), (13, 16, 24), (13, 16, 25), (13, 16, 26), (13, 16, 27), (13, 17, 18), (13, 17, 19), (13, 17, 20), (13, 17, 21), (13, 17, 22), (13, 17, 23), (13, 17, 24), (13, 17, 25), (13, 17, 26), (13, 17, 27), (13, 18, 19), (13, 18, 20), (13, 18, 21), (13, 18, 22), (13, 18, 23), (13, 18, 24), (13, 18, 25), (13, 18, 26), (13, 18, 27), (13, 19, 20), (13, 19, 21), (13, 19, 22), (13, 19, 23), (13, 19, 24), (13, 19, 25), (13, 19, 26), (13, 19, 27), (13, 20, 21), (13, 20, 22), (13, 20, 23), (13, 20, 24), (13, 20, 25), (13, 20, 26), (13, 20, 27), (13, 21, 22), (13, 21, 23), (13, 21, 24), (13, 21, 25), (13, 21, 26), (13, 21, 27), (13, 22, 23), (13, 22, 24), (13, 22, 25), (13, 22, 26), (13, 22, 27), (13, 23, 24), (13, 23, 25), (13, 23, 26), (13, 23, 27), (13, 24, 25), (13, 24, 26), (13, 24, 27), (13, 25, 26), (13, 25, 27), (13, 26, 27), (14, 15, 16), (14, 15, 17), (14, 15, 18), (14, 15, 19), (14, 15, 20), (14, 15, 21), (14, 15, 22), (14, 15, 23), (14, 15, 24), (14, 15, 25), (14, 15, 26), (14, 15, 27), (14, 16, 17), (14, 16, 18), (14, 16, 19), (14, 16, 20), (14, 16, 21), (14, 16, 22), (14, 16, 23), (14, 16, 24), (14, 16, 25), (14, 16, 26), (14, 16, 27), (14, 17, 18), (14, 17, 19), (14, 17, 20), (14, 17, 21), (14, 17, 22), (14, 17, 23), (14, 17, 24), (14, 17, 25), (14, 17, 26), (14, 17, 27), (14, 18, 19), (14, 18, 20), (14, 18, 21), (14, 18, 22), (14, 18, 23), (14, 18, 24), (14, 18, 25), (14, 18, 26), (14, 18, 27), (14, 19, 20), (14, 19, 21), (14, 19, 22), (14, 19, 23), (14, 19, 24), (14, 19, 25), (14, 19, 26), (14, 19, 27), (14, 20, 21), (14, 20, 22), (14, 20, 23), (14, 20, 24), (14, 20, 25), (14, 20, 26), (14, 20, 27), (14, 21, 22), (14, 21, 23), (14, 21, 24), (14, 21, 25), (14, 21, 26), (14, 21, 27), (14, 22, 23), (14, 22, 24), (14, 22, 25), (14, 22, 26), (14, 22, 27), (14, 23, 24), (14, 23, 25), (14, 23, 26), (14, 23, 27), (14, 24, 25), (14, 24, 26), (14, 24, 27), (14, 25, 26), (14, 25, 27), (14, 26, 27), (15, 16, 17), (15, 16, 18), (15, 16, 19), (15, 16, 20), (15, 16, 21), (15, 16, 22), (15, 16, 23), (15, 16, 24), (15, 16, 25), (15, 16, 26), (15, 16, 27), (15, 17, 18), (15, 17, 19), (15, 17, 20), (15, 17, 21), (15, 17, 22), (15, 17, 23), (15, 17, 24), (15, 17, 25), (15, 17, 26), (15, 17, 27), (15, 18, 19), (15, 18, 20), (15, 18, 21), (15, 18, 22), (15, 18, 23), (15, 18, 24), (15, 18, 25), (15, 18, 26), (15, 18, 27), (15, 19, 20), (15, 19, 21), (15, 19, 22), (15, 19, 23), (15, 19, 24), (15, 19, 25), (15, 19, 26), (15, 19, 27), (15, 20, 21), (15, 20, 22), (15, 20, 23), (15, 20, 24), (15, 20, 25), (15, 20, 26), (15, 20, 27), (15, 21, 22), (15, 21, 23), (15, 21, 24), (15, 21, 25), (15, 21, 26), (15, 21, 27), (15, 22, 23), (15, 22, 24), (15, 22, 25), (15, 22, 26), (15, 22, 27), (15, 23, 24), (15, 23, 25), (15, 23, 26), (15, 23, 27), (15, 24, 25), (15, 24, 26), (15, 24, 27), (15, 25, 26), (15, 25, 27), (15, 26, 27), (16, 17, 18), (16, 17, 19), (16, 17, 20), (16, 17, 21), (16, 17, 22), (16, 17, 23), (16, 17, 24), (16, 17, 25), (16, 17, 26), (16, 17, 27), (16, 18, 19), (16, 18, 20), (16, 18, 21), (16, 18, 22), (16, 18, 23), (16, 18, 24), (16, 18, 25), (16, 18, 26), (16, 18, 27), (16, 19, 20), (16, 19, 21), (16, 19, 22), (16, 19, 23), (16, 19, 24), (16, 19, 25), (16, 19, 26), (16, 19, 27), (16, 20, 21), (16, 20, 22), (16, 20, 23), (16, 20, 24), (16, 20, 25), (16, 20, 26), (16, 20, 27), (16, 21, 22), (16, 21, 23), (16, 21, 24), (16, 21, 25), (16, 21, 26), (16, 21, 27), (16, 22, 23), (16, 22, 24), (16, 22, 25), (16, 22, 26), (16, 22, 27), (16, 23, 24), (16, 23, 25), (16, 23, 26), (16, 23, 27), (16, 24, 25), (16, 24, 26), (16, 24, 27), (16, 25, 26), (16, 25, 27), (16, 26, 27), (17, 18, 19), (17, 18, 20), (17, 18, 21), (17, 18, 22), (17, 18, 23), (17, 18, 24), (17, 18, 25), (17, 18, 26), (17, 18, 27), (17, 19, 20), (17, 19, 21), (17, 19, 22), (17, 19, 23), (17, 19, 24), (17, 19, 25), (17, 19, 26), (17, 19, 27), (17, 20, 21), (17, 20, 22), (17, 20, 23), (17, 20, 24), (17, 20, 25), (17, 20, 26), (17, 20, 27), (17, 21, 22), (17, 21, 23), (17, 21, 24), (17, 21, 25), (17, 21, 26), (17, 21, 27), (17, 22, 23), (17, 22, 24), (17, 22, 25), (17, 22, 26), (17, 22, 27), (17, 23, 24), (17, 23, 25), (17, 23, 26), (17, 23, 27), (17, 24, 25), (17, 24, 26), (17, 24, 27), (17, 25, 26), (17, 25, 27), (17, 26, 27), (18, 19, 20), (18, 19, 21), (18, 19, 22), (18, 19, 23), (18, 19, 24), (18, 19, 25), (18, 19, 26), (18, 19, 27), (18, 20, 21), (18, 20, 22), (18, 20, 23), (18, 20, 24), (18, 20, 25), (18, 20, 26), (18, 20, 27), (18, 21, 22), (18, 21, 23), (18, 21, 24), (18, 21, 25), (18, 21, 26), (18, 21, 27), (18, 22, 23), (18, 22, 24), (18, 22, 25), (18, 22, 26), (18, 22, 27), (18, 23, 24), (18, 23, 25), (18, 23, 26), (18, 23, 27), (18, 24, 25), (18, 24, 26), (18, 24, 27), (18, 25, 26), (18, 25, 27), (18, 26, 27), (19, 20, 21), (19, 20, 22), (19, 20, 23), (19, 20, 24), (19, 20, 25), (19, 20, 26), (19, 20, 27), (19, 21, 22), (19, 21, 23), (19, 21, 24), (19, 21, 25), (19, 21, 26), (19, 21, 27), (19, 22, 23), (19, 22, 24), (19, 22, 25), (19, 22, 26), (19, 22, 27), (19, 23, 24), (19, 23, 25), (19, 23, 26), (19, 23, 27), (19, 24, 25), (19, 24, 26), (19, 24, 27), (19, 25, 26), (19, 25, 27), (19, 26, 27), (20, 21, 22), (20, 21, 23), (20, 21, 24), (20, 21, 25), (20, 21, 26), (20, 21, 27), (20, 22, 23), (20, 22, 24), (20, 22, 25), (20, 22, 26), (20, 22, 27), (20, 23, 24), (20, 23, 25), (20, 23, 26), (20, 23, 27), (20, 24, 25), (20, 24, 26), (20, 24, 27), (20, 25, 26), (20, 25, 27), (20, 26, 27), (21, 22, 23), (21, 22, 24), (21, 22, 25), (21, 22, 26), (21, 22, 27), (21, 23, 24), (21, 23, 25), (21, 23, 26), (21, 23, 27), (21, 24, 25), (21, 24, 26), (21, 24, 27), (21, 25, 26), (21, 25, 27), (21, 26, 27), (22, 23, 24), (22, 23, 25), (22, 23, 26), (22, 23, 27), (22, 24, 25), (22, 24, 26), (22, 24, 27), (22, 25, 26), (22, 25, 27), (22, 26, 27), (23, 24, 25), (23, 24, 26), (23, 24, 27), (23, 25, 26), (23, 25, 27), (23, 26, 27), (24, 25, 26), (24, 25, 27), (24, 26, 27), (25, 26, 27)]\n" - } - ], - "source": [ - "from itertools import combinations\n", - "max_features=3\n", - "features = range(Xtrain.shape[1])\n", - "features_sets = list(combinations(features, max_features))\n", - "print(features_sets)" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "tags": [] - }, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": "[(3, 7, 10), (1, 7, 24), (7, 12, 26)]\n" - } - ], - "source": [ - "import random\n", - "if len(features_sets) > 3:\n", - " features_sets = random.sample(features_sets, 3)\n", - "print(features_sets)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.6 64-bit ('general': venv)", "language": "python", - "name": "python37664bitgeneralvenve3128601eb614c5da59c5055670b6040" + "name": "python37664bitgeneralvenvfbd0a23e74cf4e778460f5ffc6761f39" }, "language_info": { "codemirror_mode": { diff --git a/notebooks/gridsearch.ipynb b/notebooks/gridsearch.ipynb index 46a180a..fe7402a 100644 --- a/notebooks/gridsearch.ipynb +++ b/notebooks/gridsearch.ipynb @@ -66,7 +66,8 @@ "id": "z9Q-YUfBDZEq", "colab_type": "code", "colab": {}, - "outputId": "afc822fb-f16a-4302-8a67-2b9e2880159b" + "outputId": "afc822fb-f16a-4302-8a67-2b9e2880159b", + "tags": [] }, "source": [ "random_state=1\n", @@ -112,7 +113,7 @@ { "output_type": "stream", "name": "stdout", - "text": "Fraud: 0.173% 492\nValid: 99.827% 284315\nX.shape (1492, 28) y.shape (1492,)\nFraud: 33.244% 496\nValid: 66.756% 996\n" + "text": "Fraud: 0.173% 492\nValid: 99.827% 284315\nX.shape (1492, 28) y.shape (1492,)\nFraud: 32.976% 492\nValid: 67.024% 1000\n" } ] }, @@ -137,25 +138,25 @@ " 'learning_rate': [.5, 1],\n", " 'base_estimator__tol': [.1, 1e-02],\n", " 'base_estimator__max_depth': [3, 5],\n", - " 'base_estimator__C': [1, 3],\n", + " 'base_estimator__C': [7, 55],\n", " 'base_estimator__kernel': ['linear', 'poly', 'rbf']\n", "}" ], - "execution_count": 9, + "execution_count": 5, "outputs": [] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { - "text/plain": "{'C': 1.0,\n 'degree': 3,\n 'gamma': 'scale',\n 'kernel': 'linear',\n 'max_depth': None,\n 'max_iter': 1000,\n 'min_samples_split': 0,\n 'random_state': None,\n 'tol': 0.0001}" + "text/plain": "{'C': 1.0,\n 'criterion': 'gini',\n 'degree': 3,\n 'gamma': 'scale',\n 'kernel': 'linear',\n 'max_depth': None,\n 'max_features': None,\n 'max_iter': 1000,\n 'min_samples_split': 0,\n 'random_state': None,\n 'split_criteria': 'max_samples',\n 'splitter': 'random',\n 'tol': 0.0001}" }, "metadata": {}, - "execution_count": 14 + "execution_count": 6 } ], "source": [ @@ -168,28 +169,29 @@ "id": "CrcB8o6EDZE5", "colab_type": "code", "colab": {}, - "outputId": "7703413a-d563-4289-a13b-532f38f82762" + "outputId": "7703413a-d563-4289-a13b-532f38f82762", + "tags": [] }, "source": [ "random_state=2020\n", - "clf = AdaBoostClassifier(random_state=random_state)\n", + "clf = AdaBoostClassifier(random_state=random_state, algorithm=\"SAMME\")\n", "grid = GridSearchCV(clf, parameters, verbose=10, n_jobs=-1, return_train_score=True)\n", "grid.fit(Xtrain, ytrain)" ], - "execution_count": 11, + "execution_count": 7, "outputs": [ { "output_type": "stream", "name": "stdout", - "text": "Fitting 5 folds for each of 96 candidates, totalling 480 fits\n[Parallel(n_jobs=-1)]: Using backend LokyBackend with 8 concurrent workers.\n[Parallel(n_jobs=-1)]: Done 2 tasks | elapsed: 3.6s\n[Parallel(n_jobs=-1)]: Done 9 tasks | elapsed: 4.2s\n[Parallel(n_jobs=-1)]: Done 16 tasks | elapsed: 4.8s\n[Parallel(n_jobs=-1)]: Done 25 tasks | elapsed: 5.3s\n[Parallel(n_jobs=-1)]: Done 34 tasks | elapsed: 6.2s\n[Parallel(n_jobs=-1)]: Done 45 tasks | elapsed: 7.2s\n[Parallel(n_jobs=-1)]: Done 56 tasks | elapsed: 8.9s\n[Parallel(n_jobs=-1)]: Done 69 tasks | elapsed: 10.7s\n[Parallel(n_jobs=-1)]: Done 82 tasks | elapsed: 12.7s\n[Parallel(n_jobs=-1)]: Done 97 tasks | elapsed: 16.7s\n[Parallel(n_jobs=-1)]: Done 112 tasks | elapsed: 19.4s\n[Parallel(n_jobs=-1)]: Done 129 tasks | elapsed: 24.4s\n[Parallel(n_jobs=-1)]: Done 146 tasks | elapsed: 29.3s\n[Parallel(n_jobs=-1)]: Done 165 tasks | elapsed: 32.7s\n[Parallel(n_jobs=-1)]: Done 184 tasks | elapsed: 36.4s\n[Parallel(n_jobs=-1)]: Done 205 tasks | elapsed: 39.7s\n[Parallel(n_jobs=-1)]: Done 226 tasks | elapsed: 43.7s\n[Parallel(n_jobs=-1)]: Done 249 tasks | elapsed: 46.6s\n[Parallel(n_jobs=-1)]: Done 272 tasks | elapsed: 48.8s\n[Parallel(n_jobs=-1)]: Done 297 tasks | elapsed: 52.0s\n[Parallel(n_jobs=-1)]: Done 322 tasks | elapsed: 55.9s\n[Parallel(n_jobs=-1)]: Done 349 tasks | elapsed: 1.0min\n[Parallel(n_jobs=-1)]: Done 376 tasks | elapsed: 1.2min\n[Parallel(n_jobs=-1)]: Done 405 tasks | elapsed: 1.3min\n[Parallel(n_jobs=-1)]: Done 434 tasks | elapsed: 1.3min\n[Parallel(n_jobs=-1)]: Done 465 tasks | elapsed: 1.4min\n[Parallel(n_jobs=-1)]: Done 480 out of 480 | elapsed: 1.5min finished\n" + "text": "Fitting 5 folds for each of 96 candidates, totalling 480 fits\n[Parallel(n_jobs=-1)]: Using backend LokyBackend with 8 concurrent workers.\n[Parallel(n_jobs=-1)]: Done 2 tasks | elapsed: 2.0s\n[Parallel(n_jobs=-1)]: Done 9 tasks | elapsed: 2.4s\n[Parallel(n_jobs=-1)]: Done 16 tasks | elapsed: 2.7s\n[Parallel(n_jobs=-1)]: Done 25 tasks | elapsed: 3.3s\n[Parallel(n_jobs=-1)]: Done 34 tasks | elapsed: 4.3s\n[Parallel(n_jobs=-1)]: Done 45 tasks | elapsed: 5.3s\n[Parallel(n_jobs=-1)]: Done 56 tasks | elapsed: 6.6s\n[Parallel(n_jobs=-1)]: Done 69 tasks | elapsed: 8.1s\n[Parallel(n_jobs=-1)]: Done 82 tasks | elapsed: 9.4s\n[Parallel(n_jobs=-1)]: Done 97 tasks | elapsed: 10.1s\n[Parallel(n_jobs=-1)]: Done 112 tasks | elapsed: 11.1s\n[Parallel(n_jobs=-1)]: Done 129 tasks | elapsed: 12.3s\n[Parallel(n_jobs=-1)]: Done 146 tasks | elapsed: 13.6s\n[Parallel(n_jobs=-1)]: Done 165 tasks | elapsed: 14.9s\n[Parallel(n_jobs=-1)]: Done 184 tasks | elapsed: 16.2s\n[Parallel(n_jobs=-1)]: Done 205 tasks | elapsed: 17.6s\n[Parallel(n_jobs=-1)]: Done 226 tasks | elapsed: 19.1s\n[Parallel(n_jobs=-1)]: Done 249 tasks | elapsed: 21.6s\n[Parallel(n_jobs=-1)]: Done 272 tasks | elapsed: 25.9s\n[Parallel(n_jobs=-1)]: Done 297 tasks | elapsed: 30.4s\n[Parallel(n_jobs=-1)]: Done 322 tasks | elapsed: 36.7s\n[Parallel(n_jobs=-1)]: Done 349 tasks | elapsed: 38.1s\n[Parallel(n_jobs=-1)]: Done 376 tasks | elapsed: 39.6s\n[Parallel(n_jobs=-1)]: Done 405 tasks | elapsed: 41.9s\n[Parallel(n_jobs=-1)]: Done 434 tasks | elapsed: 44.9s\n[Parallel(n_jobs=-1)]: Done 465 tasks | elapsed: 48.2s\n[Parallel(n_jobs=-1)]: Done 480 out of 480 | elapsed: 49.2s finished\n" }, { "output_type": "execute_result", "data": { - "text/plain": "GridSearchCV(estimator=AdaBoostClassifier(random_state=2020), n_jobs=-1,\n param_grid={'base_estimator': [Stree(C=1, max_depth=3, tol=0.1)],\n 'base_estimator__C': [1, 3],\n 'base_estimator__kernel': ['linear', 'poly', 'rbf'],\n 'base_estimator__max_depth': [3, 5],\n 'base_estimator__tol': [0.1, 0.01],\n 'learning_rate': [0.5, 1], 'n_estimators': [10, 25]},\n return_train_score=True, verbose=10)" + "text/plain": "GridSearchCV(estimator=AdaBoostClassifier(algorithm='SAMME', random_state=2020),\n n_jobs=-1,\n param_grid={'base_estimator': [Stree(C=55, max_depth=3, tol=0.01)],\n 'base_estimator__C': [7, 55],\n 'base_estimator__kernel': ['linear', 'poly', 'rbf'],\n 'base_estimator__max_depth': [3, 5],\n 'base_estimator__tol': [0.1, 0.01],\n 'learning_rate': [0.5, 1], 'n_estimators': [10, 25]},\n return_train_score=True, verbose=10)" }, "metadata": {}, - "execution_count": 11 + "execution_count": 7 } ] }, @@ -199,19 +201,20 @@ "id": "ZjX88NoYDZE8", "colab_type": "code", "colab": {}, - "outputId": "285163c8-fa33-4915-8ae7-61c4f7844344" + "outputId": "285163c8-fa33-4915-8ae7-61c4f7844344", + "tags": [] }, "source": [ "print(\"Best estimator: \", grid.best_estimator_)\n", "print(\"Best hyperparameters: \", grid.best_params_)\n", "print(\"Best accuracy: \", grid.best_score_)" ], - "execution_count": 16, + "execution_count": 8, "outputs": [ { "output_type": "stream", "name": "stdout", - "text": "Best estimator: AdaBoostClassifier(base_estimator=Stree(C=1, max_depth=3, tol=0.1),\n learning_rate=0.5, n_estimators=10, random_state=2020)\nBest hyperparameters: {'base_estimator': Stree(C=1, max_depth=3, tol=0.1), 'base_estimator__C': 1, 'base_estimator__kernel': 'linear', 'base_estimator__max_depth': 3, 'base_estimator__tol': 0.1, 'learning_rate': 0.5, 'n_estimators': 10}\nBest accuracy: 0.9492316893632683\n" + "text": "Best estimator: AdaBoostClassifier(algorithm='SAMME',\n base_estimator=Stree(C=55, max_depth=3, tol=0.01),\n learning_rate=0.5, n_estimators=25, random_state=2020)\nBest hyperparameters: {'base_estimator': Stree(C=55, max_depth=3, tol=0.01), 'base_estimator__C': 55, 'base_estimator__kernel': 'linear', 'base_estimator__max_depth': 3, 'base_estimator__tol': 0.01, 'learning_rate': 0.5, 'n_estimators': 25}\nBest accuracy: 0.9559440559440558\n" } ] } diff --git a/setup.py b/setup.py index b31557f..a75e418 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ import setuptools -__version__ = "0.9rc4" +__version__ = "0.9rc5" __author__ = "Ricardo Montañana Gómez"