Skip to content
Snippets Groups Projects
Commit 50048945 authored by nikolasph's avatar nikolasph
Browse files

updates

parent 1b5126ae
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ groupStandard.add_argument('-log', action='store_true', help='Use option to acti
groupRGB = parser.add_argument_group('RGB arguments')
groupRGB.add_argument('-RGB', action='store_true', help='Use option to activate RGB')
groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=16)
groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=25)
groupRGB.add_argument('--RGB_CI', metavar='INT', action='store', help='Max Color Intensity [0 to VALUE]', type=int, default=256)
groupRGB.add_argument('-RGB_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
......
......@@ -41,7 +41,7 @@ groupOpt.add_argument('--valueEnd', metavar='INT', action='store', help='End-Val
groupOpt.add_argument('--nCalcs', metavar='INT', action='store', help='Number of calculations between Start and End-Value', type=int)
groupRGB = parser.add_argument_group('RGB arguments')
groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=16)
groupRGB.add_argument('--RGB_Bins', metavar='INT', action='store', help='Number of bins for histogram', type=int, default=25)
groupRGB.add_argument('--RGB_CI', metavar='INT', action='store', help='Max Color Intensity [0 to VALUE]', type=int, default=256)
groupRGB.add_argument('-RGB_NMinMax', action='store_true', help='Use option to actvate MinMax Norm instead of Distribution')
......
......@@ -21,55 +21,17 @@ __date__ = 2016-03-25
parser = argparse.ArgumentParser(
description='This methods permits to execute a multiclass classification with one single view. At this point the used classifier is a RandomForest. The GridSearch permits to vary the number of trees and CrossValidation with k-folds.',
description='This method can be used to replot results from Feature Parameter Optimisation',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
args = parser.parse_args()
args.valueEnd = 5
args.valueStart =75
args.nCalcs = 8
args.name = "Caltech"
args.valueStart = 2
args.valueEnd = 25
args.nCalcs = 5
args.feature = "HOG"
args.param = "HOG_Cluster"
df_feat_res = pd.DataFrame.from_csv(path="D:\\BitBucket\\multiview-machine-learning-omis\\Code\\FeatExtraction\\Results-FeatParaOpt\\2016_03_19-FeatParaOpt-HOG.csv", sep=';')
# Get data from result to show results in plot
# Total time for feature extraction and classification
#tot_time = df_feat_res.b_feat_extr_time.values + df_feat_res.e_cl_time.values
#tot_time = np.asarray(tot_time)
# Time for feature extraction
#feat_time = df_feat_res.b_feat_extr_time.values
#feat_time = np.asarray(feat_time)
# Time for classification
#cl_time = df_feat_res.e_cl_time.values
#cl_time = np.asarray(cl_time)
# Mean Score of all classes
#score = df_feat_res.f_cl_score.values
#score = np.asarray(score)
# Range on X-Axis
#if(args.nCalcs>1):
# step = float(args.valueEnd-args.valueStart)/float(args.nCalcs-1)
# rangeX = np.around(np.array(range(0,args.nCalcs))*step) + args.valueStart
#else:
# rangeX = [args.valueStart]
#rangeX = np.asarray(rangeX)
# Description of Classification
#cl_desc = df_feat_res.c_cl_desc.values
# Description of Feature
#feat_desc = df_feat_res.a_feat_desc.values
#dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatParaOpt/"
#fileName = dir + datetime.datetime.now().strftime("%Y_%m_%d") + "-" + "Feature_" + args.feature + "-Parameter_" + args.param
#store = False
# Show Results for Calculation
#ExportResults.showScoreTime(fileName + "-TotalTime.png", store, score, tot_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation', 'Precision', 'Total Time (Feature Extraction+Classification)\n [s]')
#ExportResults.showScoreTime(fileName + "-FeatExtTime.png", store, score, feat_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation', 'Precision', 'Feature Extraction Time\n [s]')
#ExportResults.showScoreTime(fileName + "-ClassTime.png", store, score, cl_time, rangeX, args.param, feat_desc, cl_desc, 'Results for Parameter Optimisation', 'Precision', 'Classification Time\n [s]')
args.show = False
df_feat_res = pd.DataFrame.from_csv(path="D:\\BitBucket\\multiview-machine-learning-omis\\Results\\Hydra\\2016_03_22-FPO-Caltech-HOG-HOG_Cluster.csv", sep=';')
# Get data from result to show results in plot
......@@ -103,6 +65,10 @@ cl_desc = df_feat_res.c_cl_desc.values
# Description of Feature
feat_desc = df_feat_res.a_feat_desc.values
dir = os.path.dirname(os.path.abspath(__file__)) + "/Results-FeatParaOpt/"
#filename = datetime.datetime.now().strftime("%Y_%m_%d") + "-FPO-" + args.name + "-" + args.feature + "-" + args.param
#ExportResults.exportPandasToCSV(df_feat_res, dir, filename)
# Store or Show plot
if(args.show):
store = False
......
Code/Niko/Results-FeatParaOpt/2016_03_22-FPO-CTMini-RGB-RGB_Bins-ClassTime.png

211 KiB

2016-03-22 16:32:30,171 DEBUG:### Main Programm for Feature Parameter Optimisation
2016-03-22 16:32:30,171 DEBUG:### Optimisation - Feature:RGB Parameter:RGB_Bins from:2 to:30 in #calc:10
2016-03-22 16:32:30,173 DEBUG:### Start: Exportation of images from DB
2016-03-22 16:32:30,434 DEBUG:### Done: Exportation of Images from DB
2016-03-22 16:32:30,434 DEBUG:### Start: Feautre Optimisation
2016-03-22 16:32:30,434 DEBUG:### Start: FeatureExtraction Nr:1 from:10 with RGB_Bins=2 ###
2016-03-22 16:32:30,605 DEBUG:### Done: FeatureExtraction Nr:1 from:10 ###
2016-03-22 16:32:30,607 DEBUG:### Start: Classification Nr:1 from:10
2016-03-22 16:32:33,263 DEBUG:### Done: Classification Nr:1 from:10
2016-03-22 16:32:33,269 DEBUG:### Start: FeatureExtraction Nr:2 from:10 with RGB_Bins=5 ###
2016-03-22 16:32:33,440 DEBUG:### Done: FeatureExtraction Nr:2 from:10 ###
2016-03-22 16:32:33,441 DEBUG:### Start: Classification Nr:2 from:10
2016-03-22 16:32:36,063 DEBUG:### Done: Classification Nr:2 from:10
2016-03-22 16:32:36,068 DEBUG:### Start: FeatureExtraction Nr:3 from:10 with RGB_Bins=8 ###
2016-03-22 16:32:36,236 DEBUG:### Done: FeatureExtraction Nr:3 from:10 ###
2016-03-22 16:32:36,237 DEBUG:### Start: Classification Nr:3 from:10
2016-03-22 16:32:38,921 DEBUG:### Done: Classification Nr:3 from:10
2016-03-22 16:32:38,926 DEBUG:### Start: FeatureExtraction Nr:4 from:10 with RGB_Bins=11 ###
2016-03-22 16:32:39,098 DEBUG:### Done: FeatureExtraction Nr:4 from:10 ###
2016-03-22 16:32:39,099 DEBUG:### Start: Classification Nr:4 from:10
2016-03-22 16:32:41,841 DEBUG:### Done: Classification Nr:4 from:10
2016-03-22 16:32:41,845 DEBUG:### Start: FeatureExtraction Nr:5 from:10 with RGB_Bins=14 ###
2016-03-22 16:32:42,023 DEBUG:### Done: FeatureExtraction Nr:5 from:10 ###
2016-03-22 16:32:42,023 DEBUG:### Start: Classification Nr:5 from:10
2016-03-22 16:32:44,762 DEBUG:### Done: Classification Nr:5 from:10
2016-03-22 16:32:44,769 DEBUG:### Start: FeatureExtraction Nr:6 from:10 with RGB_Bins=18 ###
2016-03-22 16:32:44,950 DEBUG:### Done: FeatureExtraction Nr:6 from:10 ###
2016-03-22 16:32:44,950 DEBUG:### Start: Classification Nr:6 from:10
2016-03-22 16:32:47,818 DEBUG:### Done: Classification Nr:6 from:10
2016-03-22 16:32:47,822 DEBUG:### Start: FeatureExtraction Nr:7 from:10 with RGB_Bins=21 ###
2016-03-22 16:32:48,043 DEBUG:### Done: FeatureExtraction Nr:7 from:10 ###
2016-03-22 16:32:48,045 DEBUG:### Start: Classification Nr:7 from:10
2016-03-22 16:32:51,453 DEBUG:### Done: Classification Nr:7 from:10
2016-03-22 16:32:51,459 DEBUG:### Start: FeatureExtraction Nr:8 from:10 with RGB_Bins=24 ###
2016-03-22 16:32:51,677 DEBUG:### Done: FeatureExtraction Nr:8 from:10 ###
2016-03-22 16:32:51,677 DEBUG:### Start: Classification Nr:8 from:10
2016-03-22 16:32:54,657 DEBUG:### Done: Classification Nr:8 from:10
2016-03-22 16:32:54,661 DEBUG:### Start: FeatureExtraction Nr:9 from:10 with RGB_Bins=27 ###
2016-03-22 16:32:54,859 DEBUG:### Done: FeatureExtraction Nr:9 from:10 ###
2016-03-22 16:32:54,861 DEBUG:### Start: Classification Nr:9 from:10
2016-03-22 16:32:57,914 DEBUG:### Done: Classification Nr:9 from:10
2016-03-22 16:32:57,920 DEBUG:### Start: FeatureExtraction Nr:10 from:10 with RGB_Bins=30 ###
2016-03-22 16:32:58,135 DEBUG:### Done: FeatureExtraction Nr:10 from:10 ###
2016-03-22 16:32:58,138 DEBUG:### Start: Classification Nr:10 from:10
2016-03-22 16:33:01,158 DEBUG:### Done: Classification Nr:10 from:10
2016-03-22 16:33:01,164 DEBUG:### Done: Feautre Optimisation
2016-03-22 16:33:01,164 DEBUG:### Start: Exporting to CSV
2016-03-22 16:33:01,173 DEBUG:### Done: Exporting to CSV
2016-03-22 16:33:01,173 DEBUG:### Start: Plot Result
2016-03-22 16:33:03,180 DEBUG:### Done: Plot Result
Code/Niko/Results-FeatParaOpt/2016_03_22-FPO-CTMini-RGB-RGB_Bins-TotalTime.png

214 KiB

;a_feat_desc;b_feat_extr_time;c_cl_desc;d_cl_res;e_cl_time;f_cl_score
0;CTMini-RGB-Bins_2-MaxCI_256-Norm_Distr;0.168999910355;Classif_RF-CV_8-Trees_100;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.65900015831;0.805194805195
1;CTMini-RGB-Bins_5-MaxCI_256-Norm_Distr;0.171999931335;Classif_RF-CV_8-Trees_50;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.62199997902;0.883116883117
2;CTMini-RGB-Bins_8-MaxCI_256-Norm_Distr;0.167999982834;Classif_RF-CV_8-Trees_100;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.68400001526;0.922077922078
3;CTMini-RGB-Bins_11-MaxCI_256-Norm_Distr;0.171999931335;Classif_RF-CV_8-Trees_50;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.74300003052;0.948051948052
4;CTMini-RGB-Bins_14-MaxCI_256-Norm_Distr;0.177000045776;Classif_RF-CV_8-Trees_50;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.7380001545;0.961038961039
5;CTMini-RGB-Bins_18-MaxCI_256-Norm_Distr;0.180999994278;Classif_RF-CV_8-Trees_100;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.86800003052;0.948051948052
6;CTMini-RGB-Bins_21-MaxCI_256-Norm_Distr;0.22000002861;Classif_RF-CV_8-Trees_100;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";3.40899991989;0.935064935065
7;CTMini-RGB-Bins_24-MaxCI_256-Norm_Distr;0.21799993515;Classif_RF-CV_8-Trees_50;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";2.98099994659;0.935064935065
8;CTMini-RGB-Bins_27-MaxCI_256-Norm_Distr;0.196999788284;Classif_RF-CV_8-Trees_200;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";3.0529999733;0.974025974026
9;CTMini-RGB-Bins_30-MaxCI_256-Norm_Distr;0.214999914169;Classif_RF-CV_8-Trees_100;"GridSearchCV(cv=8, error_score='raise',
estimator=Pipeline(steps=[('classifier', RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=10, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False))]),
fit_params={}, iid=True, loss_func=None, n_jobs=1,
param_grid={'classifier__n_estimators': [50, 100, 150, 200]},
pre_dispatch='2*n_jobs', refit=True, score_func=None,
scoring='accuracy', verbose=0)";3.02300000191;0.961038961039
......@@ -15,12 +15,13 @@ from skimage.feature import hog
from sklearn.cluster import MiniBatchKMeans
import multiprocessing as mp #to count cores https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool
from joblib import Parallel, delayed
import logging # To create Log-Files
# Import own modules
import DBCrawl
# Author-Info
__author__ = "Baptiste Bauvin"
__author__ = "Baptiste Bauvin and co-author Nikolas Huelsmann"
__status__ = "?" # Production, Development, Prototype
__date__ = "?"
......@@ -140,32 +141,32 @@ if __name__ == '__main__':
MAXITER = 100
NB_CORES = mp.cpu_count()
print "Fetching Images in " + path
logging.debug("Fetching Images in " + path)
# get dictionary to link classLabels Text to Integers
sClassLabels = getClassLabels(path)
# # Get all path from all images inclusive classLabel as Integer
dfImages = imgCrawl(path, sClassLabels)
npImages = dfImages.values
extractedTime = time.time()
print "Extracted images in " + str(extractedTime-start) +'sec'
print "Sequencing Images ..."
logging.debug("Extracted images in " + str(extractedTime-start) +'sec')
logging.debug("Sequencing Images ...")
cells = corpusSequencing(npImages, CELL_DIMENSION, NB_CORES)
sequencedTime = time.time()
print "Sequenced images in " + str(sequencedTime-extractedTime) +'sec'
print "Computing gradient on each block ..."
logging.debug("Sequenced images in " + str(sequencedTime-extractedTime) +'sec')
logging.debug("Computing gradient on each block ...")
gradients = computeLocalHistograms(cells, NB_ORIENTATIONS, CELL_DIMENSION, NB_CORES)
hogedTime = time.time()
print "Computed gradients in " + str(hogedTime - sequencedTime) + 'sec'
print "Clustering gradients ..."
logging.debug("Computed gradients in " + str(hogedTime - sequencedTime) + 'sec')
logging.debug("Clustering gradients ...")
gradientLabels, sizes = clusterGradients(gradients, NB_CLUSTERS, MAXITER)
clusteredItme = time.time()
print "Clustered gradients in " + str(hogedTime - sequencedTime) + 'sec'
print "Computing histograms ..."
logging.debug("Clustered gradients in " + str(hogedTime - sequencedTime) + 'sec')
logging.debug("Computing histograms ...")
histograms = makeHistograms(gradientLabels, NB_CLUSTERS, sizes)
end = time.time()
print "Computed histograms in " + str(int(end - hogedTime)) + 'sec'
print "Histogram shape : " +str(histograms.shape)
print "Total time : " + str(end-start) + 'sec'
logging.debug("Computed histograms in " + str(int(end - hogedTime)) + 'sec')
logging.debug("Histogram shape : " +str(histograms.shape))
logging.debug("Total time : " + str(end-start) + 'sec')
#hogs = extractHOGFeature(testNpImages, CELL_DIMENSION, \
# NB_ORIENTATIONS, NB_CLUSTERS, MAXITER)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment