algo et data science

This commit is contained in:
gwen
2018-08-24 14:09:11 +02:00
committed by Benjamin Bohard
parent f20ef936ce
commit fede121bc4
86 changed files with 18028 additions and 0 deletions

View File

@ -0,0 +1,56 @@
Machine learning
=================
Data science (not big data yet)
some links
------------
numpy, scipy, matplotlib... and scikit
https://www.scipy.org/install.html
https://matplotlib.org/
http://scikit-learn.org/stable/
installation
--------------
.. code-block:: python
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print('Python: {}'.format(sys.version))
Python: 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0]
>>> import scipy
>>> print('scipy: {}'.format(scipy.__version__))
scipy: 0.19.1
>>> import numpy
>>> print('numpy: {}'.format(numpy.__version__))
numpy: 1.13.3
>>> import matplotlib
>>> print('matplotlib: {}'.format(matplotlib.__version__))
matplotlib: 2.1.1
>>> # pandas
...
>>> import pandas
>>> print('pandas: {}'.format(pandas.__version__))
pandas: 0.22.0
>>> # scikit-learn
... import sklearn
>>> print('sklearn: {}'.format(sklearn.__version__))
sklearn
usage
-------
https://machinelearningmastery.com/machine-learning-in-python-step-by-step/

View File

@ -0,0 +1,34 @@
Fil conducteur : 1er tour des élections présidentielles 2017
=============================================================
Le fil conducteur sera lexploitation de données issues du 1er tour des élections présidentielles qui ont eu lieu en France le 23 avril 2017.
Les données dont on dispose sont les résultats par canton (plus de 2000 cantons). Pour chaque canton sont donnés
- le nombre dinscrits
- le nombre de votants
- le nombre de bulletins nuls
- le nombre de bulletins blancs
- le nombre de voix obtenus par chacun des candidats.
Lobjectif est détablir
- les résultats au niveau national
- la participation
.. figure:: images/participation_globale.png
:width: 650
:alt: Participation globale
- le scores des candidats
.. figure:: images/scores_1er_tour.png
:width: 650
:alt: Score des candidats
Ce sera l'occasion de découvrir :
* les structures itérables, en particulier les tuples et dictionnaires
* la lecture et l'écriture de données dans des fichiers
* des algorithmes de tris et de recherche.

View File

@ -0,0 +1,36 @@
.. default-role:: literal
.. meta::
:description: algo tutorial
:keywords: algorithm, python, tutorial
.. title:: algofundoc
Algo Fun
==========
.. toctree::
:maxdepth: 1
programmation
liens
MachineLearning
pandas
Indices and tables
==================
* `All modules for which code is available <_modules/index.html>`_
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. note:: The pyfun code is licensed under the `LGPL licence`_
and this documentation is licensed under the `Creative Commons
Attribution-ShareAlike 3.0 Unported License`_\ .
.. _`Creative Commons Attribution-ShareAlike 3.0 Unported License`: http://creativecommons.org/licenses/by-sa/3.0/deed.en_US
.. _`LGPL licence`: http://www.gnu.org/licenses/lgpl.html

View File

@ -0,0 +1,16 @@
Liens utiles
=============
- random_ datas
- pandas_
- ploting_
- machine_ learning
- making_ a machine learning
- data_ science
.. _making: https://machinelearningmastery.com/machine-learning-in-python-step-by-step/
.. _data: https://realpython.com/tutorials/data-science/
.. _machine: https://realpython.com/tutorials/machine-learning/
.. _ploting: https://realpython.com/python-histograms/?__s=o2w1az6ypdj7ogdsnqwf
.. _random: https://realpython.com/python-random/?__s=o2w1az6ypdj7ogdsnqwf
.. _pandas: https://realpython.com/fast-flexible-pandas/?__s=o2w1az6ypdj7ogdsnqwf

View File

@ -0,0 +1,229 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The **import** keyword is used to import a library"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"6.123233995736766e-17\n"
]
}
],
"source": [
"import math\n",
"print(math.cos(math.pi / 2))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pandas\n",
"======="
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>col1</th>\n",
" <th>col2</th>\n",
" <th>col3</th>\n",
" <th>col4</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>line1</th>\n",
" <td>-0.882125</td>\n",
" <td>2.176452</td>\n",
" <td>0.163955</td>\n",
" <td>-0.618232</td>\n",
" </tr>\n",
" <tr>\n",
" <th>line2</th>\n",
" <td>-0.721538</td>\n",
" <td>0.035578</td>\n",
" <td>0.180072</td>\n",
" <td>1.015987</td>\n",
" </tr>\n",
" <tr>\n",
" <th>line3</th>\n",
" <td>-1.162355</td>\n",
" <td>0.384632</td>\n",
" <td>-0.674092</td>\n",
" <td>0.162693</td>\n",
" </tr>\n",
" <tr>\n",
" <th>line4</th>\n",
" <td>-1.399455</td>\n",
" <td>-0.698512</td>\n",
" <td>0.039420</td>\n",
" <td>0.898408</td>\n",
" </tr>\n",
" <tr>\n",
" <th>line5</th>\n",
" <td>1.755342</td>\n",
" <td>-0.073242</td>\n",
" <td>-1.502503</td>\n",
" <td>-0.586194</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" col1 col2 col3 col4\n",
"line1 -0.882125 2.176452 0.163955 -0.618232\n",
"line2 -0.721538 0.035578 0.180072 1.015987\n",
"line3 -1.162355 0.384632 -0.674092 0.162693\n",
"line4 -1.399455 -0.698512 0.039420 0.898408\n",
"line5 1.755342 -0.073242 -1.502503 -0.586194"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy\n",
"import pandas\n",
"rows = ['line1', 'line2', 'line3', 'line4', 'line5']\n",
"cols = ['col1', 'col2', 'col3', 'col4']\n",
"from IPython.display import display\n",
"dataframe = pandas.DataFrame(numpy.random.randn(5,4), index=rows, columns=cols)\n",
"display(dataframe)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"reorganise a **dataframe** from datas as a dictionary with tuples as keys\n",
"-----------------------------------------------------------------------------------------------------"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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>Column 1</th>\n",
" <th>Column 2</th>\n",
" <th>Column 3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Cerise</td>\n",
" <td>Lanister</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Paul</td>\n",
" <td>Durand</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Pierre</td>\n",
" <td>Dupont</td>\n",
" <td>16</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>john</td>\n",
" <td>Snow</td>\n",
" <td>12</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Column 1 Column 2 Column 3\n",
"0 Cerise Lanister 14\n",
"1 Paul Durand 13\n",
"2 Pierre Dupont 16\n",
"3 john Snow 12"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"dico = {('john', 'Snow') : 12, ('Paul', 'Durand') : 13, (\"Pierre\", \"Dupont\") : 16, (\"Cerise\", \"Lanister\") : 14}\n",
"import pandas\n",
"df = pandas.Series(dico).reset_index()\n",
"df.columns = ['Column 1', 'Column 2', 'Column 3']\n",
"from IPython.display import display\n",
"display(df)"
]
}
],
"metadata": {
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -0,0 +1,14 @@
pandas
==========
**examples** in the jupyter_ notebooks
.. _jupyter: http://jupyter.org/
ipython and pandas::
jupyter notebook Pandas.ipynb
.. toctree::
notebooks/Pandas.ipynb

View File

@ -0,0 +1,61 @@
==============================
Algorithmes et Programmation
==============================
-----
Cours
-----
.. toctree::
:maxdepth: 1
fil_conducteur
- Structures de données séquentielles
- Ensembles et dictionnaires
- Algorithmes de recherche
- Les fichiers
- Algorithmes de tri
----
TP
----
.. toctree::
:maxdepth: 1
- Tester avec doctest
- Listes
- Gestion dune promotion détudiants
- Anagrammes
- Analyse dun fichier texte
- Évaluation empirique des tris
-----------------
Documents annexes
-----------------
.. toctree::
:maxdepth: 1
Bibliographie
-------------
* Apprendre à programmer avec Python 3, Gérard Swinnen, editions Eyrolles (Chapitres 1 à 7, et chapitre 10 en partie). `Version électronique téléchargeable <http://inforef.be/swi/python.htm>`_.
* `Site officiel du langage Python <https://www.python.org/>`_.
* `Documentation officielle de la version 3.5 de Python <https://docs.python.org/3.5/>`_.
* `Site officiel de Thonny <http://www.thonny.org/>`_.