# -*- coding: utf-8 -*-
"""
Created on Thu May  9 23:38:57 2024

@author: Collin
"""

# -*- coding: utf-8 -*-

import numpy as np # array/matrix

#import umap
from sklearn.datasets import load_digits # statistics
from scipy.io import loadmat # math related
import h5py
import matplotlib.pyplot as plt  # plot 
from scipy.io import savemat
import os
# import time

from sklearn.cross_decomposition import PLSRegression
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression

# load data
a = h5py.File('data/m1_hempishere.mat')
metrics = np.array(a['metrics'])
a = h5py.File('data/hemisphere_dataset_gt_1.mat');
labels = np.array(a['groundTruth']).astype(int).flatten() #get ground truth
a.close()
# labels[labels == -1] = 0;
#  pls
D_latent = 3
pls = PLSRegression(n_components=D_latent)
pls.fit(metrics, labels)
Z_train = pls.transform(metrics)
dic = {}
dic['plsCoordinates'] = Z_train;
savemat('data/plsCoordinates.mat',dic) # save to .mat file.