You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2077 lines
522 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"<a href='https://www.udemy.com/user/joseportilla/'><img src='../Pierian_Data_Logo.png'/></a>\n",
"___\n",
"<center><em>Copyright by Pierian Data Inc.</em></center>\n",
"<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Random Forest - Classification"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## The Data\n",
"\n",
"We will be using the same dataset through our discussions on classification with tree-methods (Decision Tree,Random Forests, and Gradient Boosted Trees) in order to compare performance metrics across these related models.\n",
"\n",
"We will work with the \"Palmer Penguins\" dataset, as it is simple enough to help us fully understand how changing hyperparameters can change classification results.\n",
"\n",
"\n",
"<img src=\"penguin.jpg\" style=\"max-width:400px\">\n",
"\n",
"Data were collected and made available by Dr. Kristen Gorman and the Palmer Station, Antarctica LTER, a member of the Long Term Ecological Research Network.\n",
"\n",
"Gorman KB, Williams TD, Fraser WR (2014) Ecological Sexual Dimorphism and Environmental Variability within a Community of Antarctic Penguins (Genus Pygoscelis). PLoS ONE 9(3): e90081. doi:10.1371/journal.pone.0090081\n",
"\n",
"Summary:\n",
"The data folder contains two CSV files. For intro courses/examples, you probably want to use the first one (penguins_size.csv).\n",
"\n",
"* penguins_size.csv: Simplified data from original penguin data sets. Contains variables:\n",
"\n",
" * species: penguin species (Chinstrap, Adélie, or Gentoo)\n",
" * culmen_length_mm: culmen length (mm)\n",
" * culmen_depth_mm: culmen depth (mm)\n",
" * flipper_length_mm: flipper length (mm)\n",
" * body_mass_g: body mass (g)\n",
" * island: island name (Dream, Torgersen, or Biscoe) in the Palmer Archipelago (Antarctica)\n",
" * sex: penguin sex\n",
"\n",
"* (Not used) penguins_lter.csv: Original combined data for 3 penguin species \n",
"\n",
"Note: The culmen is \"the upper ridge of a bird's beak\" \n",
"\n",
"**Our goal is to create a model that can help predict a species of a penguin based on physical attributes, then we can use that model to help researchers classify penguins in the field, instead of needing an experienced biologist**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 78,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"../DATA/penguins_size.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 79,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>species</th>\n",
" <th>island</th>\n",
" <th>culmen_length_mm</th>\n",
" <th>culmen_depth_mm</th>\n",
" <th>flipper_length_mm</th>\n",
" <th>body_mass_g</th>\n",
" <th>sex</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Adelie</td>\n",
" <td>Torgersen</td>\n",
" <td>39.1</td>\n",
" <td>18.7</td>\n",
" <td>181.0</td>\n",
" <td>3750.0</td>\n",
" <td>MALE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Adelie</td>\n",
" <td>Torgersen</td>\n",
" <td>39.5</td>\n",
" <td>17.4</td>\n",
" <td>186.0</td>\n",
" <td>3800.0</td>\n",
" <td>FEMALE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Adelie</td>\n",
" <td>Torgersen</td>\n",
" <td>40.3</td>\n",
" <td>18.0</td>\n",
" <td>195.0</td>\n",
" <td>3250.0</td>\n",
" <td>FEMALE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Adelie</td>\n",
" <td>Torgersen</td>\n",
" <td>36.7</td>\n",
" <td>19.3</td>\n",
" <td>193.0</td>\n",
" <td>3450.0</td>\n",
" <td>FEMALE</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Adelie</td>\n",
" <td>Torgersen</td>\n",
" <td>39.3</td>\n",
" <td>20.6</td>\n",
" <td>190.0</td>\n",
" <td>3650.0</td>\n",
" <td>MALE</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" species island culmen_length_mm culmen_depth_mm flipper_length_mm \\\n",
"0 Adelie Torgersen 39.1 18.7 181.0 \n",
"1 Adelie Torgersen 39.5 17.4 186.0 \n",
"2 Adelie Torgersen 40.3 18.0 195.0 \n",
"4 Adelie Torgersen 36.7 19.3 193.0 \n",
"5 Adelie Torgersen 39.3 20.6 190.0 \n",
"\n",
" body_mass_g sex \n",
"0 3750.0 MALE \n",
"1 3800.0 FEMALE \n",
"2 3250.0 FEMALE \n",
"4 3450.0 FEMALE \n",
"5 3650.0 MALE "
]
},
"execution_count": 79,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df.dropna()\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Train | Test Split"
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {},
"outputs": [],
"source": [
"X = pd.get_dummies(df.drop('species',axis=1),drop_first=True)\n",
"y = df['species']"
]
},
{
"cell_type": "code",
"execution_count": 88,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "code",
"execution_count": 89,
"metadata": {},
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=101)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Random Forest Classification"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.ensemble import RandomForestClassifier"
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on class RandomForestClassifier in module sklearn.ensemble._forest:\n",
"\n",
"class RandomForestClassifier(ForestClassifier)\n",
" | RandomForestClassifier(n_estimators=100, *, criterion='gini', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None, ccp_alpha=0.0, max_samples=None)\n",
" | \n",
" | A random forest classifier.\n",
" | \n",
" | A random forest is a meta estimator that fits a number of decision tree\n",
" | classifiers on various sub-samples of the dataset and uses averaging to\n",
" | improve the predictive accuracy and control over-fitting.\n",
" | The sub-sample size is controlled with the `max_samples` parameter if\n",
" | `bootstrap=True` (default), otherwise the whole dataset is used to build\n",
" | each tree.\n",
" | \n",
" | Read more in the :ref:`User Guide <forest>`.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | n_estimators : int, default=100\n",
" | The number of trees in the forest.\n",
" | \n",
" | .. versionchanged:: 0.22\n",
" | The default value of ``n_estimators`` changed from 10 to 100\n",
" | in 0.22.\n",
" | \n",
" | criterion : {\"gini\", \"entropy\"}, default=\"gini\"\n",
" | The function to measure the quality of a split. Supported criteria are\n",
" | \"gini\" for the Gini impurity and \"entropy\" for the information gain.\n",
" | Note: this parameter is tree-specific.\n",
" | \n",
" | max_depth : int, default=None\n",
" | The maximum depth of the tree. If None, then nodes are expanded until\n",
" | all leaves are pure or until all leaves contain less than\n",
" | min_samples_split samples.\n",
" | \n",
" | min_samples_split : int or float, default=2\n",
" | The minimum number of samples required to split an internal node:\n",
" | \n",
" | - If int, then consider `min_samples_split` as the minimum number.\n",
" | - If float, then `min_samples_split` is a fraction and\n",
" | `ceil(min_samples_split * n_samples)` are the minimum\n",
" | number of samples for each split.\n",
" | \n",
" | .. versionchanged:: 0.18\n",
" | Added float values for fractions.\n",
" | \n",
" | min_samples_leaf : int or float, default=1\n",
" | The minimum number of samples required to be at a leaf node.\n",
" | A split point at any depth will only be considered if it leaves at\n",
" | least ``min_samples_leaf`` training samples in each of the left and\n",
" | right branches. This may have the effect of smoothing the model,\n",
" | especially in regression.\n",
" | \n",
" | - If int, then consider `min_samples_leaf` as the minimum number.\n",
" | - If float, then `min_samples_leaf` is a fraction and\n",
" | `ceil(min_samples_leaf * n_samples)` are the minimum\n",
" | number of samples for each node.\n",
" | \n",
" | .. versionchanged:: 0.18\n",
" | Added float values for fractions.\n",
" | \n",
" | min_weight_fraction_leaf : float, default=0.0\n",
" | The minimum weighted fraction of the sum total of weights (of all\n",
" | the input samples) required to be at a leaf node. Samples have\n",
" | equal weight when sample_weight is not provided.\n",
" | \n",
" | max_features : {\"auto\", \"sqrt\", \"log2\"}, int or float, default=\"auto\"\n",
" | The number of features to consider when looking for the best split:\n",
" | \n",
" | - If int, then consider `max_features` features at each split.\n",
" | - If float, then `max_features` is a fraction and\n",
" | `int(max_features * n_features)` features are considered at each\n",
" | split.\n",
" | - If \"auto\", then `max_features=sqrt(n_features)`.\n",
" | - If \"sqrt\", then `max_features=sqrt(n_features)` (same as \"auto\").\n",
" | - If \"log2\", then `max_features=log2(n_features)`.\n",
" | - If None, then `max_features=n_features`.\n",
" | \n",
" | Note: the search for a split does not stop until at least one\n",
" | valid partition of the node samples is found, even if it requires to\n",
" | effectively inspect more than ``max_features`` features.\n",
" | \n",
" | max_leaf_nodes : int, default=None\n",
" | Grow trees with ``max_leaf_nodes`` in best-first fashion.\n",
" | Best nodes are defined as relative reduction in impurity.\n",
" | If None then unlimited number of leaf nodes.\n",
" | \n",
" | min_impurity_decrease : float, default=0.0\n",
" | A node will be split if this split induces a decrease of the impurity\n",
" | greater than or equal to this value.\n",
" | \n",
" | The weighted impurity decrease equation is the following::\n",
" | \n",
" | N_t / N * (impurity - N_t_R / N_t * right_impurity\n",
" | - N_t_L / N_t * left_impurity)\n",
" | \n",
" | where ``N`` is the total number of samples, ``N_t`` is the number of\n",
" | samples at the current node, ``N_t_L`` is the number of samples in the\n",
" | left child, and ``N_t_R`` is the number of samples in the right child.\n",
" | \n",
" | ``N``, ``N_t``, ``N_t_R`` and ``N_t_L`` all refer to the weighted sum,\n",
" | if ``sample_weight`` is passed.\n",
" | \n",
" | .. versionadded:: 0.19\n",
" | \n",
" | min_impurity_split : float, default=None\n",
" | Threshold for early stopping in tree growth. A node will split\n",
" | if its impurity is above the threshold, otherwise it is a leaf.\n",
" | \n",
" | .. deprecated:: 0.19\n",
" | ``min_impurity_split`` has been deprecated in favor of\n",
" | ``min_impurity_decrease`` in 0.19. The default value of\n",
" | ``min_impurity_split`` has changed from 1e-7 to 0 in 0.23 and it\n",
" | will be removed in 0.25. Use ``min_impurity_decrease`` instead.\n",
" | \n",
" | \n",
" | bootstrap : bool, default=True\n",
" | Whether bootstrap samples are used when building trees. If False, the\n",
" | whole dataset is used to build each tree.\n",
" | \n",
" | oob_score : bool, default=False\n",
" | Whether to use out-of-bag samples to estimate\n",
" | the generalization accuracy.\n",
" | \n",
" | n_jobs : int, default=None\n",
" | The number of jobs to run in parallel. :meth:`fit`, :meth:`predict`,\n",
" | :meth:`decision_path` and :meth:`apply` are all parallelized over the\n",
" | trees. ``None`` means 1 unless in a :obj:`joblib.parallel_backend`\n",
" | context. ``-1`` means using all processors. See :term:`Glossary\n",
" | <n_jobs>` for more details.\n",
" | \n",
" | random_state : int or RandomState, default=None\n",
" | Controls both the randomness of the bootstrapping of the samples used\n",
" | when building trees (if ``bootstrap=True``) and the sampling of the\n",
" | features to consider when looking for the best split at each node\n",
" | (if ``max_features < n_features``).\n",
" | See :term:`Glossary <random_state>` for details.\n",
" | \n",
" | verbose : int, default=0\n",
" | Controls the verbosity when fitting and predicting.\n",
" | \n",
" | warm_start : bool, default=False\n",
" | When set to ``True``, reuse the solution of the previous call to fit\n",
" | and add more estimators to the ensemble, otherwise, just fit a whole\n",
" | new forest. See :term:`the Glossary <warm_start>`.\n",
" | \n",
" | class_weight : {\"balanced\", \"balanced_subsample\"}, dict or list of dicts, default=None\n",
" | Weights associated with classes in the form ``{class_label: weight}``.\n",
" | If not given, all classes are supposed to have weight one. For\n",
" | multi-output problems, a list of dicts can be provided in the same\n",
" | order as the columns of y.\n",
" | \n",
" | Note that for multioutput (including multilabel) weights should be\n",
" | defined for each class of every column in its own dict. For example,\n",
" | for four-class multilabel classification weights should be\n",
" | [{0: 1, 1: 1}, {0: 1, 1: 5}, {0: 1, 1: 1}, {0: 1, 1: 1}] instead of\n",
" | [{1:1}, {2:5}, {3:1}, {4:1}].\n",
" | \n",
" | The \"balanced\" mode uses the values of y to automatically adjust\n",
" | weights inversely proportional to class frequencies in the input data\n",
" | as ``n_samples / (n_classes * np.bincount(y))``\n",
" | \n",
" | The \"balanced_subsample\" mode is the same as \"balanced\" except that\n",
" | weights are computed based on the bootstrap sample for every tree\n",
" | grown.\n",
" | \n",
" | For multi-output, the weights of each column of y will be multiplied.\n",
" | \n",
" | Note that these weights will be multiplied with sample_weight (passed\n",
" | through the fit method) if sample_weight is specified.\n",
" | \n",
" | ccp_alpha : non-negative float, default=0.0\n",
" | Complexity parameter used for Minimal Cost-Complexity Pruning. The\n",
" | subtree with the largest cost complexity that is smaller than\n",
" | ``ccp_alpha`` will be chosen. By default, no pruning is performed. See\n",
" | :ref:`minimal_cost_complexity_pruning` for details.\n",
" | \n",
" | .. versionadded:: 0.22\n",
" | \n",
" | max_samples : int or float, default=None\n",
" | If bootstrap is True, the number of samples to draw from X\n",
" | to train each base estimator.\n",
" | \n",
" | - If None (default), then draw `X.shape[0]` samples.\n",
" | - If int, then draw `max_samples` samples.\n",
" | - If float, then draw `max_samples * X.shape[0]` samples. Thus,\n",
" | `max_samples` should be in the interval `(0, 1)`.\n",
" | \n",
" | .. versionadded:: 0.22\n",
" | \n",
" | Attributes\n",
" | ----------\n",
" | base_estimator_ : DecisionTreeClassifier\n",
" | The child estimator template used to create the collection of fitted\n",
" | sub-estimators.\n",
" | \n",
" | estimators_ : list of DecisionTreeClassifier\n",
" | The collection of fitted sub-estimators.\n",
" | \n",
" | classes_ : ndarray of shape (n_classes,) or a list of such arrays\n",
" | The classes labels (single output problem), or a list of arrays of\n",
" | class labels (multi-output problem).\n",
" | \n",
" | n_classes_ : int or list\n",
" | The number of classes (single output problem), or a list containing the\n",
" | number of classes for each output (multi-output problem).\n",
" | \n",
" | n_features_ : int\n",
" | The number of features when ``fit`` is performed.\n",
" | \n",
" | n_outputs_ : int\n",
" | The number of outputs when ``fit`` is performed.\n",
" | \n",
" | feature_importances_ : ndarray of shape (n_features,)\n",
" | The impurity-based feature importances.\n",
" | The higher, the more important the feature.\n",
" | The importance of a feature is computed as the (normalized)\n",
" | total reduction of the criterion brought by that feature. It is also\n",
" | known as the Gini importance.\n",
" | \n",
" | Warning: impurity-based feature importances can be misleading for\n",
" | high cardinality features (many unique values). See\n",
" | :func:`sklearn.inspection.permutation_importance` as an alternative.\n",
" | \n",
" | oob_score_ : float\n",
" | Score of the training dataset obtained using an out-of-bag estimate.\n",
" | This attribute exists only when ``oob_score`` is True.\n",
" | \n",
" | oob_decision_function_ : ndarray of shape (n_samples, n_classes)\n",
" | Decision function computed with out-of-bag estimate on the training\n",
" | set. If n_estimators is small it might be possible that a data point\n",
" | was never left out during the bootstrap. In this case,\n",
" | `oob_decision_function_` might contain NaN. This attribute exists\n",
" | only when ``oob_score`` is True.\n",
" | \n",
" | See Also\n",
" | --------\n",
" | DecisionTreeClassifier, ExtraTreesClassifier\n",
" | \n",
" | Notes\n",
" | -----\n",
" | The default values for the parameters controlling the size of the trees\n",
" | (e.g. ``max_depth``, ``min_samples_leaf``, etc.) lead to fully grown and\n",
" | unpruned trees which can potentially be very large on some data sets. To\n",
" | reduce memory consumption, the complexity and size of the trees should be\n",
" | controlled by setting those parameter values.\n",
" | \n",
" | The features are always randomly permuted at each split. Therefore,\n",
" | the best found split may vary, even with the same training data,\n",
" | ``max_features=n_features`` and ``bootstrap=False``, if the improvement\n",
" | of the criterion is identical for several splits enumerated during the\n",
" | search of the best split. To obtain a deterministic behaviour during\n",
" | fitting, ``random_state`` has to be fixed.\n",
" | \n",
" | References\n",
" | ----------\n",
" | .. [1] L. Breiman, \"Random Forests\", Machine Learning, 45(1), 5-32, 2001.\n",
" | \n",
" | Examples\n",
" | --------\n",
" | >>> from sklearn.ensemble import RandomForestClassifier\n",
" | >>> from sklearn.datasets import make_classification\n",
" | >>> X, y = make_classification(n_samples=1000, n_features=4,\n",
" | ... n_informative=2, n_redundant=0,\n",
" | ... random_state=0, shuffle=False)\n",
" | >>> clf = RandomForestClassifier(max_depth=2, random_state=0)\n",
" | >>> clf.fit(X, y)\n",
" | RandomForestClassifier(...)\n",
" | >>> print(clf.predict([[0, 0, 0, 0]]))\n",
" | [1]\n",
" | \n",
" | Method resolution order:\n",
" | RandomForestClassifier\n",
" | ForestClassifier\n",
" | sklearn.base.ClassifierMixin\n",
" | BaseForest\n",
" | sklearn.base.MultiOutputMixin\n",
" | sklearn.ensemble._base.BaseEnsemble\n",
" | sklearn.base.MetaEstimatorMixin\n",
" | sklearn.base.BaseEstimator\n",
" | builtins.object\n",
" | \n",
" | Methods defined here:\n",
" | \n",
" | __init__(self, n_estimators=100, *, criterion='gini', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, class_weight=None, ccp_alpha=0.0, max_samples=None)\n",
" | Initialize self. See help(type(self)) for accurate signature.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data and other attributes defined here:\n",
" | \n",
" | __abstractmethods__ = frozenset()\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from ForestClassifier:\n",
" | \n",
" | predict(self, X)\n",
" | Predict class for X.\n",
" | \n",
" | The predicted class of an input sample is a vote by the trees in\n",
" | the forest, weighted by their probability estimates. That is,\n",
" | the predicted class is the one with highest mean probability\n",
" | estimate across the trees.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n",
" | The input samples. Internally, its dtype will be converted to\n",
" | ``dtype=np.float32``. If a sparse matrix is provided, it will be\n",
" | converted into a sparse ``csr_matrix``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | y : ndarray of shape (n_samples,) or (n_samples, n_outputs)\n",
" | The predicted classes.\n",
" | \n",
" | predict_log_proba(self, X)\n",
" | Predict class log-probabilities for X.\n",
" | \n",
" | The predicted class log-probabilities of an input sample is computed as\n",
" | the log of the mean predicted class probabilities of the trees in the\n",
" | forest.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n",
" | The input samples. Internally, its dtype will be converted to\n",
" | ``dtype=np.float32``. If a sparse matrix is provided, it will be\n",
" | converted into a sparse ``csr_matrix``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | p : ndarray of shape (n_samples, n_classes), or a list of n_outputs\n",
" | such arrays if n_outputs > 1.\n",
" | The class probabilities of the input samples. The order of the\n",
" | classes corresponds to that in the attribute :term:`classes_`.\n",
" | \n",
" | predict_proba(self, X)\n",
" | Predict class probabilities for X.\n",
" | \n",
" | The predicted class probabilities of an input sample are computed as\n",
" | the mean predicted class probabilities of the trees in the forest.\n",
" | The class probability of a single tree is the fraction of samples of\n",
" | the same class in a leaf.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n",
" | The input samples. Internally, its dtype will be converted to\n",
" | ``dtype=np.float32``. If a sparse matrix is provided, it will be\n",
" | converted into a sparse ``csr_matrix``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | p : ndarray of shape (n_samples, n_classes), or a list of n_outputs\n",
" | such arrays if n_outputs > 1.\n",
" | The class probabilities of the input samples. The order of the\n",
" | classes corresponds to that in the attribute :term:`classes_`.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from sklearn.base.ClassifierMixin:\n",
" | \n",
" | score(self, X, y, sample_weight=None)\n",
" | Return the mean accuracy on the given test data and labels.\n",
" | \n",
" | In multi-label classification, this is the subset accuracy\n",
" | which is a harsh metric since you require for each sample that\n",
" | each label set be correctly predicted.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : array-like of shape (n_samples, n_features)\n",
" | Test samples.\n",
" | \n",
" | y : array-like of shape (n_samples,) or (n_samples, n_outputs)\n",
" | True labels for X.\n",
" | \n",
" | sample_weight : array-like of shape (n_samples,), default=None\n",
" | Sample weights.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | score : float\n",
" | Mean accuracy of self.predict(X) wrt. y.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data descriptors inherited from sklearn.base.ClassifierMixin:\n",
" | \n",
" | __dict__\n",
" | dictionary for instance variables (if defined)\n",
" | \n",
" | __weakref__\n",
" | list of weak references to the object (if defined)\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from BaseForest:\n",
" | \n",
" | apply(self, X)\n",
" | Apply trees in the forest to X, return leaf indices.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n",
" | The input samples. Internally, its dtype will be converted to\n",
" | ``dtype=np.float32``. If a sparse matrix is provided, it will be\n",
" | converted into a sparse ``csr_matrix``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | X_leaves : ndarray of shape (n_samples, n_estimators)\n",
" | For each datapoint x in X and for each tree in the forest,\n",
" | return the index of the leaf x ends up in.\n",
" | \n",
" | decision_path(self, X)\n",
" | Return the decision path in the forest.\n",
" | \n",
" | .. versionadded:: 0.18\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n",
" | The input samples. Internally, its dtype will be converted to\n",
" | ``dtype=np.float32``. If a sparse matrix is provided, it will be\n",
" | converted into a sparse ``csr_matrix``.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | indicator : sparse matrix of shape (n_samples, n_nodes)\n",
" | Return a node indicator matrix where non zero elements indicates\n",
" | that the samples goes through the nodes. The matrix is of CSR\n",
" | format.\n",
" | \n",
" | n_nodes_ptr : ndarray of shape (n_estimators + 1,)\n",
" | The columns from indicator[n_nodes_ptr[i]:n_nodes_ptr[i+1]]\n",
" | gives the indicator value for the i-th estimator.\n",
" | \n",
" | fit(self, X, y, sample_weight=None)\n",
" | Build a forest of trees from the training set (X, y).\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n",
" | The training input samples. Internally, its dtype will be converted\n",
" | to ``dtype=np.float32``. If a sparse matrix is provided, it will be\n",
" | converted into a sparse ``csc_matrix``.\n",
" | \n",
" | y : array-like of shape (n_samples,) or (n_samples, n_outputs)\n",
" | The target values (class labels in classification, real numbers in\n",
" | regression).\n",
" | \n",
" | sample_weight : array-like of shape (n_samples,), default=None\n",
" | Sample weights. If None, then samples are equally weighted. Splits\n",
" | that would create child nodes with net zero or negative weight are\n",
" | ignored while searching for a split in each node. In the case of\n",
" | classification, splits are also ignored if they would result in any\n",
" | single class carrying a negative weight in either child node.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | self : object\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Readonly properties inherited from BaseForest:\n",
" | \n",
" | feature_importances_\n",
" | The impurity-based feature importances.\n",
" | \n",
" | The higher, the more important the feature.\n",
" | The importance of a feature is computed as the (normalized)\n",
" | total reduction of the criterion brought by that feature. It is also\n",
" | known as the Gini importance.\n",
" | \n",
" | Warning: impurity-based feature importances can be misleading for\n",
" | high cardinality features (many unique values). See\n",
" | :func:`sklearn.inspection.permutation_importance` as an alternative.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | feature_importances_ : ndarray of shape (n_features,)\n",
" | The values of this array sum to 1, unless all trees are single node\n",
" | trees consisting of only the root node, in which case it will be an\n",
" | array of zeros.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from sklearn.ensemble._base.BaseEnsemble:\n",
" | \n",
" | __getitem__(self, index)\n",
" | Return the index'th estimator in the ensemble.\n",
" | \n",
" | __iter__(self)\n",
" | Return iterator over estimators in the ensemble.\n",
" | \n",
" | __len__(self)\n",
" | Return the number of estimators in the ensemble.\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Data and other attributes inherited from sklearn.ensemble._base.BaseEnsemble:\n",
" | \n",
" | __annotations__ = {'_required_parameters': typing.List[str]}\n",
" | \n",
" | ----------------------------------------------------------------------\n",
" | Methods inherited from sklearn.base.BaseEstimator:\n",
" | \n",
" | __getstate__(self)\n",
" | \n",
" | __repr__(self, N_CHAR_MAX=700)\n",
" | Return repr(self).\n",
" | \n",
" | __setstate__(self, state)\n",
" | \n",
" | get_params(self, deep=True)\n",
" | Get parameters for this estimator.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | deep : bool, default=True\n",
" | If True, will return the parameters for this estimator and\n",
" | contained subobjects that are estimators.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | params : mapping of string to any\n",
" | Parameter names mapped to their values.\n",
" | \n",
" | set_params(self, **params)\n",
" | Set the parameters of this estimator.\n",
" | \n",
" | The method works on simple estimators as well as on nested objects\n",
" | (such as pipelines). The latter have parameters of the form\n",
" | ``<component>__<parameter>`` so that it's possible to update each\n",
" | component of a nested object.\n",
" | \n",
" | Parameters\n",
" | ----------\n",
" | **params : dict\n",
" | Estimator parameters.\n",
" | \n",
" | Returns\n",
" | -------\n",
" | self : object\n",
" | Estimator instance.\n",
"\n"
]
}
],
"source": [
"help(RandomForestClassifier)"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [],
"source": [
"# Use 10 random trees\n",
"model = RandomForestClassifier(n_estimators=10,max_features='auto',random_state=101)"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"RandomForestClassifier(n_estimators=10, random_state=101)"
]
},
"execution_count": 99,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.fit(X_train,y_train)"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [],
"source": [
"preds = model.predict(X_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Evaluation"
]
},
{
"cell_type": "code",
"execution_count": 101,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import confusion_matrix,classification_report,plot_confusion_matrix,accuracy_score"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[39, 2, 0],\n",
" [ 1, 22, 0],\n",
" [ 0, 0, 37]], dtype=int64)"
]
},
"execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"confusion_matrix(y_test,preds)"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay at 0x1384588b0d0>"
]
},
"execution_count": 103,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAVwAAAEGCAYAAAApAy29AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAj5klEQVR4nO3de5gU5Zn+8e89w3AGEQcREAOIGo0HVDwbgxrjIdlosiZK3MTsuiG6msSY7E9dvdSYjRsTs248B5NsjOshqDGaeMIIrOKqHAwgiGhUIHJQQEEUYYaZ5/dH1WA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jSB5ZPoz6aZzJM2T9GtJ2+aLxwnXzCpSRMEJd3VEjM1ZJrbUnqS+wD3AuRHxNnAjsDMwhqQH/LN8MXlIwcwqVrGmhUmqIUm2t0XE7wEi4vWc928G/pSvHfdwzaxiReRf8pEk4FfAwoj4z5ztQ3J2+wIwP19b7uGaWUUKRGNxZikcBnwVeE7SnHTbvwHjJY0hucdiMfDNfA054ZpZxSrGfQ8RMR1anLD7YHvbcsI1s8oUrqVgZlY6Gbu11wnXzCpWl+nhSrqWNn4/RMS3OyUiM7MiCKCxsYskXGBWyaIwMyu2ALpKDzcibsl9Lal3RGzo/JDMzIqjy5VnlHSIpOeBF9LX+0i6odMjMzPrqChgKaFCZgX/F3AssAYgIuYCR3RiTGZmRZC/jkKpL6oVNEshIv6W3N22RUPnhGNmVkQZG1IoJOH+TdKhQKQFHL4DLOzcsMzMOiggMjZLoZAhhTOBs0kK7i4nKUV2difGZGZWJCpgKZ28PdyIWA2cVoJYzMyKK2NDCoXMUhgl6Y+SVkl
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plot_confusion_matrix(model,X_test,y_test)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Feature Importance\n",
"\n",
"Very useful attribute of the trained model!"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.35324545, 0.13320651, 0.1985798 , 0.12074795, 0.14244127,\n",
" 0.03781403, 0.00677831, 0.00718669])"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.feature_importances_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Choosing correct number of trees"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's explore if continually adding more trees improves performance..."
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
"test_error = []\n",
"\n",
"for n in range(1,40):\n",
" # Use n random trees\n",
" model = RandomForestClassifier(n_estimators=n,max_features='auto')\n",
" model.fit(X_train,y_train)\n",
" test_preds = model.predict(X_test)\n",
" test_error.append(1-accuracy_score(test_preds,y_test))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x138491ef760>"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA2l0lEQVR4nO29e5Bb93Xn+Tl4NPoJgGx2N0lAFEmJFEUSHdqm5UliWYm1kuXMWpIn8ki2M9FkNON4vXJ2y+W15XWtR3GNK9HMJtrJ2hXHiTVylMxIXmVcpmOlNJmRNbZHjixKlhok9aKoB9F8Nwn0uxto/PYP3AuCaDwugIsGCJxPVVcDF7/7u+deAN/7w/n9zjlijEFRFEXpXDytNkBRFEVpLir0iqIoHY4KvaIoSoejQq8oitLhqNAriqJ0OL5WG1DMhg0bzNatW1tthqIoymXF888/f84YM1LqtbYT+q1bt3Lw4MFWm6EoinJZISJvl3tNXTeKoigdjgq9oihKh6NCryiK0uE48tGLyC3Avwe8wF8YY/6w6PUA8JfAe4Ap4E5jzFvWa+PAnwFBIAu81xiz6NYJKIpyeZBOp0kkEiwu6te/EXp7e4lGo/j9fsf7VBV6EfEC3wBuAhLAcyJywBhzpKDZPcAFY8zVInIX8ABwp4j4gL8C/pkx5iURGQbSzk9JUZROIZFIMDQ0xNatWxGRVptzWWKMYWpqikQiwbZt2xzv58R1cx1w1BhzzBizDDwK3FbU5jbgO9bjx4EbJfdO3gxMGGNesoycMsasOLZOUZSOYXFxkeHhYRX5BhARhoeHa/5V5EToI8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background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(range(1,40),test_error,label='Test Error')\n",
"plt.legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Clearly there are diminishing returns, on such a small dataset, we've pretty much extracted all the information we can after about 5 trees."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Random Forest - HyperParameter Exploration"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"https://archive.ics.uci.edu/ml/datasets/banknote+authentication"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(\"../DATA/data_banknote_authentication.csv\")"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Variance_Wavelet</th>\n",
" <th>Skewness_Wavelet</th>\n",
" <th>Curtosis_Wavelet</th>\n",
" <th>Image_Entropy</th>\n",
" <th>Class</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>3.62160</td>\n",
" <td>8.6661</td>\n",
" <td>-2.8073</td>\n",
" <td>-0.44699</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4.54590</td>\n",
" <td>8.1674</td>\n",
" <td>-2.4586</td>\n",
" <td>-1.46210</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3.86600</td>\n",
" <td>-2.6383</td>\n",
" <td>1.9242</td>\n",
" <td>0.10645</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3.45660</td>\n",
" <td>9.5228</td>\n",
" <td>-4.0112</td>\n",
" <td>-3.59440</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.32924</td>\n",
" <td>-4.4552</td>\n",
" <td>4.5718</td>\n",
" <td>-0.98880</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Variance_Wavelet Skewness_Wavelet Curtosis_Wavelet Image_Entropy Class\n",
"0 3.62160 8.6661 -2.8073 -0.44699 0\n",
"1 4.54590 8.1674 -2.4586 -1.46210 0\n",
"2 3.86600 -2.6383 1.9242 0.10645 0\n",
"3 3.45660 9.5228 -4.0112 -3.59440 0\n",
"4 0.32924 -4.4552 4.5718 -0.98880 0"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<seaborn.axisgrid.PairGrid at 0x13849319fa0>"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAvcAAALFCAYAAABHzcwdAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOyddXwcdfrH37MuyW7c3dO0Sd1b6kLxww874LDD4Tjkjvudcdzhehwc7lq8UC91SyW1uLtssrtZ353fH5NumyZACzVg3q/XQjK2325mZ555vs/z+QiiKCIjIyMjIyMjIyMj89NHcaIHICMjIyMjIyMjIyNzdJCDexkZGRkZGRkZGZmfCXJwLyMjIyMjIyMjI/MzQQ7uZWRkZGRkZGRkZH4myMG9jIyMjIyMjIyMzM8EObiXkZGRkZGRk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eJC4u46tWtAMSbdczKjwGg3ebmno92snRvGyAFG6/8ZiyTsmSNbZmfFlanh4e+LmVvs42UCAM7G7r57ZQMzhudRHVfE2qCWX9MM91Wp4fV5R3sbOhhTUVHcPnQRBMz82JYVdYRDOwBvH6RF9dU86uRiSza1Uqbzc2/violL97E9NyY4HbtdjfPrqjE3WcaODIljEfOLZTLG48hcnAvc9xo6nZid/tIDNMPWJcQpqe81c4YucHmF015m61fYA9w/ye7GZUaTupBNzWHx4fPLwYzP6cVJpAZHUJNp5RJHxIfGswcNXW7mJIdzcaqgXbonb0emsraWTAsjrRIA5Uddv762R46+25gOxt6OKMogeZuZzC4L2+z8cCXe/nNpDS8vgDflHdgcXgYlhDGFNl
"text/plain": [
"<Figure size 762.375x720 with 20 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.pairplot(df,hue='Class')"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [],
"source": [
"X = df.drop(\"Class\",axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [],
"source": [
"y = df[\"Class\"]"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.15, random_state=101)"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import GridSearchCV"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [],
"source": [
"n_estimators=[64,100,128,200]\n",
"max_features= [2,3,4]\n",
"bootstrap = [True,False]"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [],
"source": [
"param_grid = {'n_estimators':n_estimators,\n",
" 'max_features':max_features,\n",
" 'bootstrap':bootstrap}"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [],
"source": [
"rfc = RandomForestClassifier(oob_score=True) # Note, oob_score only makes sense when bootstrap=True!\n",
"grid = GridSearchCV(rfc,param_grid)"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n",
"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py:548: FitFailedWarning: Estimator fit failed. The score on this train-test partition for these parameters will be set to nan. Details: \n",
"Traceback (most recent call last):\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\model_selection\\_validation.py\", line 531, in _fit_and_score\n",
" estimator.fit(X_train, y_train, **fit_params)\n",
" File \"c:\\users\\marcial\\anaconda_new\\envs\\ml_master\\lib\\site-packages\\sklearn\\ensemble\\_forest.py\", line 351, in fit\n",
" raise ValueError(\"Out of bag estimation only available\"\n",
"ValueError: Out of bag estimation only available if bootstrap=True\n",
"\n",
" warnings.warn(\"Estimator fit failed. The score on this train-test\"\n"
]
},
{
"data": {
"text/plain": [
"GridSearchCV(estimator=RandomForestClassifier(oob_score=True),\n",
" param_grid={'bootstrap': [True, False], 'max_features': [2, 3, 4],\n",
" 'n_estimators': [64, 100, 128, 200]})"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grid.fit(X_train,y_train)"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'bootstrap': True, 'max_features': 2, 'n_estimators': 64}"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grid.best_params_"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [],
"source": [
"predictions = grid.predict(X_test)"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" precision recall f1-score support\n",
"\n",
" 0 1.00 0.98 0.99 124\n",
" 1 0.98 1.00 0.99 82\n",
"\n",
" accuracy 0.99 206\n",
" macro avg 0.99 0.99 0.99 206\n",
"weighted avg 0.99 0.99 0.99 206\n",
"\n"
]
}
],
"source": [
"print(classification_report(y_test,predictions))"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<sklearn.metrics._plot.confusion_matrix.ConfusionMatrixDisplay at 0x138493358e0>"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAATgAAAEHCAYAAAA6U1oSAAAAOXRFWHRTb2Z0d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7OcGjjIUDQHnJnlV5ImnAPOzHIrfQtO0tfoI6cj4qJCKjKzlhZAd3fJAw5YsNOqMLPyCKDsLbiImFX7XtKQiFhffElm1urKch9cvzezSPqApGeAX6bvD5f0zcIrM7PWFRm3Jstyt96/ACcDbwBExM+B4wusycxaWraJ9q0wEJFpFDUiXk5WM3lHVzHlmFkptEDrLIssAfeypA8CIakDuBh4ttiyzKxlBURJRlGzdFHPBy4gWRd9GXBE+t7MdlnKuDVXvy24iFgJnL0TajGzsihJFzXLKOqBkn4g6XVJKyTNkXTgzijOzFpUhUZRbwJuBcaSPPnmNmB2kUWZWQvrudE3y9ZkWQJuSET8W0R0ptv3gcFFF2ZmratBD50pXF9zUUekL38k6VLgZpLs/hhw106ozcxaVUlGUfsaZHicJNB6fpNP1XwWwGVFFWVmrU0t0DrLoq+5qBN3ZiFmVhItMoCQRaaZDJIOBSZTc+0tIr5XVFFm1spaYwAhi34DTtLlwFSSgLsLOAV4GHDAme2qStKCyzKKejpwEvBqRHwCOBzYs9CqzKy1dWfcmixLF3VDRHRL6pQ0DFgBTCi4LjNrVVVY8LLGAknDge+QjKyuBX5aZFFm1tpKP4raIyL+In15jaS7gWER8VSxZZlZS2tQwKWNp2uBQ9OjfhJYBNwCHAC8AHw0IlbXc/xer8FJOnLbDRgBtKevzcx21NXA3RFxCMn1/WeBS4F5ETEJmJe+r0tfLbh/7uOzAE6
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plot_confusion_matrix(grid,X_test,y_test)"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# No underscore, reports back original oob_score parameter\n",
"grid.best_estimator_.oob_score"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.9939965694682675"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# With underscore, reports back fitted attribute of oob_score\n",
"grid.best_estimator_.oob_score_"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Understanding Number of Estimators (Trees)\n",
"\n",
"Let's plot out error vs. Number of Estimators"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.metrics import accuracy_score"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [],
"source": [
"errors = []\n",
"misclassifications = []\n",
"\n",
"for n in range(1,64):\n",
" rfc = RandomForestClassifier( n_estimators=n,bootstrap=True,max_features= 2)\n",
" rfc.fit(X_train,y_train)\n",
" preds = rfc.predict(X_test)\n",
" err = 1 - accuracy_score(preds,y_test)\n",
" n_missed = np.sum(preds != y_test) # watch the video to understand this line!!\n",
" errors.append(err)\n",
" misclassifications.append(n_missed)"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x13849748310>]"
]
},
"execution_count": 75,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD4CAYAAADlwTGnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA1xklEQVR4nO29f3Rc13Xf+9kzgxkQP2b4CwBJkBJpkbZMApYiIZSdyKltxTblOqbTSCtSvGr1La0ora3+WGnaJzWJnqMm7dN7fVHTRE2rREoVrTiSq0bPTMJEcSzHWU5sWpAsGwAlyhBFigBFAvw1+P1794+5d3AxuDNzB7gjYHj3Zy0szNw5987Zc2bu95yz99lHVBXDMAwjesTWugKGYRjG2mACYBiGEVFMAAzDMCKKCYBhGEZEMQEwDMOIKIm1rkAlbN26V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0yxcLAzUMw1ikbBgogKoeBY4WHHvI83gKuNPnvF8Hfr3IZW8OXs1wSCZMAAzDMFwitRI4ZU5gwzCMPJESgKTlAjIMw8gTOQGwEYBhGEaOaAlAPG4+AMMwDIdICYDlAjIMw1gkUgKQjOemgBYWdK2rYhiGseZESwDcbSHND2AYhhEtAUiZABiGYeSJpABYKKhhGEbEBMCmgAzDMBaJpgBYJJBhGEa0BCCViAMmAIZhGBAxAUjGHR+A7QlgGIYRMQGwKSDDMIw8JgCGYRgRJVICkA8DtSggwzCMYAIgIodE5ISI9IvIAz6vp0TkWef1YyKy2zn+cRF5WUR6nP8f85xzs3O8X0T+i4hIaFYVIWnrAAzDMPKUFQARiQOPAbcD+4G7RWR/QbF7gcuquhd4FHjEOX4B+ClV7SS3Z/DTnnN+F/h
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(range(1,64),errors)"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x13849791c10>]"
]
},
"execution_count": 76,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAs8UlEQVR4nO3de3Bj130f8O8PAHHBB4B98LFL7Fu7euyS0kpmZTmynVqKPZLj2DNtOiNPkkmdtJvMOIndZpqx244z6R+ZSdNJ43YyabdxHDdx7DaO3bgePys7cRzbslcvk/vQSruSVgvuktwXAD7wPv3j3gNeABfABXgveWF+PzOcXZIgeA7PxQ+/e56ilAIREQVXaKsLQERE7TFQExEFHAM1EVHAMVATEQUcAzURUcBF/HjS0dFRdejQIT+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f+IZ5Eu9vfk8fHg3/ucvPdz1z/3aXz6Hk/t34F+87UhPv7eTVvUaj8fwlQ+9rXZ3RLQdubr6RSQM4FkARwH8kVLqGYfHnAJwCgAOHDiw4YLpcxML5UpdoH5lcRkXF5bx9PlFx0C9lCvgxGQCANan57UJ1Gdev40zr9/GqzdXcNfYyIbL7caFazlcWlrBT0/vxb6dgwCAYqWKT/7Da3jhjTttA/WPrmZwZ7WEX3jkIIZsfxc3fvjaLXzv0g0opSDi/k1prVjBl2evYaVQ9i1QO9XrWiaPL744j7l0Bm8+stuX30vUD1wFaqVUBcBJEdkB4AsiMqWUmmt4zGkApwFgZmZmwxm3PaO207M6ZtMZx59byObxjnv
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(range(1,64),misclassifications)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}