#!/usr/bin/env python

import numpy as np
import sys
from sklearn import preprocessing
from sklearn.svm import SVC

from ism_pkg.tools.load_data import load_data
from ism_pkg.ism import ism


np.set_printoptions(precision=4)
np.set_printoptions(threshold=sys.maxsize)
np.set_printoptions(linewidth=300)
np.set_printoptions(suppress=True)



data_name = 'cancer'
[X,Y,X_test,Y_test] = load_data(data_name)
I = ism(debug_mode=True, stochastic=True, batch_size_per_class=50, var_percentage=0.8) # Cancer setting
I.fit(X, Y)

I.classify_fit(X, Y, I.σ, I.W, classifier_type='svm_stochastic', class_batch_size=80) #'svm', 'HSIC_optimizer', 'svm_stochastic'
[Ŷ, ᘔ] = I.classify_predict(X, Y, W=I.W)
[Ŷᚁ, ᘔᚁ] = I.classify_predict(X_test, Y_test, W=I.W)
print('Train Acc: %.3f, Test Acc: %.3f, Batch size: %d'%(ᘔ, ᘔᚁ, I.db['batch_size_per_class']))


I.classify_fit(X, Y, I.σ, I.W, classifier_type='svm', class_batch_size=20)
[Ŷ, ᘔ] = I.classify_predict(X, Y, W=I.W)
[Ŷᚁ, ᘔᚁ] = I.classify_predict(X_test, Y_test, W=I.W)
print('Train Acc: %.3f, Test Acc: %.3f'%(ᘔ, ᘔᚁ))



