from sklearn.cross_validation import train_test_split
from sklearn.decomposition import RandomizedPCA, SparsePCA, IncrementalPCA
from sklearn.grid_search import GridSearchCV
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import normalize
from hed_bilateral import HedBilateralFilter
from segment_hist import  SegmentStage
from cellcounting import common as com
from cellcounting.features.hog import HOGFeature
from cellcounting.features.lbp import LBP

# Create samples and its label
preprocessor = HedBilateralFilter()
filter_kernel = (7, 7)
preprocessor.set_param("bilateral_kernel", filter_kernel)
preprocessor.set_param("sigma_color", 9)
segment = SegmentStage(5)
hog = HOGFeature()
lbp = LBP(2, 16, "var")
labels = []

def load_list_files(filename):
    """
    load all data form the file of list data
    """
    files = []
    data = []
    hist_data = []
    labels = []
    with open(filename, "r") as f: