Skip to content

Commit

Permalink
Merge pull request #79 from DIDONEproject/tutorials
Browse files Browse the repository at this point in the history
Tutorials colab compatible
  • Loading branch information
CarlosVaquero authored Oct 12, 2024
2 parents b53ca5b + 002a611 commit 2f4ceb6
Showing 1 changed file with 81 additions and 27 deletions.
108 changes: 81 additions & 27 deletions docs/source/Tutorial_poprock.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 37,
"id": "9fdda6bf",
"metadata": {
"scrolled": true
Expand Down Expand Up @@ -78,8 +78,8 @@
"Requirement already satisfied: tabulate>=0.8.10 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from frictionless[pandas,visidata]->ms3==2.4.2->musif) (0.9.0)\n",
"Requirement already satisfied: typer>=0.12 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from frictionless[pandas,visidata]->ms3==2.4.2->musif) (0.12.5)\n",
"Requirement already satisfied: validators>=0.18 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from frictionless[pandas,visidata]->ms3==2.4.2->musif) (0.34.0)\n",
"Requirement already satisfied: pyarrow>=14.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from frictionless[pandas,visidata]->ms3==2.4.2->musif) (17.0.0)\n",
"Requirement already satisfied: visidata>=2.10 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from frictionless[pandas,visidata]->ms3==2.4.2->musif) (3.0.2)\n",
"Requirement already satisfied: pyarrow>=14.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from frictionless[pandas,visidata]->ms3==2.4.2->musif) (17.0.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from requests->music21>=9.1->musif) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from requests->music21>=9.1->musif) (3.7)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from requests->music21>=9.1->musif) (2.2.3)\n",
Expand Down Expand Up @@ -130,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 38,
"id": "85fd7772",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -160,7 +160,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -214,7 +214,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 40,
"id": "48641f97",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -254,7 +254,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 41,
"id": "e5b5d3a0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -301,7 +301,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 42,
"id": "e940c224",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -333,7 +333,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 43,
"id": "f7597151",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -428,7 +428,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 44,
"id": "1e71283e",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -475,7 +475,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 45,
"id": "00ed0bfb",
"metadata": {},
"outputs": [],
Expand All @@ -487,7 +487,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 46,
"id": "08b7b661",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -522,7 +522,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 48,
"id": "6ab4ab25",
"metadata": {
"scrolled": true
Expand All @@ -534,7 +534,7 @@
"(566, 61250)"
]
},
"execution_count": 32,
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -552,12 +552,39 @@
"source": [
"## Post-processing\n",
"\n",
"We will now postprocess the data, again, see the [Getting started tutorial](./Tutorial.html) for more info."
"We will now postprocess the data, see the [Getting started tutorial](./Tutorial.html) for more info."
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "63bb9560",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" import google.colab\n",
" IN_COLAB = True\n",
"except:\n",
" IN_COLAB = False\n",
"\n",
"# Check if in colab\n",
"if IN_COLAB:\n",
" print('in colab')\n",
" import urllib.request\n",
" # Replace with the raw URL of the YAML file on GitHub\n",
" github_url = \"https://raw.githubusercontent.com/DIDONEproject/musif/main/config_postprocess_example.yml\" \n",
" # Replace with the desired local file name\n",
" local_file_name = \"config_postprocess_example.yml\" \n",
" urllib.request.urlretrieve(github_url, local_file_name)\n",
" print(f\"File downloaded to: {local_file_name}\")\n",
"else:\n",
" local_file_name = \"../../config_postprocess_example.yml\" \n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 50,
"id": "527b85cd",
"metadata": {},
"outputs": [
Expand All @@ -575,15 +602,15 @@
"(566, 162)"
]
},
"execution_count": 33,
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from musif.process.processor import DataProcessor\n",
"\n",
"processed_df = DataProcessor(df,'../../config_postprocess_example.yml').process().data\n",
"processed_df = DataProcessor(df,local_file_name).process().data\n",
"\n",
"# with `.shape` you can see the number of rows and columns of the DataFrame.\n",
"processed_df.shape"
Expand All @@ -602,7 +629,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 51,
"id": "6af21fe1",
"metadata": {},
"outputs": [
Expand All @@ -612,7 +639,7 @@
"(566, 162)"
]
},
"execution_count": 34,
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -639,21 +666,48 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 52,
"id": "f65c709c",
"metadata": {
"tags": [
"hide-output"
]
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: scikit-learn in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (1.5.2)\n",
"Requirement already satisfied: seaborn in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (0.13.2)\n",
"Requirement already satisfied: numpy>=1.19.5 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from scikit-learn) (2.1.2)\n",
"Requirement already satisfied: scipy>=1.6.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from scikit-learn) (1.14.1)\n",
"Requirement already satisfied: joblib>=1.2.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from scikit-learn) (1.4.2)\n",
"Requirement already satisfied: threadpoolctl>=3.1.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from scikit-learn) (3.5.0)\n",
"Requirement already satisfied: pandas>=1.2 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from seaborn) (2.2.3)\n",
"Requirement already satisfied: matplotlib!=3.6.1,>=3.4 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from seaborn) (3.9.2)\n",
"Requirement already satisfied: contourpy>=1.0.1 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.3.0)\n",
"Requirement already satisfied: cycler>=0.10 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (0.12.1)\n",
"Requirement already satisfied: fonttools>=4.22.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (4.54.1)\n",
"Requirement already satisfied: kiwisolver>=1.3.1 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (1.4.7)\n",
"Requirement already satisfied: packaging>=20.0 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (24.1)\n",
"Requirement already satisfied: pillow>=8 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (10.4.0)\n",
"Requirement already satisfied: pyparsing>=2.3.1 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (3.1.4)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.4->seaborn) (2.9.0.post0)\n",
"Requirement already satisfied: pytz>=2020.1 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from pandas>=1.2->seaborn) (2024.1)\n",
"Requirement already satisfied: tzdata>=2022.7 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from pandas>=1.2->seaborn) (2024.2)\n",
"Requirement already satisfied: six>=1.5 in /opt/anaconda3/envs/musif_tutorials/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib!=3.6.1,>=3.4->seaborn) (1.16.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install scikit-learn seaborn"
]
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 53,
"id": "bc8a9edb",
"metadata": {},
"outputs": [
Expand All @@ -663,7 +717,7 @@
"<Axes: >"
]
},
"execution_count": 36,
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -710,7 +764,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 54,
"id": "7a9f3f81",
"metadata": {},
"outputs": [
Expand All @@ -720,7 +774,7 @@
"<Axes: >"
]
},
"execution_count": 37,
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -765,7 +819,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 55,
"id": "540550a4",
"metadata": {
"scrolled": false
Expand All @@ -777,7 +831,7 @@
"<Axes: >"
]
},
"execution_count": 38,
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
},
Expand Down

0 comments on commit 2f4ceb6

Please sign in to comment.