combineMethodComparisions_normed.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import pandas as pd
  2. from matplotlib import pyplot as plt
  3. import seaborn as sns
  4. import os
  5. import sys
  6. from regmaxsn.core.matplotlibRCParams import mplPars
  7. sns.set(rc=mplPars)
  8. setNames = ["LCInt", "ALPN", "OPInt", "AA1", "AA2"]
  9. intSetNames = ["LLC", "OMB", "OPSInt", "AA1", "RAL"]
  10. def combinePlotMethodComparisons(inDir):
  11. plt.ion()
  12. allPerfsDF = pd.DataFrame()
  13. for setInd, setName in enumerate(setNames):
  14. intSetName = intSetNames[setInd]
  15. metricsXL = os.path.join(inDir, "{}.xlsx".format(intSetName))
  16. if os.path.isfile(metricsXL):
  17. metricsDFNormed = pd.DataFrame()
  18. metricsDF = pd.read_excel(metricsXL)
  19. for irName, irDF in metricsDF.groupby("Initial Reference"):
  20. standardisedMeasure = float(irDF.loc[lambda df: df["Method"] == "Standardized",
  21. "Occupancy Based Dissimilarity Measure"])
  22. irDF["Occupancy Based Dissimilarity Measure"] /= standardisedMeasure
  23. metricsDFNormed = metricsDFNormed.append(irDF)
  24. metricsDFNormed["Group"] = setName
  25. allPerfsDF = allPerfsDF.append(metricsDFNormed, ignore_index=True)
  26. [darkblue, green, red, violet, yellow, lightblue] = sns.color_palette()
  27. fig1, ax1 = plt.subplots(figsize=(14, 11.2))
  28. sns.barplot(data=allPerfsDF, x="Group", y="Occupancy Based Dissimilarity Measure",
  29. hue='Method', ax=ax1, hue_order=["PCA", "PCA + RobartsICP", "BlastNeuron",
  30. "Reg-MaxS", "Reg-MaxS-N", "Standardized"],
  31. palette=[red, violet, yellow, lightblue, darkblue, green])
  32. ax1.set_ylabel("Occupancy Based Dissimilarity Measure\nNormalized to Standardized")
  33. ax1.set_xticklabels(setNames)
  34. # ax1.text(0, 12, 'n=4', color='r', fontsize=48)
  35. fig1.tight_layout()
  36. return fig1
  37. if __name__ == "__main__":
  38. assert len(sys.argv) == 2, "Improper Usage! Please use as:\n" \
  39. "python {} <directory with performance excel files".format(sys.argv[0])
  40. fig = combinePlotMethodComparisons(sys.argv[1])