Added comments

This commit is contained in:
Morgane Foussats 2021-12-14 17:24:42 +01:00
parent c58aa1ec51
commit 7daeec2ef4
3 changed files with 206 additions and 7 deletions

View file

@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "4d162f18",
"metadata": {},
"source": [
"## Import du dataset"
]
},
{
"cell_type": "code",
"execution_count": 1,
@ -23,6 +31,14 @@
"from sklearn.neural_network import MLPClassifier"
]
},
{
"cell_type": "markdown",
"id": "95e0ce45",
"metadata": {},
"source": [
"## Echantillonnage du dataset"
]
},
{
"cell_type": "code",
"execution_count": 4,
@ -34,10 +50,15 @@
"data = mnist.data.values[echantillon]\n",
"target = mnist.target[echantillon]\n",
"trainSize = 17500/25000\n",
"xtrain, xtest, ytrain, ytest = train_test_split(data, target, train_size=trainSize)\n",
"#trainSize = 49000/len(data)\n",
"#xtrain, xtest, ytrain, ytest = train_test_split(data, target, \n",
"#train_size=trainSize)"
"xtrain, xtest, ytrain, ytest = train_test_split(data, target, train_size=trainSize)"
]
},
{
"cell_type": "markdown",
"id": "f35a2a10",
"metadata": {},
"source": [
"## Premier entraînement et scores"
]
},
{
@ -110,6 +131,14 @@
"precision_score(target.values, clf.predict(data), average='micro')"
]
},
{
"cell_type": "markdown",
"id": "d5d7d4c1",
"metadata": {},
"source": [
"## Nombre de couches cachées optimal"
]
},
{
"cell_type": "code",
"execution_count": 14,
@ -149,6 +178,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "e4b13f21",
"metadata": {},
"source": [
"## Nombre de couches cachées et de neurones par couche optimaux"
]
},
{
"cell_type": "code",
"execution_count": 46,
@ -231,6 +268,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "11adbe03",
"metadata": {},
"source": [
"## Algorithme d'optimisation optimal"
]
},
{
"cell_type": "code",
"execution_count": 47,
@ -370,6 +415,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "cf7095a5",
"metadata": {},
"source": [
"## Fonction d'activation optimale"
]
},
{
"cell_type": "code",
"execution_count": 5,
@ -517,6 +570,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "569f6393",
"metadata": {},
"source": [
"## Valeur optimale d'alpha"
]
},
{
"cell_type": "code",
"execution_count": 62,
@ -631,6 +692,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "c46d042a",
"metadata": {},
"source": [
"## Matrice de confusion"
]
},
{
"cell_type": "code",
"execution_count": 6,

View file

@ -1,9 +1,17 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "87214e92",
"metadata": {},
"source": [
"## Import du dataset MNIST"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "b4978985",
"execution_count": null,
"id": "c2e6fa5e",
"metadata": {},
"outputs": [],
"source": [
@ -11,6 +19,14 @@
"mnist = fetch_openml('mnist_784') "
]
},
{
"cell_type": "markdown",
"id": "a36d996c",
"metadata": {},
"source": [
"## Manpulation du jeu de données"
]
},
{
"cell_type": "code",
"execution_count": 8,
@ -703,6 +719,14 @@
"print(mnist.target[4])"
]
},
{
"cell_type": "markdown",
"id": "73194d9b",
"metadata": {},
"source": [
"## Premier entraînement"
]
},
{
"cell_type": "code",
"execution_count": 45,
@ -747,6 +771,14 @@
"clf.fit(xtrain, ytrain)"
]
},
{
"cell_type": "markdown",
"id": "d7d80cd2",
"metadata": {},
"source": [
"## Vérification de la prédiction faite avec l'algorithme entraîné"
]
},
{
"cell_type": "code",
"execution_count": 68,
@ -781,6 +813,14 @@
"print(clf.predict([data[4]]))"
]
},
{
"cell_type": "markdown",
"id": "8eb362f6",
"metadata": {},
"source": [
"## Scores obtenus"
]
},
{
"cell_type": "code",
"execution_count": 71,
@ -805,6 +845,14 @@
"print(clf.score(xtrain, ytrain))"
]
},
{
"cell_type": "markdown",
"id": "aac45aac",
"metadata": {},
"source": [
"## Nombre de voisins optimal"
]
},
{
"cell_type": "code",
"execution_count": 3,
@ -860,6 +908,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "411f6841",
"metadata": {},
"source": [
"## Séparation optimale entre l'entraînement et le test "
]
},
{
"cell_type": "code",
"execution_count": 18,
@ -924,6 +980,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "b3563ad5",
"metadata": {},
"source": [
"## Echantillonnage optimal du dataset"
]
},
{
"cell_type": "code",
"execution_count": 20,
@ -985,6 +1049,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "e387a386",
"metadata": {},
"source": [
"## Distance optimale"
]
},
{
"cell_type": "code",
"execution_count": 25,
@ -1055,6 +1127,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "c863ff41",
"metadata": {},
"source": [
"## Meilleure valeur de n_jobs "
]
},
{
"cell_type": "code",
"execution_count": 31,
@ -1129,6 +1209,14 @@
"print(f'Temps d\\'exécution : {elapsed:.4}ms')"
]
},
{
"cell_type": "markdown",
"id": "1a26da41",
"metadata": {},
"source": [
"## Matrice de confusion"
]
},
{
"cell_type": "code",
"execution_count": 7,

View file

@ -1,5 +1,13 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "557db042",
"metadata": {},
"source": [
"## Import du dataset"
]
},
{
"cell_type": "code",
"execution_count": 15,
@ -11,6 +19,14 @@
"mnist = fetch_openml('mnist_784')"
]
},
{
"cell_type": "markdown",
"id": "2295fc5b",
"metadata": {},
"source": [
"## Premier entraînement et scores"
]
},
{
"cell_type": "code",
"execution_count": 16,
@ -72,6 +88,14 @@
"print(classifier.score(xtest, ytest))"
]
},
{
"cell_type": "markdown",
"id": "32caafa6",
"metadata": {},
"source": [
"## Meilleur kernel à utiliser"
]
},
{
"cell_type": "code",
"execution_count": 7,
@ -196,6 +220,8 @@
}
],
"source": [
"## Il est nécessaire de donner à l'algorithme en entrée une matrice carrée. \n",
"## Ne sachant pas comment faire nous avons décidé de ne pas prendre en compte ce type. \n",
"start = time.time()\n",
"clsvm = SVC(kernel='precomputed')\n",
"clsvm.fit(xtrain, ytrain) \n",
@ -243,6 +269,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "218f2c18",
"metadata": {},
"source": [
"## Valeur optimale du paramètre C"
]
},
{
"cell_type": "code",
"execution_count": 8,
@ -304,6 +338,14 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "2ddd41c7",
"metadata": {},
"source": [
"## Matrice de confusion"
]
},
{
"cell_type": "code",
"execution_count": 19,
@ -339,7 +381,7 @@
{
"cell_type": "code",
"execution_count": 58,
"id": "14cd493b",
"id": "7ea957d9",
"metadata": {},
"outputs": [
{