Exemplo n.º 1
0
"""
    A script to delete all clients, to clean up the staging database if it gets too crowded.
    This script will also be extended in future to delete projects and workers.
    Also shows how to delete a single client, project, or worker.
    In general this is NOT RECOMMENDED.  
    But if you have created a lot of example clients for testing you may want to clean up.
    This example requires environment variables GL_STAGE and GL_APIKEY to be set.

    As client: you CANNOT run this example, it is for admin roles only.
    As admin: you can run this example.  Only in stage=staging though.
"""

# setting up the example
import common

common.print_header(__file__)

i_am_sure = input("are you sure? ")
if not i_am_sure in "yY":
    exit()

# real stuff starts here
from greenlight import GreenLight, get_glapi_from_env

greenlight = get_glapi_from_env()
if greenlight.role_type() != 'admin':
    raise ValueError('This example can only be run with admin credentials')

if greenlight.stage == 'production' or greenlight.stage == 'beta' or greenlight.stage == 'site':
    raise EnvironmentError(
        'Running this example in production is a Really Bad Idea.')
Exemplo n.º 2
0
'''
PAC-BAYESIAN DOMAIN ADAPTATION (aka PBDA)
Executable script to launch the learning algorithm

@author: Pascal Germain -- http://graal.ift.ulaval.ca/pgermain
'''
import common
from pbda import *
from dataset import *
from kernel import *

import sys
import pickle
import argparse 

common.print_header('LEARNING ALGORITHM')

# Arguments parser
parser = argparse.ArgumentParser(description="", formatter_class=common.custom_formatter, epilog="")

parser.add_argument("-c", dest="C_value", type=float, default=1.0, help="Trade-off parameter \"C\" (source risk modifier). Default: 1.0")
parser.add_argument("-a", dest="A_value", type=float, default=1.0, help="Trade-off parameter \"A\" (domain disagreement modifier). Default: 1.0")

parser.add_argument("--kernel", "-k", dest="kernel", default="linear", choices=['rbf', 'linear'], help="Kernel function. Default: linear.")
parser.add_argument("--gamma",  "-g", dest="gamma",  type=float, default=1.0, help="Gamma parameter of the RBF kernel. Only used if --kernel is set to rbf. Default: 1.0")
parser.add_argument("--nb_restarts", "-n", dest="nb_restarts",  type=int, default=1, help='Number of random restarts of the optimization process. Default: 1')
parser.add_argument("--format", "-f", dest="format",  choices=['matrix', 'svmlight'], default='matrix', help='Datasets format. Default: matrix (each line defines an example, the first column defines the label in {-1, 1}, and the next columns represent the real-valued features)')
parser.add_argument("--model",  "-m", dest="model_file", default='model.bin', help="Model file name. Default: model.bin")
parser.add_argument("--weight", "-w", dest="weight_file", default='', help="Weight vector file name. Default: (none)")

parser.add_argument("source_file", help="Defines the file containing the source dataset.")
Exemplo n.º 3
0
See: http://arxiv.org/abs/1506.04573

Executable script to launch the learning algorithm

@author: Pascal Germain -- http://researchers.lille.inria.fr/pgermain/
'''
import common
from dalc import *
from dataset import *
from kernel import *

import sys
import pickle
import argparse

common.print_header('LEARNING ALGORITHM')

# Arguments parser
parser = argparse.ArgumentParser(description="",
                                 formatter_class=common.custom_formatter,
                                 epilog="")

parser.add_argument(
    "-b",
    dest="B_value",
    type=float,
    default=1.0,
    help="Trade-off parameter \"B\" (source joint error modifier). Default: 1.0"
)
parser.add_argument(
    "-c",
Exemplo n.º 4
0
Executable script to perform reverse cross-validation

@author: Pascal Germain -- http://researchers.lille.inria.fr/pgermain/
'''
import common
from pbda import *
from dataset import *
from kernel import *

import sys
import argparse 

from math import floor
import numpy as np

common.print_header('REVERSE CROSS-VALIDATION HELPER')

# Arguments parser
parser = argparse.ArgumentParser(description="", formatter_class=common.custom_formatter, epilog="")

parser.add_argument("-c", dest="C_value", type=float, default=1.0, help="Trade-off parameter \"C\" (source risk modifier). Default: 1.0")
parser.add_argument("-a", dest="A_value", type=float, default=1.0, help="Trade-off parameter \"A\" (domain disagreement modifier). Default: 1.0")
parser.add_argument("--nb_folds", "-cv", dest="nb_folds",  type=int, default=5, help='Number of cross validation folds. Default: 5')


parser.add_argument("--kernel", "-k", dest="kernel", default="linear", choices=['rbf', 'linear'], help="Kernel function. Default: linear.")
parser.add_argument("--gamma",  "-g", dest="gamma",  type=float, default=1.0, help="Gamma parameter of the RBF kernel. Only used if --kernel is set to rbf. Default: 1.0")
parser.add_argument("--nb_restarts", "-n", dest="nb_restarts",  type=int, default=1, help='Number of random restarts of the optimization process. Default: 1')
parser.add_argument("--format", "-f", dest="format",  choices=['matrix', 'svmlight'], default='matrix', help='Datasets format. Default: matrix (each line defines an example, the first column defines the label in {-1, 1}, and the next columns represent the real-valued features)')

parser.add_argument("source_file", help="Defines the file containing the source dataset.")
Exemplo n.º 5
0
'''
PAC-BAYESIAN DOMAIN ADAPTATION (aka PBDA)
Executable script to use the classifier (to be used after the learning process).

@author: Pascal Germain -- http://researchers.lille.inria.fr/pgermain/
'''
import common
from pbda import *
from dataset import *
from kernel import *

import sys
import pickle
import argparse 

common.print_header('CLASSIFICATION')

# Arguments parser   
parser = argparse.ArgumentParser(description="", formatter_class=common.custom_formatter, epilog="")

parser.add_argument("--format", "-f", dest="format",  choices=['matrix', 'svmlight'], default='matrix', help='Datasets format. Default: matrix (each line defines an example, the first column defines the label in {-1, 1}, and the next columns represent the real-valued features)')
parser.add_argument("--model",  "-m", dest="model_file", default='model.bin', help="Model file name. Default: model.bin")
parser.add_argument("--pred",   "-p", dest="prediction_file", default='predictions.out', help="Save predictions into files. Default: predictions.out")

parser.add_argument("test_file", help="Defines the file containing the dataset to classify.")
args = parser.parse_args()

# Main program
###############################################################################
print('... Loading model file ...')
###############################################################################
Exemplo n.º 6
0
 def print(self):
     print_header()
     for person in self.contact_list:
         person.print()
Exemplo n.º 7
0
 def print_with_header(self):
     print_header()
     print_person(self)
Exemplo n.º 8
0
Executable script to perform reverse cross-validation

@author: Pascal Germain -- http://researchers.lille.inria.fr/pgermain/
'''
import common
from pbda import *
from dataset import *
from kernel import *

import sys
import argparse

from math import floor
import numpy as np

common.print_header('REVERSE CROSS-VALIDATION HELPER')

# Arguments parser
parser = argparse.ArgumentParser(description="",
                                 formatter_class=common.custom_formatter,
                                 epilog="")

parser.add_argument(
    "-c",
    dest="C_value",
    type=float,
    default=1.0,
    help="Trade-off parameter \"C\" (source risk modifier). Default: 1.0")
parser.add_argument(
    "-a",
    dest="A_value",
Exemplo n.º 9
0
'''
PAC-BAYESIAN DOMAIN ADAPTATION (aka PBDA)
Executable script to use the classifier (to be used after the learning process).

@author: Pascal Germain -- http://researchers.lille.inria.fr/pgermain/
'''
import common
from pbda import *
from dataset import *
from kernel import *

import sys
import pickle
import argparse

common.print_header('CLASSIFICATION')

# Arguments parser
parser = argparse.ArgumentParser(description="",
                                 formatter_class=common.custom_formatter,
                                 epilog="")

parser.add_argument(
    "--format",
    "-f",
    dest="format",
    choices=['matrix', 'svmlight'],
    default='matrix',
    help=
    'Datasets format. Default: matrix (each line defines an example, the first column defines the label in {-1, 1}, and the next columns represent the real-valued features)'
)
Executable script to perform reverse cross-validation

@author: Pascal Germain -- http://graal.ift.ulaval.ca/pgermain
"""
import common
from dalc import *
from dataset import *
from kernel import *

import sys
import argparse

from math import floor
import numpy as np

common.print_header("REVERSE CROSS-VALIDATION HELPER")

# Arguments parser
parser = argparse.ArgumentParser(description="", formatter_class=common.custom_formatter, epilog="")

parser.add_argument(
    "-b",
    dest="B_value",
    type=float,
    default=1.0,
    help='Trade-off parameter "B" (source joint error modifier). Default: 1.0',
)
parser.add_argument(
    "-c",
    dest="C_value",
    type=float,