|
|
@@ -223,11 +223,19 @@ def plotCloud(data0, data1, dataNew=None, outputFile=None, title="", doShow=True
|
|
|
Does a PCA analysis of the given data and plot the both important axis.
|
|
|
"""
|
|
|
|
|
|
+ if data0.shape[0] > 0:
|
|
|
+ if data1.shape[0] > 0:
|
|
|
+ data = np.concatenate([data0, data1])
|
|
|
+ else:
|
|
|
+ data = data0
|
|
|
+ else:
|
|
|
+ data = data1
|
|
|
+
|
|
|
# Normalizes the data.
|
|
|
if dataNew is None:
|
|
|
- data_t = StandardScaler().fit_transform(np.concatenate([data0, data1]))
|
|
|
+ data_t = StandardScaler().fit_transform(data)
|
|
|
else:
|
|
|
- data_t = StandardScaler().fit_transform(np.concatenate([data0, data1, dataNew]))
|
|
|
+ data_t = StandardScaler().fit_transform(np.concatenate([data, dataNew]))
|
|
|
|
|
|
|
|
|
# Run the PCA analysis.
|
|
|
@@ -248,7 +256,12 @@ def plotCloud(data0, data1, dataNew=None, outputFile=None, title="", doShow=True
|
|
|
|
|
|
m = 0
|
|
|
n = len(data0)
|
|
|
- doSubplot(m, n, "gray")
|
|
|
+ labels = []
|
|
|
+ if n > 0:
|
|
|
+ labels = ["majority", "minority"]
|
|
|
+ doSubplot(m, n, "gray")
|
|
|
+ else:
|
|
|
+ labels = ["data"]
|
|
|
|
|
|
m += n
|
|
|
n = len(data1)
|
|
|
@@ -257,9 +270,10 @@ def plotCloud(data0, data1, dataNew=None, outputFile=None, title="", doShow=True
|
|
|
if dataNew is not None:
|
|
|
m += n
|
|
|
n = len(dataNew)
|
|
|
+ labels.append("synthetic")
|
|
|
doSubplot(m, n, "blue")
|
|
|
|
|
|
- ax.legend(title="", loc='upper left', labels=['majority', 'minority', 'synthetic minority'])
|
|
|
+ ax.legend(title="", loc='upper left', labels=labels)
|
|
|
ax.set_xlabel("PCA0")
|
|
|
ax.set_ylabel("PCA1")
|
|
|
if doShow:
|