Exemple #1
0
class TestConnection(unittest.TestCase):
    def test_mysql(self):
        self.connection = DBConnection(TEST_DB['user'],
                                       TEST_DB['pass'],
                                       TEST_DB['host'],
                                       TEST_DB['database'],
                                       vendor=TEST_DB['vendor'])
        try:
            self.connection.check_connection()
            connection_success = True
        except:
            connection_success = False
        self.assertTrue(connection_success)

    def test_pgsql(self):
        self.connection = DBConnection(TEST_DB_POSTGRES['user'],
                                       TEST_DB_POSTGRES['pass'],
                                       TEST_DB_POSTGRES['host'],
                                       TEST_DB_POSTGRES['database'],
                                       vendor=TEST_DB_POSTGRES['vendor'])
        try:
            self.connection.check_connection()
            connection_success = True
        except:
            connection_success = False
        self.assertTrue(connection_success)
Exemple #2
0
class TestConnection(unittest.TestCase):

    def test_mysql(self):
        self.connection = DBConnection(
            TEST_DB['user'],
            TEST_DB['pass'],
            TEST_DB['host'],
            TEST_DB['database'],
            vendor=TEST_DB['vendor']
        )
        try:
            self.connection.check_connection()
            connection_success = True
        except:
            connection_success = False
        self.assertTrue(connection_success)


    def test_pgsql(self):
        self.connection = DBConnection(
            TEST_DB_POSTGRES['user'],
            TEST_DB_POSTGRES['pass'],
            TEST_DB_POSTGRES['host'],
            TEST_DB_POSTGRES['database'],
            vendor=TEST_DB_POSTGRES['vendor']
        )
        try:
            self.connection.check_connection()
            connection_success = True
        except:
            connection_success = False
        self.assertTrue(connection_success)
Exemple #3
0
    def setUp(self):
        self.connection = DBConnection(TEST_DB['user'],
                                       TEST_DB['pass'],
                                       TEST_DB['host'],
                                       TEST_DB['database'],
                                       vendor=TEST_DB['vendor'])

        self.connection_pg = DBConnection(TEST_DB_POSTGRES['user'],
                                          TEST_DB_POSTGRES['pass'],
                                          TEST_DB_POSTGRES['host'],
                                          TEST_DB_POSTGRES['database'],
                                          vendor=TEST_DB_POSTGRES['vendor'])
Exemple #4
0
 def test_mysql(self):
     self.connection = DBConnection(TEST_DB['user'],
                                    TEST_DB['pass'],
                                    TEST_DB['host'],
                                    TEST_DB['database'],
                                    vendor=TEST_DB['vendor'])
     try:
         self.connection.check_connection()
         connection_success = True
     except:
         connection_success = False
     self.assertTrue(connection_success)
Exemple #5
0
 def setUp(self):
     # MySQL test db
     self.connection = DBConnection(TEST_DB['user'],
                                    TEST_DB['pass'],
                                    TEST_DB['host'],
                                    TEST_DB['database'],
                                    vendor=TEST_DB['vendor'])
     self.context = DBContext(self.connection,
                              target_table='trains',
                              target_att='direction')
     # Postgres test db
     self.connection_pg = DBConnection(TEST_DB_POSTGRES['user'],
                                       TEST_DB_POSTGRES['pass'],
                                       TEST_DB_POSTGRES['host'],
                                       TEST_DB_POSTGRES['database'],
                                       vendor=TEST_DB_POSTGRES['vendor'])
     self.context_pg = DBContext(self.connection_pg)
     self.context_pg.target_table = 'urbanblock'
     self.context_pg.target_att = 'class'
Exemple #6
0
 def test_mysql(self):
     self.connection = DBConnection(
         TEST_DB['user'],
         TEST_DB['pass'],
         TEST_DB['host'],
         TEST_DB['database'],
         vendor=TEST_DB['vendor']
     )
     try:
         self.connection.check_connection()
         connection_success = True
     except:
         connection_success = False
     self.assertTrue(connection_success)
Exemple #7
0
from rdm.db import DBVendor, DBConnection, DBContext, AlephConverter
from rdm.wrappers import Aleph

# Provide connection information
connection = DBConnection(
    'ilp',  # User
    'ilp123',  # Password
    'workflow.ijs.si',  # Host
    'ilp',  # Database
)

# Define learning context
context = DBContext(connection, target_table='trains', target_att='direction')

# Convert the data and induce features using Aleph
conv = AlephConverter(context, target_att_val='east')
aleph = Aleph()
theory, features = aleph.induce('induce_features', conv.positive_examples(),
                                conv.negative_examples(),
                                conv.background_knowledge())
print(theory)
Exemple #8
0
import sys

reload(sys)  # Reload does the trick!
sys.setdefaultencoding('UTF8')

import orange

from rdm.db import DBVendor, DBConnection, DBContext, RSDConverter, mapper
from rdm.wrappers import RSD
from rdm.validation import cv_split
from rdm.helpers import arff_to_orange_table

# Provide connection information
connection = DBConnection(
    'ilp',  # User
    'ilp123',  # Password
    'workflow.ijs.si',  # Host
    'imdb_top',  # Database
    vendor=DBVendor.MySQL)

# Define learning context
context = DBContext(connection, target_table='movies', target_att='quality')

# Cross-validation loop
predictions = []
folds = 10
for train_context, test_context in cv_split(context,
                                            folds=folds,
                                            random_seed=0):
    # Find features on the train set
    conv = RSDConverter(train_context)
    rsd = RSD()
algorithm = "nrelaggs"

#hyperparameters
predictor_layers = [(100, ), (50, ), (100, 50)]
loss = 'hinge'
feature_generation = [1., 0.5, 0.75]
feature_selection = [1., 0.5, 0.75]

#for propStar/propDRM
learning_rates = [0.001, 0.01, 0.0001]
num_featuress = [10000, 30000, 50000]
hidden_sizes = [8, 16, 32]

connection = DBConnection(
    'guest',  # User
    'relational',  # Password
    'relational.fit.cvut.cz',  # Host
    dataset,  # Database
    vendor=DBVendor.MySQL)

context = DBContext(connection,
                    target_table=target_table,
                    target_att=target_label)

#Sql-File for propStar/propDRM
sql_file = "Data/trains/trains.sql"

if algorithm in ["aleph", "rsd", "treeliker", "wordification", "relaggs"]:
    transform(algorithm,
              context,
              target_attr_value,
              seed=1,