def test_method_param(self): self.assertTrue('learning_rate' in Config(method='perceptron')['parameter']) self.assertTrue('sensitivity' in Config(method='PA')['parameter']) self.assertTrue('sensitivity' in Config(method='PA1')['parameter']) self.assertTrue('regularization_weight' in Config(method='PA1')['parameter']) self.assertTrue('nearest_neighbor_num' in Config(method='NN')['parameter']) self.assertTrue('nearest_neighbor_num' in Config(method='cosine')['parameter']) self.assertTrue('nearest_neighbor_num' in Config(method='euclidean')['parameter'])
# Load a CSV file. loader = CSVLoader('wine.csv') # Define a Schema that defines types for each columns of the CSV file. schema = Schema({ 'quality': Schema.TARGET, }, Schema.NUMBER) # Create a Dataset dataset = Dataset(loader, schema).shuffle() n_samples = len(dataset) n_train_samples = int(n_samples * 0.75) # Create a Regression Service cfg = Config.default() regression = Regression.run(cfg) print("Started Service: {0}".format(regression)) # Train the regression using the first half of the dataset. train_ds = dataset[:n_train_samples] print("Training...: {0}".format(train_ds)) for _ in regression.train(train_ds): pass # Test the regression using the last half of the dataset. test_ds = dataset[n_train_samples:] print("Testing...: {0}".format(test_ds)) mse, mae = 0, 0 for (idx, label, result) in regression.estimate(test_ds):
# Load a CSV file. loader = CSVLoader('wine.csv') # Define a Schema that defines types for each columns of the CSV file. schema = Schema({ 'quality': Schema.TARGET, }, Schema.NUMBER) # Create a Dataset dataset = Dataset(loader, schema).shuffle() n_samples = len(dataset) n_train_samples = int(n_samples * 0.75) # Create a Regression Service cfg = Config.default() regression = Regression.run(cfg) print("Started Service: {0}".format(regression)) # Train the regression using the first half of the dataset. train_ds = dataset[:n_train_samples] print("Training...: {0}".format(train_ds)) for _ in regression.train(train_ds): pass # Test the regression using the last half of the dataset. test_ds = dataset[n_train_samples:] print("Testing...: {0}".format(test_ds)) mse, mae = 0, 0 for (idx, label, result) in regression.estimate(test_ds): diff = np.abs(label - result)
def test_default(self): config = Config.default() self.assertEqual('AROW', config['method'])
def test_methods(self): config = Config() self.assertTrue(isinstance(config.methods(), list))
def test_simple(self): config = Config() self.assertEqual('AROW', config['method'])
def test_embedded(self): regression = Regression.run(Config(), embedded=True)
from jubakit.regression import Regression, Dataset, Config # Load the boston dataset. boston = sklearn.datasets.load_boston() X = boston.data y = boston.target # Create a Dataset dataset = Dataset.from_array(boston.data, boston.target).shuffle() n_samples = len(dataset) n_train_samples = int(n_samples * 0.75) # Create a Regression Service cfg = Config(method='AROW', parameter={ 'regularization_weight': 1.0, 'sensitivity': 1.0 }) regression = Regression.run(cfg) print("Started Service: {0}".format(regression)) # Train the regression using the first half of the dataset. train_ds = dataset[:n_train_samples] print("Training...: {0}".format(train_ds)) for _ in regression.train(train_ds): pass # Test the regression using the last half of the dataset. test_ds = dataset[n_train_samples:] print("Testing...: {0}".format(test_ds))