def new_experiment():
    outmodelpath = '../measuredivergence/results/newexperimentmodels.csv'
    columns = ['name', 'size', 'ratio', 'iteration', 'meandate', 'maxaccuracy', 'features', 'regularization']
    if (not os.path.isfile(outmodelpath)):
        with open(outmodelpath, mode='w', encoding='utf-8') as f:
            scribe = csv.DictWriter(f, fieldnames=columns)
            scribe.writeheader()
    c_range = [1e-05, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100]
    featurestart = 1500
    featureend = 6000
    featurestep = 300
    modelparams = ('logistic', 10, featurestart, featureend, featurestep, c_range)
    sizecap = 75
    for i in range(3, 6):
        for ratio in [0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100]:
            sourcefolder = (('../measuredivergence/mix/' + str(ratio)) + '/')
            metadatapath = (('../measuredivergence/partitionmeta/meta' + str(ratio)) + '.csv')
            name = ((('mixeddata_' + str(i)) + '_') + str(ratio))
            vocabpath = (('../lexica/' + name) + '.txt')
            tags4positive = {'fantasy', 'detective'}
            tags4negative = {'random'}
            floor = 1800
            ceiling = 1930
            (metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist) = versatiletrainer2.get_simple_data(sourcefolder, metadatapath, vocabpath, tags4positive, tags4negative, sizecap, excludebelow=floor, excludeabove=ceiling, force_even_distribution=False, numfeatures=6000)
            (matrix, maxaccuracy, metadata, coefficientuples, features4max, best_regularization_coef) = versatiletrainer2.tune_a_model(metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist, tags4positive, tags4negative, modelparams, name, (('../measuredivergence/newmodeloutput/' + name) + '.csv'))
            meandate = int(round((np.sum(metadata.firstpub) / len(metadata.firstpub))))
            row = dict()
            row['name'] = name
            row['size'] = sizecap
            row['ratio'] = ratio
            row['iteration'] = i
            row['meandate'] = meandate
            row['maxaccuracy'] = maxaccuracy
            row['features'] = features4max
            row['regularization'] = best_regularization_coef
            with open(outmodelpath, mode='a', encoding='utf-8') as f:
                scribe = csv.DictWriter(f, fieldnames=columns)
                scribe.writerow(row)
            os.remove(vocabpath)
        sourcefolder = '../data/'
        metadatapath = '../measuredivergence/partitionmeta/part2.csv'
        name = ('goldfantasy_' + str(i))
        vocabpath = (('../lexica/' + name) + '.txt')
        tags4positive = {'fantasy'}
        tags4negative = {'random', 'randomB'}
        floor = 1800
        ceiling = 1930
        (metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist) = versatiletrainer2.get_simple_data(sourcefolder, metadatapath, vocabpath, tags4positive, tags4negative, sizecap, excludebelow=floor, excludeabove=ceiling, force_even_distribution=False, numfeatures=6000)
        (matrix, maxaccuracy, metadata, coefficientuples, features4max, best_regularization_coef) = versatiletrainer2.tune_a_model(metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist, tags4positive, tags4negative, modelparams, name, (('../measuredivergence/newmodeloutput/' + name) + '.csv'))
        meandate = int(round((np.sum(metadata.firstpub) / len(metadata.firstpub))))
        row = dict()
        row['name'] = name
        row['size'] = sizecap
        row['ratio'] = ratio
        row['iteration'] = i
        row['meandate'] = meandate
        row['maxaccuracy'] = maxaccuracy
        row['features'] = features4max
        row['regularization'] = best_regularization_coef
        with open(outmodelpath, mode='a', encoding='utf-8') as f:
            scribe = csv.DictWriter(f, fieldnames=columns)
            scribe.writerow(row)
        os.remove(vocabpath)
        sourcefolder = '../data/'
        metadatapath = '../measuredivergence/partitionmeta/part2.csv'
        name = ('golddetective_' + str(i))
        vocabpath = (('../lexica/' + name) + '.txt')
        tags4positive = {'detective'}
        tags4negative = {'random', 'randomB'}
        floor = 1800
        ceiling = 1930
        (metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist) = versatiletrainer2.get_simple_data(sourcefolder, metadatapath, vocabpath, tags4positive, tags4negative, sizecap, excludebelow=floor, excludeabove=ceiling, force_even_distribution=False, numfeatures=6000)
        (matrix, maxaccuracy, metadata, coefficientuples, features4max, best_regularization_coef) = versatiletrainer2.tune_a_model(metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist, tags4positive, tags4negative, modelparams, name, (('../measuredivergence/newmodeloutput/' + name) + '.csv'))
        meandate = int(round((np.sum(metadata.firstpub) / len(metadata.firstpub))))
        row = dict()
        row['name'] = name
        row['size'] = sizecap
        row['ratio'] = ratio
        row['iteration'] = i
        row['meandate'] = meandate
        row['maxaccuracy'] = maxaccuracy
        row['features'] = features4max
        row['regularization'] = best_regularization_coef
        with open(outmodelpath, mode='a', encoding='utf-8') as f:
            scribe = csv.DictWriter(f, fieldnames=columns)
            scribe.writerow(row)
        os.remove(vocabpath)
def new_experiment():
    outmodelpath = '../measuredivergence/results/newexperimentmodels.csv'
    columns = ['name', 'size', 'ratio', 'iteration', 'meandate', 'maxaccuracy', 'features', 'regularization']
    if (not os.path.isfile(outmodelpath)):
        with open(outmodelpath, mode='w', encoding='utf-8') as f:
            scribe = csv.DictWriter(f, fieldnames=columns)
            scribe.writeheader()
    c_range = [1e-05, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100]
    featurestart = 1500
    featureend = 6000
    featurestep = 300
    modelparams = ('logistic', 10, featurestart, featureend, featurestep, c_range)
    sizecap = 75
    for i in range(3, 6):
        for ratio in [0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100]:
            sourcefolder = (('../measuredivergence/mix/' + str(ratio)) + '/')
            metadatapath = (('../measuredivergence/partitionmeta/meta' + str(ratio)) + '.csv')
            name = ((('mixeddata_' + str(i)) + '_') + str(ratio))
            vocabpath = (('../lexica/' + name) + '.txt')
            tags4positive = {'fantasy', 'detective'}
            tags4negative = {'random'}
            floor = 1800
            ceiling = 1930
            (metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist) = versatiletrainer2.get_simple_data(sourcefolder, metadatapath, vocabpath, tags4positive, tags4negative, sizecap, excludebelow=floor, excludeabove=ceiling, force_even_distribution=False, numfeatures=6000)
            (matrix, maxaccuracy, metadata, coefficientuples, features4max, best_regularization_coef) = versatiletrainer2.tune_a_model(metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist, tags4positive, tags4negative, modelparams, name, (('../measuredivergence/newmodeloutput/' + name) + '.csv'))
            meandate = int(round((np.sum(metadata.firstpub) / len(metadata.firstpub))))
            row = dict()
            row['name'] = name
            row['size'] = sizecap
            row['ratio'] = ratio
            row['iteration'] = i
            row['meandate'] = meandate
            row['maxaccuracy'] = maxaccuracy
            row['features'] = features4max
            row['regularization'] = best_regularization_coef
            with open(outmodelpath, mode='a', encoding='utf-8') as f:
                scribe = csv.DictWriter(f, fieldnames=columns)
                scribe.writerow(row)
            os.remove(vocabpath)
        sourcefolder = '../data/'
        metadatapath = '../measuredivergence/partitionmeta/part2.csv'
        name = ('goldfantasy_' + str(i))
        vocabpath = (('../lexica/' + name) + '.txt')
        tags4positive = {'fantasy'}
        tags4negative = {'random', 'randomB'}
        floor = 1800
        ceiling = 1930
        (metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist) = versatiletrainer2.get_simple_data(sourcefolder, metadatapath, vocabpath, tags4positive, tags4negative, sizecap, excludebelow=floor, excludeabove=ceiling, force_even_distribution=False, numfeatures=6000)
        (matrix, maxaccuracy, metadata, coefficientuples, features4max, best_regularization_coef) = versatiletrainer2.tune_a_model(metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist, tags4positive, tags4negative, modelparams, name, (('../measuredivergence/newmodeloutput/' + name) + '.csv'))
        meandate = int(round((np.sum(metadata.firstpub) / len(metadata.firstpub))))
        row = dict()
        row['name'] = name
        row['size'] = sizecap
        row['ratio'] = ratio
        row['iteration'] = i
        row['meandate'] = meandate
        row['maxaccuracy'] = maxaccuracy
        row['features'] = features4max
        row['regularization'] = best_regularization_coef
        with open(outmodelpath, mode='a', encoding='utf-8') as f:
            scribe = csv.DictWriter(f, fieldnames=columns)
            scribe.writerow(row)
        os.remove(vocabpath)
        sourcefolder = '../data/'
        metadatapath = '../measuredivergence/partitionmeta/part2.csv'
        name = ('golddetective_' + str(i))
        vocabpath = (('../lexica/' + name) + '.txt')
        tags4positive = {'detective'}
        tags4negative = {'random', 'randomB'}
        floor = 1800
        ceiling = 1930
        (metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist) = versatiletrainer2.get_simple_data(sourcefolder, metadatapath, vocabpath, tags4positive, tags4negative, sizecap, excludebelow=floor, excludeabove=ceiling, force_even_distribution=False, numfeatures=6000)
        (matrix, maxaccuracy, metadata, coefficientuples, features4max, best_regularization_coef) = versatiletrainer2.tune_a_model(metadata, masterdata, classvector, classdictionary, orderedIDs, authormatches, vocablist, tags4positive, tags4negative, modelparams, name, (('../measuredivergence/newmodeloutput/' + name) + '.csv'))
        meandate = int(round((np.sum(metadata.firstpub) / len(metadata.firstpub))))
        row = dict()
        row['name'] = name
        row['size'] = sizecap
        row['ratio'] = ratio
        row['iteration'] = i
        row['meandate'] = meandate
        row['maxaccuracy'] = maxaccuracy
        row['features'] = features4max
        row['regularization'] = best_regularization_coef
        with open(outmodelpath, mode='a', encoding='utf-8') as f:
            scribe = csv.DictWriter(f, fieldnames=columns)
            scribe.writerow(row)
        os.remove(vocabpath)