|
299 | 299 | "- The print() function is used to display the result of type(greeting) on the screen." |
300 | 300 | ] |
301 | 301 | }, |
302 | | - { |
303 | | - "cell_type": "code", |
304 | | - "execution_count": null, |
305 | | - "id": "f5e8aa5d", |
306 | | - "metadata": {}, |
307 | | - "outputs": [], |
308 | | - "source": [ |
309 | | - "ç" |
310 | | - ] |
311 | | - }, |
312 | 302 | { |
313 | 303 | "cell_type": "code", |
314 | 304 | "execution_count": null, |
|
716 | 706 | }, |
717 | 707 | { |
718 | 708 | "cell_type": "code", |
719 | | - "execution_count": 51, |
| 709 | + "execution_count": null, |
720 | 710 | "id": "5af768f4", |
721 | 711 | "metadata": {}, |
722 | 712 | "outputs": [], |
|
753 | 743 | "metadata": {}, |
754 | 744 | "outputs": [], |
755 | 745 | "source": [ |
756 | | - "np.loadtxt(fname=\"inflammation-01.csv\", delimiter=\",\")" |
| 746 | + "np.loadtxt(fname=\"data/inflammation-01.csv\", delimiter=\",\")" |
757 | 747 | ] |
758 | 748 | }, |
759 | 749 | { |
|
784 | 774 | "metadata": {}, |
785 | 775 | "outputs": [], |
786 | 776 | "source": [ |
787 | | - "data = np.loadtxt(fname=\"inflammation-01.csv\", delimiter=\",\")" |
| 777 | + "data = np.loadtxt(fname=\"data/inflammation-01.csv\", delimiter=\",\")" |
788 | 778 | ] |
789 | 779 | }, |
790 | 780 | { |
|
909 | 899 | "print(\"First value in data:\", data[0,0])" |
910 | 900 | ] |
911 | 901 | }, |
| 902 | + { |
| 903 | + "cell_type": "markdown", |
| 904 | + "id": "92bd2173", |
| 905 | + "metadata": {}, |
| 906 | + "source": [ |
| 907 | + "Let's look at a slice of the data" |
| 908 | + ] |
| 909 | + }, |
912 | 910 | { |
913 | 911 | "cell_type": "code", |
914 | 912 | "execution_count": null, |
|
1091 | 1089 | "metadata": {}, |
1092 | 1090 | "outputs": [], |
1093 | 1091 | "source": [ |
1094 | | - "plt.imshow(data, aspect='1', cmap='viridis')\n", |
| 1092 | + "plt.imshow(data, aspect='1', cmap='Spectral_r')\n", |
1095 | 1093 | "# aspect='1' This specifies the aspect ratio of the plot,\n", |
1096 | | - "# cmap='viridis' This specifies the colormap to use, viridis is a sequencial colormap. \n", |
| 1094 | + "# cmap='Spectral_r' This specifies the colormap to use, viridis, and Spectral_r are sequencial colormaps. \n", |
1097 | 1095 | "# 'viridis' is a popular perceptually-uniform colormap that \n", |
1098 | 1096 | "# ranges from dark blue through green to yellow. It's colorblind-friendly and works well for scientific visualization\n", |
1099 | 1097 | "plt.colorbar(label=\"Inflammation Level\") # Adds a color legend\n", |
|
1108 | 1106 | "id": "3edcfe88", |
1109 | 1107 | "metadata": {}, |
1110 | 1108 | "source": [ |
1111 | | - "Storing our average inflammations each day in a variable and then calling that variable in a matplotlib plot and show set of functions.\n" |
| 1109 | + "Storing our average inflammations each day in a variable and then calling that variable in a matplotlib plot and show set of functions.\n", |
| 1110 | + "\n", |
| 1111 | + "`plt.plot()` is a function from the matplotlib.pyplot module in Python, used to create line plots. It is one of the most commonly used plotting functions in Matplotlib.\n" |
1112 | 1112 | ] |
1113 | 1113 | }, |
1114 | 1114 | { |
|
1118 | 1118 | "metadata": {}, |
1119 | 1119 | "outputs": [], |
1120 | 1120 | "source": [ |
| 1121 | + "# Calculate the average inflammation per day across all patients\n", |
1121 | 1122 | "ave_inflammation = np.mean(data, axis=0)\n", |
| 1123 | + "\n", |
| 1124 | + "# Plot the average inflammation\n", |
1122 | 1125 | "plt.plot(ave_inflammation)\n", |
| 1126 | + "\n", |
| 1127 | + "# Display the plot\n", |
1123 | 1128 | "plt.show()" |
1124 | 1129 | ] |
1125 | 1130 | }, |
| 1131 | + { |
| 1132 | + "cell_type": "markdown", |
| 1133 | + "id": "896b5926", |
| 1134 | + "metadata": {}, |
| 1135 | + "source": [ |
| 1136 | + "Here we can see the generated line plot representation of the average inflammation per day across all patients" |
| 1137 | + ] |
| 1138 | + }, |
1126 | 1139 | { |
1127 | 1140 | "cell_type": "markdown", |
1128 | 1141 | "id": "390a3c8b", |
|
1148 | 1161 | "metadata": {}, |
1149 | 1162 | "outputs": [], |
1150 | 1163 | "source": [ |
1151 | | - "print(sorted(glob.glob(\"inflammation*.csv\")))" |
| 1164 | + "print(sorted(glob.glob(\"data/inflammation*.csv\")))" |
1152 | 1165 | ] |
1153 | 1166 | }, |
1154 | 1167 | { |
|
1166 | 1179 | "metadata": {}, |
1167 | 1180 | "outputs": [], |
1168 | 1181 | "source": [ |
1169 | | - "filenames = sorted(glob.glob(\"inflammation*.csv\"))\n", |
| 1182 | + "filenames = sorted(glob.glob(\"data/inflammation*.csv\"))\n", |
1170 | 1183 | "\n", |
1171 | 1184 | "for filename in filenames:\n", |
1172 | 1185 | " print(filename)\n", |
| 1186 | + " # Use NumPy's loadtxt function to load the CSV data from the file specified by 'filename'.\n", |
| 1187 | + " # The 'fname' parameter receives the filename and 'delimiter' is set to a comma since the file is CSV-formatted.\n", |
1173 | 1188 | " data = np.loadtxt(fname=filename, delimiter=\",\")\n", |
1174 | 1189 | " \n", |
1175 | 1190 | " ave_inflammation = np.mean(data, axis=0)\n", |
|
1250 | 1265 | }, |
1251 | 1266 | { |
1252 | 1267 | "cell_type": "code", |
1253 | | - "execution_count": 52, |
| 1268 | + "execution_count": null, |
1254 | 1269 | "id": "ec2af987", |
1255 | 1270 | "metadata": {}, |
1256 | 1271 | "outputs": [], |
|
0 commit comments