from optparse import OptionParser
from run_svm import SVMInterpolant

parser = OptionParser()

parser.add_option(
    '-i', '--input',
    action='store',
    dest='input',
    type='string',
    help='input file of sample points',
)
parser.add_option(
    '-d', '--degree',
    action='store',
    dest='degree',
    type='int',
    default=5,
    help='the polynomial highest degree'
)

parser.add_option(
    '-c', '--C',
    action='store',
    dest='C',
    type='float',
    default=1000,
    help='the soft margin parameter'
)
parser.add_option(
    '-g', '--gamma',
    action='store',
    dest='gamma',
    default=1,
    type='float',
    help='gamma parameter in the polynomial kernel'
)
parser.add_option(
    '-b', '--bias',
    action='store',
    dest='coef0',
    default=1,
    type='float',
    help='bias parameter in the polynomial kernel'
)
parser.add_option(
    '-o', '--output',
    action='store',
    dest='output',
    type='string',
    help='output model path'
)

options, args = parser.parse_args()
interpolant = SVMInterpolant(options.input, options.degree, 'mid_out.model', options.output,
                             options.C, options.gamma, options.coef0)
interpolant.train()
code = interpolant.test()
interpolant.post_process()
with open('.exitcode', mode='w') as exitcode:
    exitcode.write(str(code))
