Skip to content

Commit 36667ec

Browse files
committed
put command to beginnig, so imports are fail safe
1 parent 9ddab5d commit 36667ec

File tree

1 file changed

+26
-51
lines changed

1 file changed

+26
-51
lines changed

chapter02/Transforming Data in Scikit-Learn.ipynb

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
"The dataset is available at openML."
1616
]
1717
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": null,
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"# making sure imbalanced-learn and scikit-learn are in compatible versions:\n",
25+
"!pip install -U 'scikit-learn>=0.23' 'imbalanced-learn==0.7.0'"
26+
]
27+
},
1828
{
1929
"cell_type": "code",
2030
"execution_count": 1,
@@ -37,52 +47,7 @@
3747
}
3848
],
3949
"source": [
40-
"pip install -q openml"
41-
]
42-
},
43-
{
44-
"cell_type": "code",
45-
"execution_count": 2,
46-
"metadata": {},
47-
"outputs": [
48-
{
49-
"name": "stdout",
50-
"output_type": "stream",
51-
"text": [
52-
"Requirement already satisfied: imbalanced-learn in /Users/ben/anaconda3/lib/python3.6/site-packages (0.7.0)\n",
53-
"Requirement already satisfied: scikit-learn>=0.23 in /Users/ben/anaconda3/lib/python3.6/site-packages (from imbalanced-learn) (0.23.2)\n",
54-
"Requirement already satisfied: joblib>=0.11 in /Users/ben/anaconda3/lib/python3.6/site-packages (from imbalanced-learn) (0.16.0)\n",
55-
"Requirement already satisfied: scipy>=0.19.1 in /Users/ben/anaconda3/lib/python3.6/site-packages (from imbalanced-learn) (1.5.2)\n",
56-
"Requirement already satisfied: numpy>=1.13.3 in /Users/ben/anaconda3/lib/python3.6/site-packages (from imbalanced-learn) (1.19.1)\n",
57-
"Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn>=0.23->imbalanced-learn) (2.1.0)\n",
58-
"Note: you may need to restart the kernel to use updated packages.\n"
59-
]
60-
}
61-
],
62-
"source": [
63-
"pip install imbalanced-learn"
64-
]
65-
},
66-
{
67-
"cell_type": "code",
68-
"execution_count": 3,
69-
"metadata": {},
70-
"outputs": [
71-
{
72-
"name": "stdout",
73-
"output_type": "stream",
74-
"text": [
75-
"Requirement already up-to-date: scikit-learn in /Users/ben/anaconda3/lib/python3.6/site-packages (0.23.2)\n",
76-
"Requirement already satisfied, skipping upgrade: threadpoolctl>=2.0.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn) (2.1.0)\n",
77-
"Requirement already satisfied, skipping upgrade: numpy>=1.13.3 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn) (1.19.1)\n",
78-
"Requirement already satisfied, skipping upgrade: scipy>=0.19.1 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn) (1.5.2)\n",
79-
"Requirement already satisfied, skipping upgrade: joblib>=0.11 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn) (0.16.0)\n",
80-
"Note: you may need to restart the kernel to use updated packages.\n"
81-
]
82-
}
83-
],
84-
"source": [
85-
"pip install --upgrade scikit-learn"
50+
"!pip install -q openml"
8651
]
8752
},
8853
{
@@ -1519,17 +1484,27 @@
15191484
},
15201485
{
15211486
"cell_type": "code",
1522-
"execution_count": 23,
1487+
"execution_count": 2,
15231488
"metadata": {
15241489
"colab": {},
15251490
"colab_type": "code",
15261491
"id": "cyJyWqnoclf1"
15271492
},
1528-
"outputs": [],
1493+
"outputs": [
1494+
{
1495+
"name": "stdout",
1496+
"output_type": "stream",
1497+
"text": [
1498+
"Requirement already up-to-date: scikit-learn>=0.23 in /Users/ben/anaconda3/lib/python3.6/site-packages (0.23.2)\n",
1499+
"Requirement already up-to-date: imbalanced-learn==0.7.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (0.7.0)\n",
1500+
"Requirement already satisfied, skipping upgrade: joblib>=0.11 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn>=0.23) (0.16.0)\n",
1501+
"Requirement already satisfied, skipping upgrade: scipy>=0.19.1 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn>=0.23) (1.5.2)\n",
1502+
"Requirement already satisfied, skipping upgrade: threadpoolctl>=2.0.0 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn>=0.23) (2.1.0)\n",
1503+
"Requirement already satisfied, skipping upgrade: numpy>=1.13.3 in /Users/ben/anaconda3/lib/python3.6/site-packages (from scikit-learn>=0.23) (1.18.5)\n"
1504+
]
1505+
}
1506+
],
15291507
"source": [
1530-
"#if you run into problems with importing imblearn, you might have to downgrade scikit-learn:\n",
1531-
"#!pip install --upgrade scikit-learn==0.20.3\n",
1532-
"\n",
15331508
"from imblearn.ensemble import (\n",
15341509
" BalancedRandomForestClassifier,\n",
15351510
" RUSBoostClassifier,\n",

0 commit comments

Comments
 (0)