|
18 | 18 | }, |
19 | 19 | { |
20 | 20 | "cell_type": "code", |
21 | | - "execution_count": 1, |
| 21 | + "execution_count": null, |
22 | 22 | "id": "08c2e5da", |
23 | 23 | "metadata": {}, |
24 | 24 | "outputs": [], |
25 | 25 | "source": [ |
| 26 | + "# Import the libraries\n", |
26 | 27 | "import pandas as pd\n", |
27 | 28 | "import matplotlib.pyplot as plt\n", |
28 | 29 | "import sqlite3\n", |
|
34 | 35 | "id": "5f210e72", |
35 | 36 | "metadata": {}, |
36 | 37 | "source": [ |
37 | | - "## How to get data about the experiment\n", |
| 38 | + "## 1. How to get data about the experiment\n", |
38 | 39 | "\n", |
39 | 40 | "As explained above, ARIEL uses an SQL database to store the data for the individuals. This means that we have a complete file of every individual that existed during the evolution process whether they died or continued to live until the final generation. " |
40 | 41 | ] |
|
44 | 45 | "id": "8d93181b", |
45 | 46 | "metadata": {}, |
46 | 47 | "source": [ |
47 | | - "## Database to pandas dataframe\n", |
| 48 | + "## 1.1 Database to pandas dataframe\n", |
48 | 49 | "\n", |
49 | 50 | "All data about the individuals is stored in the `individual` table. The following line shows you how to turn the database into a pandas DataFrame, which then allows you to manipulate and use the data however you want." |
50 | 51 | ] |
|
313 | 314 | "id": "ed5d7ad0", |
314 | 315 | "metadata": {}, |
315 | 316 | "source": [ |
316 | | - "### Get population per generation\n", |
| 317 | + "### 2. Get population per generation\n", |
317 | 318 | "\n", |
318 | 319 | "The way ARIEL keeps track of individuals is not in the form of a list for each generation like it is more usually used in EAs. Normally in EAs, the population is represented as a list holding the \"current alive population\". This means that if you want more detailed data on individuals that did not survive to the end of the evolution loop you do not have that data.\n", |
319 | 320 | "\n", |
|
477 | 478 | "id": "1ec9d1fa", |
478 | 479 | "metadata": {}, |
479 | 480 | "source": [ |
480 | | - "Now that we have the list of the ids of each individual per generation, we can start querying information from the data to get deeper insights. For this example we will extract the mean and best (min) fitness and standard deviation of the fitness per generation. " |
| 481 | + "## 2. Computing fitness statistics per generation\n", |
| 482 | + "\n", |
| 483 | + "Now that we know which individuals were alive in each generation, we can compute:\n", |
| 484 | + "- Mean fitness\n", |
| 485 | + "- Standard deviation\n", |
| 486 | + "- Best (minimum) fitness" |
481 | 487 | ] |
482 | 488 | }, |
483 | 489 | { |
|
703 | 709 | "id": "8dba6c51", |
704 | 710 | "metadata": {}, |
705 | 711 | "source": [ |
706 | | - "### Plotting\n", |
| 712 | + "## 3. Plotting\n", |
707 | 713 | "\n", |
708 | 714 | "Now that we have the mean and best fitness and standard deviation per generation, we can use them to plot the fitness progression " |
709 | 715 | ] |
710 | 716 | }, |
711 | 717 | { |
712 | 718 | "cell_type": "code", |
713 | | - "execution_count": 6, |
| 719 | + "execution_count": null, |
714 | 720 | "id": "49ab868e", |
715 | 721 | "metadata": {}, |
716 | 722 | "outputs": [ |
|
729 | 735 | "# Create a copy of dataframe\n", |
730 | 736 | "df = pop_df.copy()\n", |
731 | 737 | "\n", |
732 | | - "# Create mast to avoid missing data \n", |
| 738 | + "# Create mask to avoid missing data \n", |
733 | 739 | "# if the evolution process was done correctly this should not change anything.\n", |
734 | | - "# This mask cold be used to get custom data out of the dataframe\n", |
| 740 | + "# This mask could be used to get custom data out of the dataframe\n", |
735 | 741 | "mask = df['fitness_mean'].notna()\n", |
736 | 742 | "\n", |
737 | 743 | "# Get data according to the mask\n", |
|
0 commit comments