diff --git a/Cluster_Analysis.ipynb b/Cluster_Analysis.ipynb index f1dd1446cb9b22367aef0b44e1c6eaab4db27d79..b1a955bd6f19807ba10f2ba3c20bc06ba00ce703 100644 --- a/Cluster_Analysis.ipynb +++ b/Cluster_Analysis.ipynb @@ -27,7 +27,7 @@ "\n", "# sets min and max parameters for ReqMemCPU\n", "LowerlimitGB = 0\n", - "UpperlimitGB = 50" + "UpperlimitGB = 50 # gigs per cpu" ] }, { @@ -40,7 +40,7 @@ "\n", "# sets min and max parameters for AllocCPUS\n", "LowerlimitAllocCPU = 0\n", - "UpperlimitAllocCPU = 50" + "UpperlimitAllocCPU = 50 #cpus" ] }, { @@ -53,7 +53,7 @@ "\n", "# sets min and max parameters for Elapsed\n", "LowerlimitElapsed = 0\n", - "UpperlimitElapsed = 150.02" + "UpperlimitElapsed = 150.02 #in hours - 6.25 days" ] }, { @@ -62,7 +62,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Enter 'none', '0-1', or 'log' as achoice for data nomralization\n", + "# Enter 'none', '0-1', or 'log' as a choice for data nomralization\n", "Data_Normalization_Choice = 'none'" ] }, @@ -274,6 +274,86 @@ " print(clusterpoints[:,0],clusterpoints[:,1])\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Separating the Clusters for 2d Histograms" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# must run\n", + "\n", + "# creates dataset of ReqMemCPU, Elapsed, and AllocCPUS using the parameters in the labels shown above\n", + "\n", + "#Purple\n", + "df_purple = df_clustering[kmeans_cluster.labels_ == 0]\n", + "\n", + "#Green\n", + "df_green = df_clustering[kmeans_cluster.labels_ == 1]\n", + "\n", + "#Red\n", + "df_red = df_clustering[kmeans_cluster.labels_ == 2]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# voluntary\n", + "\n", + "# returns the min and max ReqMemCPU, Elapsed, and AllocCPUS for each cluster using the datasets created above. \n", + "# These are the parameters for the scatter plots of each cluster\n", + "print(\"Purple Cluster\")\n", + "print(\"ReqMemCPU:\", \"min =\",df_purple.ReqMemCPU.min(),\" \",\"max =\",df_purple.ReqMemCPU.max())\n", + "print(\"Elapsed:\", \"min =\",df_purple.Elapsed.min(),\" \",\"max =\",df_purple.Elapsed.max())\n", + "print(\"AllocCPUS:\", \"min =\",df_purple.AllocCPUS.min(),\" \",\"max =\",df_purple.AllocCPUS.max())\n", + "\n", + "print(\"\\nGreen Cluster\")\n", + "print(\"ReqMemCPU:\", \"min =\",df_green.ReqMemCPU.min(),\" \",\"max =\",df_green.ReqMemCPU.max())\n", + "print(\"Elapsed:\", \"min =\",df_green.Elapsed.min(),\" \",\"max =\",df_green.Elapsed.max())\n", + "print(\"AllocCPUS:\", \"min =\",df_green.AllocCPUS.min(),\" \",\"max =\",df_green.AllocCPUS.max())\n", + "\n", + "print(\"\\nRed Cluster\")\n", + "print(\"ReqMemCPU:\", \"min =\",df_red.ReqMemCPU.min(),\" \",\"max =\",df_red.ReqMemCPU.max())\n", + "print(\"Elapsed:\", \"min =\",df_red.Elapsed.min(),\" \",\"max =\",df_red.Elapsed.max())\n", + "print(\"AllocCPUS:\", \"min =\",df_red.AllocCPUS.min(),\" \",\"max =\",df_red.AllocCPUS.max())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# must run\n", + "\n", + "# Creates datasets used to make the 2d histograms that correspond to each cluster scatter plot. \n", + "# The groupby does not change the data, but it does make a small enough dataset\n", + "\n", + "# for purple cluster \n", + "df_purlple_2d1 = df_purple.groupby(['ReqMemCPU','Elapsed']).sum().reset_index()\n", + "df_purlple_2d2 = df_purple.groupby(['AllocCPUS','Elapsed']).sum().reset_index()\n", + "df_purlple_2d3 = df_purple.groupby(['ReqMemCPU','AllocCPUS']).sum().reset_index()\n", + "\n", + "# for green cluster\n", + "df_green_2d1 = df_green.groupby(['ReqMemCPU','Elapsed']).sum().reset_index()\n", + "df_green_2d2 = df_green.groupby(['AllocCPUS','Elapsed']).sum().reset_index()\n", + "df_green_2d3 = df_green.groupby(['ReqMemCPU','AllocCPUS']).sum().reset_index()\n", + "\n", + "# for red cluster\n", + "df_red_2d1 = df_red.groupby(['ReqMemCPU','Elapsed']).sum().reset_index()\n", + "df_red_2d2 = df_red.groupby(['AllocCPUS','Elapsed']).sum().reset_index()\n", + "df_red_2d3 = df_red.groupby(['ReqMemCPU','AllocCPUS']).sum().reset_index()" + ] + }, { "cell_type": "code", "execution_count": null, @@ -284,126 +364,267 @@ "\n", "figure = plt.figure()\n", "\n", - "figure.set_size_inches(20,20)\n", + "figure.set_size_inches(20,40)\n", + "\n", + "# ReqMem/Elapsed 2d Graph\n", + "rqmem_elapsed_clustergraph = figure.add_subplot(5,3,1)\n", "\n", - "# Elapsed/ReqMem 2d Graph\n", - "elapsed_rqmem_clustergraph = figure.add_subplot(3,3,1)\n", - "#figure.suptitle('Runtime per Requested gigs of RAM %i gigs or less'%UpperlimitGB)\n", - "elapsed_rqmem_clustergraph.scatter(df_clustering['ReqMemCPU'],df_clustering['Elapsed'], \n", + "rqmem_elapsed_clustergraph.scatter(df_clustering['ReqMemCPU'],df_clustering['Elapsed'], \n", " c=kmeans_cluster.labels_, cmap='rainbow')\n", - "elapsed_rqmem_clustergraph.scatter(clusterpoints[:,0] ,clusterpoints[:,1], color='black')\n", + "rqmem_elapsed_clustergraph.scatter(clusterpoints[:,0] ,clusterpoints[:,1], color='black')\n", "plt.xlabel('ReqMemCPU(gigs)')\n", "plt.ylabel('Elapsed(hours)')\n", + "plt.title('Runtime/Requested Gigs RAM')\n", "\n", "\n", - "# Elapsed/Alloc 2d Graph\n", - "elapsed_alloc_clustergraph = figure.add_subplot(3,3,2)\n", - "#figure.suptitle('Runtime per Core %i cores or less'%UpperlimitAllocCPU)\n", - "elapsed_alloc_clustergraph.scatter(df_clustering['AllocCPUS'],df_clustering['Elapsed'], \n", + "# Alloc/Elapsed 2d Graph\n", + "alloc_elapsed_clustergraph = figure.add_subplot(5,3,2)\n", + "alloc_elapsed_clustergraph.scatter(df_clustering['AllocCPUS'],df_clustering['Elapsed'], \n", " c=kmeans_cluster.labels_, cmap='rainbow')\n", - "elapsed_alloc_clustergraph.scatter(clusterpoints[:,2] ,clusterpoints[:,1], color='black')\n", + "alloc_elapsed_clustergraph.scatter(clusterpoints[:,2] ,clusterpoints[:,1], color='black')\n", "plt.xlabel('AllocCPUS')\n", "plt.ylabel('Elapsed(hours)')\n", + "plt.title('Runtime/Core')\n", "\n", - "# Alloc/ReqMem 2d Graph\n", - "alloc_rqmem_clustergraph = figure.add_subplot(3,3,3)\n", - "#figure.suptitle('Runtime per Requested gigs of RAM %i gigs or less'%UpperlimitGB)\n", - "alloc_rqmem_clustergraph.scatter(df_clustering['ReqMemCPU'],df_clustering['AllocCPUS'], \n", + "# ReqMem/Alloc 2d Graph\n", + "rqmem_alloc_clustergraph = figure.add_subplot(5,3,3)\n", + "rqmem_alloc_clustergraph.scatter(df_clustering['ReqMemCPU'],df_clustering['AllocCPUS'], \n", " c=kmeans_cluster.labels_, cmap='rainbow')\n", - "elapsed_rqmem_clustergraph.scatter(clusterpoints[:,0] ,clusterpoints[:,2], color='black')\n", + "rqmem_alloc_clustergraph.scatter(clusterpoints[:,0] ,clusterpoints[:,2], color='black')\n", "plt.xlabel('ReqMemCPU(gigs)')\n", "plt.ylabel('AllocCPUS')\n", + "plt.title('Cores/Requested Gigs RAM')\n", "\n", - "###########\n", - "# Alloc/ReqMem 3d Graph\n", - "alloc_reqmem_clustergraph_3d = figure.add_subplot(3,3,4, projection='3d')\n", - "alloc_reqmem_clustergraph_3d.scatter(df_clustering['ReqMemCPU'], df_clustering['AllocCPUS'], df_clustering['Elapsed'], \n", + "########### 3d Graphs\n", + "# ReqMem/Alloc 3d Graph\n", + "rqmem_alloc_clustergraph_3d = figure.add_subplot(5,3,4, projection='3d')\n", + "rqmem_alloc_clustergraph_3d.scatter(df_clustering['ReqMemCPU'], df_clustering['AllocCPUS'], df_clustering['Elapsed'], \n", " c=kmeans_cluster.labels_ ,cmap='rainbow')\n", - "alloc_reqmem_clustergraph_3d.scatter(clusterpoints[:,0] ,clusterpoints[:,2], color='black')\n", - "alloc_reqmem_clustergraph_3d.set_xlabel('ReqMemCPU(gigs')\n", - "alloc_reqmem_clustergraph_3d.set_ylabel('AllocCPUS')\n", - "alloc_reqmem_clustergraph_3d.set_zlabel('Elapsed(hours)')\n", + "rqmem_alloc_clustergraph_3d.scatter(clusterpoints[:,0] ,clusterpoints[:,2], color='black')\n", + "rqmem_alloc_clustergraph_3d.set_xlabel('ReqMemCPU(gigs')\n", + "rqmem_alloc_clustergraph_3d.set_ylabel('AllocCPUS')\n", + "rqmem_alloc_clustergraph_3d.set_zlabel('Elapsed(hours)')\n", "\n", "# sets size and color for gridlines by axis\n", - "alloc_reqmem_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "alloc_reqmem_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "alloc_reqmem_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "rqmem_alloc_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "rqmem_alloc_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "rqmem_alloc_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", "\n", "\n", - "# Elapsed/Alloc 3d Graph\n", - "elapsed_alloc_clustergraph_3d = figure.add_subplot(3,3,5, projection='3d')\n", - "elapsed_alloc_clustergraph_3d.scatter(df_clustering['AllocCPUS'], df_clustering['ReqMemCPU'], df_clustering['Elapsed'], \n", + "# Alloc/Elapsed 3d Graph\n", + "alloc_elapsed_clustergraph_3d = figure.add_subplot(5,3,5, projection='3d')\n", + "alloc_elapsed_clustergraph_3d.scatter(df_clustering['AllocCPUS'], df_clustering['ReqMemCPU'], df_clustering['Elapsed'], \n", " c=kmeans_cluster.labels_ ,cmap='rainbow')\n", - "elapsed_alloc_clustergraph_3d.scatter(clusterpoints[:,2] ,clusterpoints[:,1], color='black')\n", - "elapsed_alloc_clustergraph_3d.set_xlabel('AllocCPUS')\n", - "elapsed_alloc_clustergraph_3d.set_ylabel('ReqMemCPU(gigs)')\n", - "elapsed_alloc_clustergraph_3d.set_zlabel('Elapsed(hours)')\n", + "alloc_elapsed_clustergraph_3d.scatter(clusterpoints[:,2] ,clusterpoints[:,1], color='black')\n", + "alloc_elapsed_clustergraph_3d.set_xlabel('AllocCPUS')\n", + "alloc_elapsed_clustergraph_3d.set_ylabel('ReqMemCPU(gigs)')\n", + "alloc_elapsed_clustergraph_3d.set_zlabel('Elapsed(hours)')\n", "\n", - "elapsed_alloc_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_alloc_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_alloc_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "alloc_elapsed_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "alloc_elapsed_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "alloc_elapsed_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", "\n", "\n", "\n", - "# Elapsed/ReqMem 3d Graph\n", - "elapsed_rqmem_clustergraph_3d = figure.add_subplot(3,3,6, projection='3d')\n", - "elapsed_rqmem_clustergraph_3d.scatter(df_clustering['ReqMemCPU'], df_clustering['Elapsed'], df_clustering['AllocCPUS'], \n", + "# ReqMem/Elapsed 3d Graph\n", + "rqmem_elapsed_clustergraph_3d = figure.add_subplot(5,3,6, projection='3d')\n", + "rqmem_elapsed_clustergraph_3d.scatter(df_clustering['ReqMemCPU'], df_clustering['Elapsed'], df_clustering['AllocCPUS'], \n", " c=kmeans_cluster.labels_ ,cmap='rainbow')\n", - "elapsed_rqmem_clustergraph_3d.scatter(clusterpoints[:,0] ,clusterpoints[:,1], color='black')\n", + "rqmem_elapsed_clustergraph_3d.scatter(clusterpoints[:,0] ,clusterpoints[:,1], color='black')\n", + "\n", + "rqmem_elapsed_clustergraph_3d.set_xlabel('ReqMemCPU(gigs)')\n", + "rqmem_elapsed_clustergraph_3d.set_ylabel('Elapsed(hours)')\n", + "rqmem_elapsed_clustergraph_3d.set_zlabel('AllocCPUS')\n", + "\n", + "rqmem_elapsed_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "rqmem_elapsed_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "rqmem_elapsed_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "\n", + "\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Creating bins \n", + "\n", + "####Purple\n", + "purple_rqmem_min = np.min(df_purple.ReqMemCPU.min())\n", + "purple_rqmem_max = np.max(df_purple.ReqMemCPU.max())\n", + " \n", + "purple_elapsed_min = np.min(df_purple.Elapsed.min()) \n", + "purple_elapsed_max = np.max(df_purple.Elapsed.max()) \n", + "\n", + "purple_alloc_min = np.min(df_purple.AllocCPUS.min()) \n", + "purple_alloc_max = np.max(df_purple.AllocCPUS.max())\n", + " \n", + " \n", + "x_purple_rqmem_elapsed_bins = list(range(purple_rqmem_max))\n", + "y_purple_rqmem_elapsed_bins = list(range(int(purple_elapsed_max)))\n", "\n", - "elapsed_rqmem_clustergraph_3d.set_xlabel('ReqMemCPU(gigs)')\n", - "elapsed_rqmem_clustergraph_3d.set_ylabel('Elapsed(hours)')\n", - "elapsed_rqmem_clustergraph_3d.set_zlabel('AllocCPUS')\n", + "x_purple_alloc_elapsed_bins = list(range(purple_alloc_max))\n", + "y_purple_alloc_elapsed_bins = list(range(int(purple_elapsed_max))) \n", "\n", - "elapsed_rqmem_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_rqmem_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_rqmem_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "x_purple_reqmem_alloc_bins = list(range(purple_rqmem_max))\n", + "y_purple_reqmem_alloc_bins = list(range(int(purple_alloc_max))) \n", "\n", "\n", - "##############\n", - "# Alloc/ReqMem 3d Graph\n", - "alloc_reqmem_clustergraph_3d = figure.add_subplot(3,3,7, projection='3d')\n", - "alloc_reqmem_clustergraph_3d.scatter(df_clustering['ReqMemCPU'], df_clustering['AllocCPUS'], df_clustering['Elapsed'], \n", - " c=kmeans_cluster.labels_ ,cmap='rainbow', alpha = .08)\n", - "alloc_reqmem_clustergraph_3d.scatter(clusterpoints[:,0] ,clusterpoints[:,2], color='black')\n", - "alloc_reqmem_clustergraph_3d.set_xlabel('ReqMemCPU(gigs')\n", - "alloc_reqmem_clustergraph_3d.set_ylabel('AllocCPUS')\n", - "alloc_reqmem_clustergraph_3d.set_zlabel('Elapsed(hours)')\n", + "####Green\n", + "green_rqmem_min = np.min(df_green.ReqMemCPU.min())\n", + "green_rqmem_max = np.max(df_green.ReqMemCPU.max())\n", + " \n", + "green_elapsed_min = np.min(df_green.Elapsed.min()) \n", + "green_elapsed_max = np.max(df_green.Elapsed.max()) \n", "\n", - "# sets size and color for gridlines by axis\n", - "alloc_reqmem_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "alloc_reqmem_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "alloc_reqmem_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", + "green_alloc_min = np.min(df_green.AllocCPUS.min()) \n", + "green_alloc_max = np.max(df_green.AllocCPUS.max())\n", + " \n", + " \n", + "x_green_rqmem_elapsed_bins = list(range(green_rqmem_max))\n", + "y_green_rqmem_elapsed_bins = list(range(int(green_elapsed_max)))\n", "\n", + "x_green_alloc_elapsed_bins = list(range(green_alloc_max))\n", + "y_green_alloc_elapsed_bins = list(range(int(green_elapsed_max))) \n", "\n", - "# Elapsed/Alloc 3d Graph\n", - "elapsed_alloc_clustergraph_3d = figure.add_subplot(3,3,8, projection='3d')\n", - "elapsed_alloc_clustergraph_3d.scatter(df_clustering['AllocCPUS'], df_clustering['ReqMemCPU'], df_clustering['Elapsed'], \n", - " c=kmeans_cluster.labels_ ,cmap='rainbow', alpha = .08)\n", - "elapsed_alloc_clustergraph_3d.scatter(clusterpoints[:,2] ,clusterpoints[:,1], color='black')\n", - "elapsed_alloc_clustergraph_3d.set_xlabel('AllocCPUS')\n", - "elapsed_alloc_clustergraph_3d.set_ylabel('ReqMemCPU(gigs)')\n", - "elapsed_alloc_clustergraph_3d.set_zlabel('Elapsed(hours)')\n", + "x_green_reqmem_alloc_bins = list(range(green_rqmem_max))\n", + "y_green_reqmem_alloc_bins = list(range(int(green_alloc_max))) \n", "\n", - "elapsed_alloc_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_alloc_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_alloc_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", "\n", + "####Red\n", + "red_rqmem_min = np.min(df_red.ReqMemCPU.min())\n", + "red_rqmem_max = np.max(df_red.ReqMemCPU.max())\n", + " \n", + "red_elapsed_min = np.min(df_red.Elapsed.min()) \n", + "red_elapsed_max = np.max(df_red.Elapsed.max()) \n", "\n", + "red_alloc_min = np.min(df_red.AllocCPUS.min()) \n", + "red_alloc_max = np.max(df_red.AllocCPUS.max())\n", + " \n", + " \n", + "x_red_rqmem_elapsed_bins = list(range(red_rqmem_max))\n", + "y_red_rqmem_elapsed_bins = list(range(int (red_elapsed_max)))\n", "\n", - "# Elapsed/ReqMem 3d Graph\n", - "elapsed_rqmem_clustergraph_3d = figure.add_subplot(3,3,9, projection='3d')\n", - "elapsed_rqmem_clustergraph_3d.scatter(df_clustering['ReqMemCPU'], df_clustering['Elapsed'], df_clustering['AllocCPUS'], \n", - " c=kmeans_cluster.labels_ ,cmap='rainbow', alpha = .08)\n", - "elapsed_rqmem_clustergraph_3d.scatter(clusterpoints[:,0] ,clusterpoints[:,1], color='black')\n", + "x_red_alloc_elapsed_bins = list(range(red_alloc_max))\n", + "y_red_alloc_elapsed_bins = list(range(int (red_elapsed_max)))\n", "\n", - "elapsed_rqmem_clustergraph_3d.set_xlabel('ReqMemCPU(gigs)')\n", - "elapsed_rqmem_clustergraph_3d.set_ylabel('Elapsed(hours)')\n", - "elapsed_rqmem_clustergraph_3d.set_zlabel('AllocCPUS')\n", + "x_red_reqmem_alloc_bins = list(range(red_rqmem_max)) # list range gives one bin per gig\n", + "y_red_reqmem_alloc_bins = list(range(red_alloc_max)) # list range gives one bin per cpu" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plt.figure()\n", + "fig.set_size_inches(20,20)\n", + "\n", + "#####Green\n", + "ax = fig.add_subplot(331)\n", + "rqmem_elapsed_green_hist = ax.hist2d(df_green_2d1['ReqMemCPU'],df_green_2d1['Elapsed'], \n", + " bins =[x_green_rqmem_elapsed_bins, y_green_rqmem_elapsed_bins], \n", + " cmap = plt.cm.Blues)\n", + "ax.set_xlabel('ReqMemCPU(gigs)')\n", + "ax.set_ylabel('Elapsed(hours)')\n", + "ax.set_title('Green Cluster')\n", + "ax.set_xlim(0,40)\n", + "ax.set_ylim(0,140)\n", + "\n", + "\n", + "ax2 = fig.add_subplot(332)\n", + "alloc_elapsed_green_hist = ax2.hist2d(df_green_2d2['AllocCPUS'],df_green_2d2['Elapsed'], \n", + " bins =[x_green_alloc_elapsed_bins, y_green_alloc_elapsed_bins],\n", + " cmap = plt.cm.Blues)\n", + "ax2.set_xlabel('AllocCPUS')\n", + "ax2.set_ylabel('Elapsed(hours)')\n", + "ax2.set_title('Green Cluster')\n", + "ax2.set_xlim(0,40)\n", + "ax2.set_ylim(0,140)\n", + "\n", + "\n", + "ax3 = fig.add_subplot(333)\n", + "reqmem_alloc_green_hist = ax3.hist2d(df_green_2d3['ReqMemCPU'],df_green_2d3['AllocCPUS'], \n", + " bins =[x_green_reqmem_alloc_bins, y_green_reqmem_alloc_bins],\n", + " cmap = plt.cm.Blues)\n", + "ax3.set_xlabel('ReqMemCPU(gigs)')\n", + "ax3.set_ylabel('AllocCPUS')\n", + "ax3.set_title('Green Cluster')\n", + "ax3.set_xlim(0,40)\n", + "ax3.set_ylim(0,140)\n", + "\n", + " \n", + "####Purple\n", + "ax4 = fig.add_subplot(334) # This represents a (3x3) grid (row x col) and we are plotting the (1) subplot. The last number increments row-wise.\n", + "rqmem_elapsed_purple_hist = ax4.hist2d(df_purlple_2d1['ReqMemCPU'],df_purlple_2d1['Elapsed'], \n", + " bins =[x_purple_rqmem_elapsed_bins, y_purple_rqmem_elapsed_bins], \n", + " cmap = plt.cm.Blues)\n", + "ax4.set_xlabel('ReqMemCPU(gigs)')\n", + "ax4.set_ylabel('Elapsed(hours)')\n", + "ax4.set_title('Purple Cluster')\n", + "ax4.set_xlim(0,40)\n", + "ax4.set_ylim(0,140)\n", + "\n", + "\n", + "ax5 = fig.add_subplot(335) # Second subplot\n", + "alloc_elapsed_purple_hist = ax5.hist2d(df_purlple_2d2['AllocCPUS'],df_purlple_2d2['Elapsed'], \n", + " bins =[x_purple_alloc_elapsed_bins, y_purple_alloc_elapsed_bins], \n", + " cmap = plt.cm.Blues)\n", + "ax5.set_xlabel('AllocCPUS')\n", + "ax5.set_ylabel('Elapsed(hours)')\n", + "ax5.set_title('Purple Cluster')\n", + "ax5.set_xlim(0,40)\n", + "ax5.set_ylim(0,140)\n", + "\n", + "\n", + "ax6 = fig.add_subplot(336)\n", + "reqmem_alloc_purple_hist = ax6.hist2d(df_purlple_2d3['ReqMemCPU'],df_purlple_2d3['AllocCPUS'], \n", + " bins =[x_purple_reqmem_alloc_bins, y_purple_reqmem_alloc_bins], \n", + " cmap = plt.cm.Blues) # use magma or\n", + "ax6.set_xlabel('ReqMemCPU(gigs)')\n", + "ax6.set_ylabel('AllocCPUS')\n", + "ax6.set_title('Purple Cluster')\n", + "ax6.set_xlim(0,40)\n", + "ax6.set_ylim(0,140)\n", + "\n", + "\n", + "#####Red\n", + "ax7 = fig.add_subplot(337)\n", + "rqmem_elapsed_red_hist = ax7.hist2d(df_red_2d1['ReqMemCPU'],df_red_2d1['Elapsed'], \n", + " bins =[x_red_rqmem_elapsed_bins, y_red_rqmem_elapsed_bins],\n", + " cmap = plt.cm.Blues)\n", + "ax7.set_xlabel('ReqMemCPU(gigs)')\n", + "ax7.set_ylabel('Elapsed(hours)')\n", + "ax7.set_title('Red Cluster')\n", + "ax7.set_xlim(0,40)\n", + "ax7.set_ylim(0,140)\n", + "\n", + "\n", + "ax8 = fig.add_subplot(338)\n", + "alloc_elapsed_red_hist = ax8.hist2d(df_red_2d2['AllocCPUS'],df_red_2d2['Elapsed'], \n", + " bins =[x_red_reqmem_alloc_bins, y_red_reqmem_alloc_bins],\n", + " cmap = plt.cm.Blues)\n", + "ax8.set_xlabel('AllocCPUS')\n", + "ax8.set_ylabel('Elapsed(hours)')\n", + "ax8.set_title('Red Cluster')\n", + "ax8.set_xlim(0,40)\n", + "ax8.set_ylim(0,140)\n", + "\n", + "\n", + "ax9 = fig.add_subplot(339)\n", + "reqmem_alloc_red_hist = ax9.hist2d(df_red_2d3['ReqMemCPU'],df_red_2d3['AllocCPUS'], \n", + " bins =[x_red_reqmem_alloc_bins, y_red_reqmem_alloc_bins],\n", + " cmap = plt.cm.Blues)\n", + "ax9.set_xlabel('ReqMemCPU(gigs)')\n", + "ax9.set_ylabel('AllocCPUS')\n", + "ax9.set_title('Red Cluster')\n", + "ax9.set_xlim(0,40)\n", + "ax9.set_ylim(0,140)\n", "\n", - "elapsed_rqmem_clustergraph_3d.xaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_rqmem_clustergraph_3d.yaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", - "elapsed_rqmem_clustergraph_3d.zaxis._axinfo[\"grid\"].update({\"linewidth\":.5, \"color\" : \"black\"})\n", "\n", "\n", "# sets the spacing\n", @@ -411,6 +632,151 @@ "# left = space to the left\n", "# wspace = padding on both sides of graphs\n", "# hspace = padding on top and bottom of graphs\n", + "\n", + "figure.subplots_adjust(left=0.0, wspace=0.2, top=.92, hspace=0.3)\n", + "figure.suptitle('Clusters', fontsize=20)\n", + "\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Creating bins \n", + "\n", + "#### Reqmem/Elapsed\n", + "x_rqmem_elapsed_min = np.min(LowerlimitGB)\n", + "x_rqmem_elapsed_max = np.max(UpperlimitGB)\n", + " \n", + "y_rqmem_elapsed_min = np.min(LowerlimitElapsed) \n", + "y_rqmem_elapsed_max = np.max(UpperlimitElapsed) \n", + " \n", + "x_rqmem_elapsed_bins = np.linspace(x_rqmem_elapsed_min, x_rqmem_elapsed_max, 50) \n", + "y_rqmem_elapsed_bins = np.linspace(y_rqmem_elapsed_min, y_rqmem_elapsed_max, 20) \n", + "\n", + "####Alloc/Elapsed\n", + "x_alloc_elapsed_min = np.min(LowerlimitAllocCPU)\n", + "x_alloc_elapsed_max = np.max(UpperlimitAllocCPU)\n", + " \n", + "y_alloc_elapsed_min = np.min(LowerlimitElapsed) \n", + "y_alloc_elapsed_max = np.max(UpperlimitElapsed)\n", + "\n", + "x_alloc_elapsed_bins = np.linspace(x_alloc_elapsed_min, x_alloc_elapsed_max, 50) \n", + "y_alloc_elapsed_bins = np.linspace(y_alloc_elapsed_min, y_alloc_elapsed_max, 20) \n", + "\n", + "\n", + "###Alloc/Reqmem\n", + "x_reqmem_alloc_min = np.min(LowerlimitGB)\n", + "x_reqmem_alloc_max = np.max(UpperlimitGB)\n", + " \n", + "y_reqmem_alloc_min = np.min(LowerlimitAllocCPU) \n", + "y_reqmem_alloc_max = np.max(UpperlimitAllocCPU)\n", + "\n", + "x_reqmem_alloc_bins = np.linspace(x_reqmem_alloc_min, x_reqmem_alloc_max, 50) \n", + "y_reqmem_alloc_bins = np.linspace(y_reqmem_alloc_min, y_reqmem_alloc_max, 20) \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plt.figure()\n", + "fig.set_size_inches(20,20)\n", + " \n", + "####Purple\n", + "ax = fig.add_subplot(331) # This represents a (3x3) grid (row x col) and we are plotting the (1) subplot. The last number increments row-wise.\n", + "rqmem_elapsed_purple_hist = ax.hist2d(df_purlple_2d1['ReqMemCPU'],df_purlple_2d1['Elapsed'], \n", + " bins =[x_rqmem_elapsed_bins, y_rqmem_elapsed_bins], \n", + " cmap = plt.cm.Greys)\n", + "ax.set_xlabel('ReqMemCPU(gigs)')\n", + "ax.set_ylabel('Elapsed(hours)')\n", + "ax.set_title('Purple Cluster')\n", + "\n", + "\n", + "ax2 = fig.add_subplot(332) # Second subplot\n", + "alloc_elapsed_purple_hist = ax2.hist2d(df_purlple_2d2['AllocCPUS'],df_purlple_2d2['Elapsed'], \n", + " bins =[x_alloc_elapsed_bins, y_alloc_elapsed_bins], \n", + " cmap = plt.cm.Greys)\n", + "ax2.set_xlabel('AllocCPUS')\n", + "ax2.set_ylabel('Elapsed(hours)')\n", + "ax2.set_title('Purple Cluster')\n", + "\n", + "\n", + "ax3 = fig.add_subplot(333)\n", + "reqmem_alloc_purple_hist = ax3.hist2d(df_purlple_2d3['ReqMemCPU'],df_purlple_2d3['AllocCPUS'], \n", + " bins =[x_reqmem_alloc_bins, y_reqmem_alloc_bins], \n", + " cmap = plt.cm.Greys) # use magma or\n", + "ax3.set_xlabel('ReqMemCPU(gigs)')\n", + "ax3.set_ylabel('AllocCPUS')\n", + "ax3.set_title('Purple Cluster')\n", + "\n", + "\n", + "#####Green\n", + "ax4 = fig.add_subplot(334)\n", + "rqmem_elapsed_green_hist = ax4.hist2d(df_green_2d1['ReqMemCPU'],df_green_2d1['Elapsed'], \n", + " bins =[x_rqmem_elapsed_bins, y_rqmem_elapsed_bins], \n", + " cmap = plt.cm.Greys)\n", + "ax4.set_xlabel('ReqMemCPU(gigs)')\n", + "ax4.set_ylabel('Elapsed(hours)')\n", + "ax4.set_title('Green Cluster')\n", + "\n", + "\n", + "ax5 = fig.add_subplot(335)\n", + "alloc_elapsed_green_hist = ax5.hist2d(df_green_2d2['AllocCPUS'],df_green_2d2['Elapsed'], \n", + " bins =[x_alloc_elapsed_bins, y_alloc_elapsed_bins],\n", + " cmap = plt.cm.Greys)\n", + "ax5.set_xlabel('AllocCPUS')\n", + "ax5.set_ylabel('Elapsed(hours)')\n", + "ax5.set_title('Green Cluster')\n", + "\n", + "\n", + "ax6 = fig.add_subplot(336)\n", + "reqmem_alloc_green_hist = ax6.hist2d(df_green_2d3['ReqMemCPU'],df_green_2d3['AllocCPUS'], \n", + " bins =[x_reqmem_alloc_bins, y_reqmem_alloc_bins],\n", + " cmap = plt.cm.Greys)\n", + "ax6.set_xlabel('ReqMemCPU(gigs)')\n", + "ax6.set_ylabel('AllocCPUS')\n", + "ax6.set_title('Green Cluster')\n", + "\n", + "\n", + "#####Red\n", + "ax7 = fig.add_subplot(337)\n", + "rqmem_elapsed_red_hist = ax7.hist2d(df_red_2d1['ReqMemCPU'],df_red_2d1['Elapsed'], \n", + " bins =[x_rqmem_elapsed_bins, y_rqmem_elapsed_bins],\n", + " cmap = plt.cm.Greys)\n", + "ax7.set_xlabel('ReqMemCPU(gigs)')\n", + "ax7.set_ylabel('Elapsed(hours)')\n", + "ax7.set_title('Red Cluster')\n", + "\n", + "\n", + "ax8 = fig.add_subplot(338)\n", + "alloc_elapsed_red_hist = ax8.hist2d(df_red_2d2['AllocCPUS'],df_red_2d2['Elapsed'], \n", + " bins =[x_reqmem_alloc_bins, y_reqmem_alloc_bins],\n", + " cmap = plt.cm.Greys)\n", + "ax8.set_xlabel('AllocCPUS')\n", + "ax8.set_ylabel('Elapsed(hours)')\n", + "ax8.set_title('Red Cluster')\n", + "\n", + "\n", + "ax9 = fig.add_subplot(339)\n", + "reqmem_alloc_red_hist = ax9.hist2d(df_red_2d3['ReqMemCPU'],df_red_2d3['AllocCPUS'], \n", + " bins =[x_reqmem_alloc_bins, y_reqmem_alloc_bins],\n", + " cmap = plt.cm.Greys)\n", + "ax9.set_xlabel('ReqMemCPU(gigs)')\n", + "ax9.set_ylabel('AllocCPUS')\n", + "ax9.set_title('Red Cluster')\n", + "\n", + "# sets the spacing\n", + "# top = space between title and graphs - increase number to bring title down and decrease to bring title up\n", + "# left = space to the left\n", + "# wspace = padding on both sides of graphs\n", + "# hspace = padding on top and bottom of graphs\n", + "\n", "figure.subplots_adjust(left=0.0, wspace=0.2, top=.92, hspace=0.3)\n", "figure.suptitle('Clusters', fontsize=20)\n", "\n",