|
1678 | 1678 | "name": "stdout", |
1679 | 1679 | "output_type": "stream", |
1680 | 1680 | "text": [ |
1681 | | - "{'decision tree': DecisionTreeClassifier(criterion='entropy', splitter='random'), 'random forest': RandomForestClassifier(criterion='entropy'), 'SVM': SVC(), 'gradient boosting': GradientBoostingClassifier(), 'multi-layer perceptron (MLP)': MLPClassifier(hidden_layer_sizes=3769, learning_rate='adaptive', max_iter=500), 'k��nearest neighbour (k-NN) classifier': KNeighborsClassifier(n_jobs=-1, n_neighbors=7, weights='distance')}\n" |
| 1681 | + "{'decision tree': DecisionTreeClassifier(criterion='entropy', splitter='random'), 'random forest': RandomForestClassifier(criterion='entropy'), 'SVM': SVC(), 'gradient boosting': GradientBoostingClassifier(), 'multi-layer perceptron (MLP)': MLPClassifier(hidden_layer_sizes=3769, learning_rate='adaptive', max_iter=500), 'k‐nearest neighbour (k-NN) classifier': KNeighborsClassifier(n_jobs=-1, weights='distance')}\n" |
1682 | 1682 | ] |
1683 | 1683 | } |
1684 | 1684 | ], |
|
1742 | 1742 | "output_type": "stream", |
1743 | 1743 | "text": [ |
1744 | 1744 | "Number of samples in the Chocolate dataset: 1885\n", |
1745 | | - "Number of features in a sample: 13\n", |
| 1745 | + "Number of features in a sample: 12\n", |
1746 | 1746 | "Number of Labels in the Chocolate dataset: 1885\n", |
1747 | 1747 | "Unique Labels: ['non-user' 'user']\n" |
1748 | 1748 | ] |
1749 | 1749 | } |
1750 | 1750 | ], |
1751 | 1751 | "source": [ |
1752 | 1752 | "# Convert the dataset to a numpy array\n", |
1753 | | - "np_samples_choco = df_dataset_choco.iloc[:, :-1].to_numpy();\n", |
| 1753 | + "np_samples_choco = df_dataset_choco.iloc[:, 1:-1].to_numpy();\n", |
1754 | 1754 | "np_labels_choco = df_dataset_choco.iloc[:,-1].to_numpy();\n", |
1755 | 1755 | "print(\"Number of samples in the Chocolate dataset: \" + str(len(np_samples_choco)));\n", |
1756 | 1756 | "print(\"Number of features in a sample: \" + str(len(np_samples_choco[random.randint(0, len(np_samples_choco)-1)])));\n", |
|
1768 | 1768 | "name": "stdout", |
1769 | 1769 | "output_type": "stream", |
1770 | 1770 | "text": [ |
1771 | | - "Columns for chocolate dataset: ['ID' 'age' 'gender' 'education' 'country' 'ethnicity' 'nscore' 'escore'\n", |
1772 | | - " 'oscore' 'ascore' 'cscore' 'impuslive' 'ss' 'choc']\n" |
| 1771 | + "Columns for chocolate dataset: ['age' 'gender' 'education' 'country' 'ethnicity' 'nscore' 'escore'\n", |
| 1772 | + " 'oscore' 'ascore' 'cscore' 'impuslive' 'ss']\n" |
1773 | 1773 | ] |
1774 | 1774 | } |
1775 | 1775 | ], |
1776 | 1776 | "source": [ |
1777 | | - "columns_choco = df_dataset_choco.columns.to_numpy();\n", |
| 1777 | + "columns_choco = df_dataset_choco.columns.to_numpy()[1:-1];\n", |
1778 | 1778 | "print(f\"Columns for chocolate dataset: {columns_choco}\");" |
1779 | 1779 | ] |
1780 | 1780 | }, |
|
1858 | 1858 | "joblib.dump(choco_y_test, constants.choco_dataset + '_test-set_labels.pkl');\n", |
1859 | 1859 | "# Save the columns array\n", |
1860 | 1860 | "# Note: We don't use the first ID column and the last labels column\n", |
1861 | | - "joblib.dump(columns_choco[1:-1], constants.choco_dataset + \"_columns.pkl\");" |
| 1861 | + "joblib.dump(columns_choco, constants.choco_dataset + \"_columns.pkl\");" |
1862 | 1862 | ] |
1863 | 1863 | }, |
1864 | 1864 | { |
|
1917 | 1917 | }, |
1918 | 1918 | { |
1919 | 1919 | "cell_type": "code", |
1920 | | - "execution_count": null, |
| 1920 | + "execution_count": 20, |
1921 | 1921 | "id": "59089074", |
1922 | 1922 | "metadata": {}, |
1923 | 1923 | "outputs": [], |
|
1939 | 1939 | "name": "stdout", |
1940 | 1940 | "output_type": "stream", |
1941 | 1941 | "text": [ |
1942 | | - "Training all models\n" |
1943 | | - ] |
1944 | | - }, |
1945 | | - { |
1946 | | - "name": "stderr", |
1947 | | - "output_type": "stream", |
1948 | | - "text": [ |
1949 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1950 | | - " warnings.warn(\n", |
1951 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1952 | | - " warnings.warn(\n", |
1953 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1954 | | - " warnings.warn(\n", |
1955 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1956 | | - " warnings.warn(\n", |
1957 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1958 | | - " warnings.warn(\n", |
1959 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1960 | | - " warnings.warn(\n", |
1961 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1962 | | - " warnings.warn(\n", |
1963 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1964 | | - " warnings.warn(\n", |
1965 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1966 | | - " warnings.warn(\n", |
1967 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
1968 | | - " warnings.warn(\n" |
1969 | | - ] |
1970 | | - }, |
1971 | | - { |
1972 | | - "name": "stdout", |
1973 | | - "output_type": "stream", |
1974 | | - "text": [ |
1975 | | - "All models are completely trained.\n" |
| 1942 | + "Training all models\n", |
| 1943 | + "Completed training decision tree, in 0:00:00.105568s\n", |
| 1944 | + "Completed training random forest, in 0:00:05.836123s\n", |
| 1945 | + "Completed training SVM, in 0:00:06.196589s\n", |
| 1946 | + "Completed training gradient boosting, in 0:00:12.179263s\n", |
| 1947 | + "Completed training MLP, in 0:01:06.500467s\n", |
| 1948 | + "Completed training KNN, in 0:01:11.832748s\n", |
| 1949 | + "All models are completely trained, within 0:01:11.933396s\n" |
1976 | 1950 | ] |
1977 | 1951 | } |
1978 | 1952 | ], |
|
2007 | 1981 | "name": "stdout", |
2008 | 1982 | "output_type": "stream", |
2009 | 1983 | "text": [ |
2010 | | - "{'decision tree': DecisionTreeClassifier(criterion='entropy', splitter='random'), 'random forest': RandomForestClassifier(criterion='entropy'), 'SVM': SVC(), 'gradient boosting': GradientBoostingClassifier(), 'multi-layer perceptron (MLP)': MLPClassifier(hidden_layer_sizes=3769, learning_rate='adaptive', max_iter=500), 'k‐nearest neighbour (k-NN) classifier': KNeighborsClassifier(n_jobs=-1, n_neighbors=7, weights='distance')}\n" |
| 1984 | + "{'decision tree': DecisionTreeClassifier(criterion='entropy', splitter='random'), 'random forest': RandomForestClassifier(criterion='entropy'), 'SVM': SVC(), 'gradient boosting': GradientBoostingClassifier(), 'multi-layer perceptron (MLP)': MLPClassifier(hidden_layer_sizes=3769, learning_rate='adaptive', max_iter=500), 'k‐nearest neighbour (k-NN) classifier': KNeighborsClassifier(n_jobs=-1, weights='distance')}\n" |
2011 | 1985 | ] |
2012 | 1986 | } |
2013 | 1987 | ], |
|
2095 | 2069 | "name": "stdout", |
2096 | 2070 | "output_type": "stream", |
2097 | 2071 | "text": [ |
2098 | | - "Columns for mushroom dataset: ['ID' 'age' 'gender' 'education' 'country' 'ethnicity' 'nscore' 'escore'\n", |
2099 | | - " 'oscore' 'ascore' 'cscore' 'impuslive' 'ss' 'mushrooms']\n" |
| 2072 | + "Columns for mushroom dataset: ['age' 'gender' 'education' 'country' 'ethnicity' 'nscore' 'escore'\n", |
| 2073 | + " 'oscore' 'ascore' 'cscore' 'impuslive' 'ss']\n" |
2100 | 2074 | ] |
2101 | 2075 | } |
2102 | 2076 | ], |
2103 | 2077 | "source": [ |
2104 | | - "columns_mush = df_dataset_mushrooms.columns.to_numpy();\n", |
| 2078 | + "columns_mush = df_dataset_mushrooms.columns.to_numpy()[1:-1];\n", |
2105 | 2079 | "print(f\"Columns for mushroom dataset: {columns_mush}\");" |
2106 | 2080 | ] |
2107 | 2081 | }, |
|
2197 | 2171 | "joblib.dump(mush_y_test, constants.mushrooms_dataset + '_test-set_labels.pkl');\n", |
2198 | 2172 | "# Save the column names\n", |
2199 | 2173 | "# Note: We don't use the first ID column and the last labels column\n", |
2200 | | - "joblib.dump(columns_mush[1:-1], constants.mushrooms_dataset + \"_columns.pkl\");" |
| 2174 | + "joblib.dump(columns_mush, constants.mushrooms_dataset + \"_columns.pkl\");" |
2201 | 2175 | ] |
2202 | 2176 | }, |
2203 | 2177 | { |
|
2266 | 2240 | "name": "stdout", |
2267 | 2241 | "output_type": "stream", |
2268 | 2242 | "text": [ |
2269 | | - "Training all models\n" |
2270 | | - ] |
2271 | | - }, |
2272 | | - { |
2273 | | - "name": "stderr", |
2274 | | - "output_type": "stream", |
2275 | | - "text": [ |
2276 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet.\n", |
2277 | | - " warnings.warn(\n", |
2278 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet.\n", |
2279 | | - " warnings.warn(\n", |
2280 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet.\n", |
2281 | | - " warnings.warn(\n", |
2282 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2283 | | - " warnings.warn(\n", |
2284 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2285 | | - " warnings.warn(\n", |
2286 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2287 | | - " warnings.warn(\n", |
2288 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2289 | | - " warnings.warn(\n", |
2290 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2291 | | - " warnings.warn(\n", |
2292 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2293 | | - " warnings.warn(\n", |
2294 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2295 | | - " warnings.warn(\n", |
2296 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2297 | | - " warnings.warn(\n", |
2298 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2299 | | - " warnings.warn(\n", |
2300 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2301 | | - " warnings.warn(\n", |
2302 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2303 | | - " warnings.warn(\n", |
2304 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2305 | | - " warnings.warn(\n", |
2306 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2307 | | - " warnings.warn(\n", |
2308 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2309 | | - " warnings.warn(\n", |
2310 | | - "c:\\Users\\kelvi\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\neural_network\\_multilayer_perceptron.py:702: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.\n", |
2311 | | - " warnings.warn(\n" |
2312 | | - ] |
2313 | | - }, |
2314 | | - { |
2315 | | - "name": "stdout", |
2316 | | - "output_type": "stream", |
2317 | | - "text": [ |
2318 | | - "All models are completely trained.\n" |
| 2243 | + "Training all models\n", |
| 2244 | + "Completed training decision tree, in 0:00:00.060516s\n", |
| 2245 | + "Completed training random forest, in 0:00:05.128584s\n", |
| 2246 | + "Completed training SVM, in 0:00:07.143005s\n", |
| 2247 | + "Completed training gradient boosting, in 0:00:15.253115s\n", |
| 2248 | + "Completed training MLP, in 0:02:04.641959s\n", |
| 2249 | + "Completed training KNN, in 0:02:06.566441s\n", |
| 2250 | + "All models are completely trained, within 0:02:06.704161s\n" |
2319 | 2251 | ] |
2320 | 2252 | } |
2321 | 2253 | ], |
|
0 commit comments