/usr/bin/irelief-sigma is in python-mlpy 2.2.0~dfsg1-3build2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/python
from numpy import *
from optparse import OptionParser
from mlpy import *
# Command line parsing
parser = OptionParser()
parser.add_option("-d", "--data", metavar = "FILE", action = "store", type = "string",
dest = "data", help = "data - required")
parser.add_option("-t", "--theta", action = "store", type = "float",
dest = "theta", help = "theta (default 0.001)", default=0.001)
parser.add_option("-s", "--standardize", action = "store_true", default = False,
dest = "stand", help = "standardize data")
parser.add_option("-n", "--normalize", action = "store_true", default = False,
dest = "norm", help = "normalize data")
parser.add_option("-m", "--min", action = "store", type = "float",
dest = "min", help = "min value (default -5)", default = -5)
parser.add_option("-M", "--max", action = "store", type = "float",
dest = "max", help = "max value (default 5)", default = 5)
parser.add_option("-p", "--steps", action = "store", type = "int",
dest = "steps", help = "steps (default 11)", default = 11)
parser.add_option("-e", "--scale", action = "store", type = "string",
dest = "scale", help = "scale (lin or log, default log)", default = "log")
(options, args) = parser.parse_args()
if not options.data:
parser.error("option -d (data) is required")
if not options.scale in ["lin", "log"]:
parser.error("option -e (scale) should be 'lin' or 'log'")
# Sigma values, max loops
if options.scale == 'lin':
sigma = linspace(options.min, options.max, options.steps)
elif options.scale == 'log':
sigma = logspace(options.min, options.max, options.steps)
T = 20
# Data
x, y = data_fromfile(options.data)
if options.stand:
x = data_standardize(x)
if options.norm:
x = data_normalize(x)
print "samples:", x.shape[0]
print "features:", x.shape[1]
# Try sigmas
print "theta %f" % options.theta
for s in sigma:
ir = Irelief(T = T, sigma = s, theta = options.theta)
try:
ir.weights(x, y)
except SigmaError, e:
print "sigma %e: %s" % (s, e)
else:
if T == ir.loops:
print "sigma %e: more than %d loop(s)" % (s, ir.loops)
else:
print "sigma %e: %d loop(s)" % (s, ir.loops)
|