Skip to content

Commit

Permalink
comment print functions in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Mar 19, 2012
1 parent f081ae0 commit aba8078
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
Expand Up @@ -56,9 +56,9 @@ def evaluation_cross_validation_classification(traindat=traindat, label_traindat

# perform cross-validation and print results
result=cross_validation.evaluate()
print "mean:", result.mean
if result.has_conf_int:
print "[", result.conf_int_low, ",", result.conf_int_up, "] with alpha=", result.conf_int_alpha
#print "mean:", result.mean
#if result.has_conf_int:
# print "[", result.conf_int_low, ",", result.conf_int_up, "] with alpha=", result.conf_int_alpha

if __name__=='__main__':
print 'Evaluation CrossValidationClassification'
Expand Down
Expand Up @@ -58,9 +58,9 @@ def evaluation_cross_validation_regression(fm_train=traindat,fm_test=testdat,lab

# perform cross-validation and print results
result=cross_validation.evaluate()
print "mean:", result.mean
if result.has_conf_int:
print "[", result.conf_int_low, ",", result.conf_int_up, "] with alpha=", result.conf_int_alpha
#print "mean:", result.mean
#if result.has_conf_int:
# print "[", result.conf_int_low, ",", result.conf_int_up, "] with alpha=", result.conf_int_alpha

if __name__=='__main__':
print 'Evaluation CrossValidationClassification'
Expand Down
Expand Up @@ -21,7 +21,7 @@
parameter_list = [[traindat,testdat,label_traindat,2.1,1,1e-5,1e-2], \
[traindat,testdat,label_traindat,2.1,1,1e-5,1e-2]]

def evaluation_cross_validation_classification(fm_train=traindat,fm_test=testdat,label_train=label_traindat,\
def evaluation_cross_validation_regression(fm_train=traindat,fm_test=testdat,label_train=label_traindat,\
width=2.1,C=1,epsilon=1e-5,tube_epsilon=1e-2):
from shogun.Evaluation import CrossValidation, CrossValidationResult
from shogun.Evaluation import MeanSquaredError
Expand All @@ -43,7 +43,7 @@ def evaluation_cross_validation_classification(fm_train=traindat,fm_test=testdat

# print all parameter available for modelselection
# Dont worry if yours is not included but, write to the mailing list
kernel.print_modsel_params()
#kernel.print_modsel_params()

labels=Labels(label_train)

Expand Down Expand Up @@ -72,7 +72,7 @@ def evaluation_cross_validation_classification(fm_train=traindat,fm_test=testdat

# print all parameter available for modelselection
# Dont worry if yours is not included but, write to the mailing list
predictor.print_modsel_params()
#predictor.print_modsel_params()

# build parameter tree to select C1 and C2
param_tree_root=ModelSelectionParameters()
Expand All @@ -90,29 +90,29 @@ def evaluation_cross_validation_classification(fm_train=traindat,fm_test=testdat

# perform model selection with selected methods
#print "performing model selection of"
print "parameter tree"
param_tree_root.print_tree()
#print "parameter tree"
#param_tree_root.print_tree()

print "starting model selection"
#print "starting model selection"
# print the current parameter combination, if no parameter nothing is printed
print_state=True
print_state=False
# lock data before since model selection will not change the kernel matrix
# (use with care) This avoids that the kernel matrix is recomputed in every
# iteration of the model search
predictor.data_lock(labels, features_train)
best_parameters=model_selection.select_model(print_state)

# print best parameters
print "best parameters:"
best_parameters.print_tree()
#print "best parameters:"
#best_parameters.print_tree()

# apply them and print result
best_parameters.apply_to_machine(predictor)
result=cross_validation.evaluate()
print "mean:", result.mean
if result.has_conf_int:
print "[", result.conf_int_low, ",", result.conf_int_up, "] with alpha=", result.conf_int_alpha
#print "mean:", result.mean
#if result.has_conf_int:
# print "[", result.conf_int_low, ",", result.conf_int_up, "] with alpha=", result.conf_int_alpha

if __name__=='__main__':
print 'Evaluation CrossValidationClassification'
evaluation_cross_validation_classification(*parameter_list[0])
print 'Modelselection Grid Search LibSVR'
evaluation_cross_validation_regression(*parameter_list[0])
Expand Up @@ -32,7 +32,7 @@ def modelselection_parameter_tree_modular(dummy):

# print all parameter available for modelselection
# Dont worry if yours is not included but, write to the mailing list
power_kernel.print_modsel_params()
#power_kernel.print_modsel_params()

param_power_kernel=ModelSelectionParameters('kernel', power_kernel)
root.append_child(param_power_kernel)
Expand All @@ -45,7 +45,7 @@ def modelselection_parameter_tree_modular(dummy):

# print all parameter available for modelselection
# Dont worry if yours is not included but, write to the mailing list
metric1.print_modsel_params()
#metric1.print_modsel_params()

param_power_kernel_metric1=ModelSelectionParameters('distance', metric1)

Expand All @@ -59,7 +59,7 @@ def modelselection_parameter_tree_modular(dummy):

# print all parameter available for modelselection
# Dont worry if yours is not included but, write to the mailing list
gaussian_kernel.print_modsel_params()
#gaussian_kernel.print_modsel_params()

param_gaussian_kernel=ModelSelectionParameters('kernel', gaussian_kernel)

Expand All @@ -73,7 +73,7 @@ def modelselection_parameter_tree_modular(dummy):

# print all parameter available for modelselection
# Dont worry if yours is not included but, write to the mailing list
ds_kernel.print_modsel_params()
#ds_kernel.print_modsel_params()

param_ds_kernel=ModelSelectionParameters('kernel', ds_kernel)

Expand Down

0 comments on commit aba8078

Please sign in to comment.