-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e45d12
commit bf22487
Showing
3 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sys | ||
import numpy as np | ||
from IO_util import Raw_to_NetCDF | ||
import xarray as xr | ||
|
||
dirname = '../../Data_Analysis/data/' | ||
filename='SSWdata.nc' | ||
|
||
ds = xr.open_dataset(dirname+filename) | ||
|
||
print('total data size',ds["Y_TRUE"].size) | ||
print('size of 2nd cluster by MATLAB',ds["Y_TRUE"].sum()) | ||
print('size of 2nd cluster by C',ds["Y_C"].sum()) | ||
|
||
mismatch = (ds["Y_TRUE"].values != ds["Y_C"].values) | ||
print("inconsistent labels: ",mismatch.sum()) | ||
|
||
#ds.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
import numpy as np | ||
from IO_util import Raw_to_NetCDF | ||
|
||
ndata = 17878 | ||
nfeatures = 252 | ||
|
||
dirname = '../../Data_Analysis/data/' | ||
# Read data points | ||
file1=open(dirname+'SSWdata.bin','rb') | ||
X=np.fromfile(file1) | ||
if sys.byteorder=='little': | ||
X.byteswap(True) | ||
X=X.reshape(ndata,nfeatures) | ||
|
||
# Read python label | ||
file1=open(dirname+'Label_py.bin','rb') | ||
Y_py=np.fromfile(file1,np.int32) | ||
if sys.byteorder=='little': | ||
Y_py.byteswap(True) | ||
|
||
# Read matlab label | ||
file1=open(dirname+'Label_matlab.bin','rb') | ||
Y_matlab=np.fromfile(file1,np.int32) | ||
Y_matlab -= 1 # 1~2 to 0~1 | ||
|
||
# ======================== | ||
# convert the NetCDF format | ||
# ======================== | ||
N_clusters = 2 | ||
N_samples = ndata | ||
N_features = nfeatures | ||
N_repeat = 20 | ||
|
||
initial_ind = np.zeros([N_repeat,N_clusters],dtype=np.int32) | ||
for i in range(N_repeat): | ||
initial_ind[i,:] = np.random.choice(np.arange(N_samples), | ||
N_clusters,replace=False) | ||
|
||
filename='SSWdata.nc' | ||
Raw_to_NetCDF(X,initial_ind,dirname+filename,y_true=Y_matlab) | ||
|