本文整理汇总了Python中DataManager.DataManager类的典型用法代码示例。如果您正苦于以下问题:Python DataManager类的具体用法?Python DataManager怎么用?Python DataManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, code ):
hobby_row = DataManager.getRow( "SELECT * FROM Hobby WHERE HobbyCode=?", [code] )
self.code = code
self.expense = hobby_row['Expense']
self.skills = DataManager.getRows( "SELECT * FROM HobbySkill WHERE HobbyCode=?", [code] )
self.needs = DataManager.getRows( "SELECT * FROM HobbyNeed WHERE HobbyCode=?", [code] )
示例2: Test_2_DataManagerSyncStart
class Test_2_DataManagerSyncStart(unittest.TestCase):
def setUp(self):
self.af = FeedRef((FeatureType.ADDRESS,FeedType.FEATURES))
self.ac = FeedRef((FeatureType.ADDRESS,FeedType.CHANGEFEED))
self.ar = FeedRef((FeatureType.ADDRESS,FeedType.RESOLUTIONFEED))
self.aff = FeatureFactory.getInstance(self.af)
self.afc = FeatureFactory.getInstance(self.ac)
self.afr = FeatureFactory.getInstance(self.ar)
self.dm = DataManager()
def tearDown(self):
self.dm.close()
del self.afr
del self.afc
del self.aff
def test10_validdatastoreTest(self):
'''Tests whether a valid address object is returned on json decoded arg'''
initdata = self.dm.pull()
self.assertEquals(len(initdata),5,'Invalid ADL list length returned')
def test20_refreshTest(self):
'''Tests whether a valid address object is returned on json decoded arg'''
initdata = self.dm.pull()
self.assertTrue(isinstance(initdata[self.af][0],Address),'Invalid address type returned')
self.assertTrue(isinstance(initdata[self.ac][0],AddressChange),'Invalid address type returned')
self.assertTrue(isinstance(initdata[self.ar][0],AddressResolution),'Invalid address type returned')
def test30_refreshTest(self):
pass
def test40_refreshTest(self):
pass
示例3: add
def add(self, task, projectName=None):
date = Timings.now()
if self.taskType(task) != "work":
projectName = None
attributes = self.processTask(date, task, projectName)
DataManager.writeTask(date, task, projectName, firstToday=len(self.tasks) == 1)
return attributes
示例4: test_experiment_not_transformed_test
def test_experiment_not_transformed_test(self):
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
loaded_data = FileLoader.load_file(file_path)
data_manager = DataManager()
data_manager.set_data(loaded_data)
data_manager.split_data(test_split=0.19, train_split=0.62)
learning_model = FakePredictionModel()
exp = Experiment(data_manager, learning_model)
exp.run_experiment()
self.assertEquals(0, exp.get_r2(SplitTypes.Test))
示例5: test_experiment
def test_experiment(self):
output_filename_header = FileLoader.create_output_file()
time.sleep(1)
loaded_algorithm_combinations = FileLoader.read_csv_file("../Datasets/test.csv")
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
loaded_data = FileLoader.load_file(file_path)
# feature_eliminator = SelectKBest(f_regression,k=k_value)
print (loaded_algorithm_combinations[0])
output_filename = FileLoader.create_output_file()
for i in range(0, 80):
normalizer = self.getnormalizer(loaded_algorithm_combinations[i][0])
feature_eliminator = self.getfeature_eliminator(loaded_algorithm_combinations[i][1])
the_model = self.get_model(loaded_algorithm_combinations[i][2])
print "taking ", type(normalizer).__name__, "and feature selector ", type(
feature_eliminator
).__name__, "model", type(the_model).__name__
FileLoader.write_model_in_file(
output_filename_header,
type(normalizer).__name__,
type(feature_eliminator).__name__,
type(the_model).__name__,
"",
"",
"",
"",
"",
)
the_data_manager = DataManager(feature_eliminator, normalizer=normalizer)
the_data_manager.set_data(loaded_data)
the_data_manager.split_data(test_split=0.15, train_split=0.70)
exp = Experiment(the_data_manager, the_model)
exp.run_experiment()
# arr_selected = feature_eliminator.get_support(indices=True)
# if(exp.get_r2(SplitTypes.Train) > 0 and exp.get_r2(SplitTypes.Valid) > 0 and exp.get_r2(SplitTypes.Test) > 0):
FileLoader.write_model_in_file(
output_filename,
type(normalizer).__name__,
type(feature_eliminator).__name__,
type(the_model).__name__,
"",
exp.fitness_matrix[0],
exp.get_r2(SplitTypes.Train),
exp.get_r2(SplitTypes.Valid),
exp.get_r2(SplitTypes.Test),
)
示例6: calculateNeededGallons
def calculateNeededGallons():
result = []
recentWateringGallons = DataManager.getPreviousWateringAmounts(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
sectorTargets = DataManager.getTargetCapacity(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
previousRain = DataManager.getLatestRainfall(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
predictedRain = DataManager.getPredictedRainfall(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
currentMoistures = DataManager.getLatestMoisture(pymysql.connect(host='localhost',
user='root',
password='',
db='Garden',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor))
for x in range(0, 4):
currentGallons = (previousRain * 280) + recentWateringGallons[x + 1]
if currentMoistures[x] > sectorTargets[x]:
result.insert(x, 0)
elif currentGallons > 280:
result.insert(x, 0)
else:
if (predictedRain[1] * 280) * (predictedRain[0]/Decimal(100)) + currentGallons > 280:
result.insert(x, 0)
else:
result.insert(x, 280 - ((predictedRain[1] * 280) * (predictedRain[0]/Decimal(100)) + currentGallons))
print((predictedRain[1] * 280) * (predictedRain[0]/Decimal(100)) + currentGallons)
return result
示例7: test_experiment_all_zeros_r2_1
def test_experiment_all_zeros_r2_1(self):
the_data_manager = DataManager()
array_all_zeroes = np.zeros((37, 397))
the_data_manager.set_data(array_all_zeroes)
the_data_manager.split_data(test_split=0.19, train_split=0.62)
the_model = svm.SVR()
exp = Experiment(the_data_manager, the_model)
exp.run_experiment()
r2_train = exp.get_r2(SplitTypes.Train)
expected = 1.0
self.assertEqual(r2_train, expected)
示例8: test_experiment_sum_of_squares_zeros_test
def test_experiment_sum_of_squares_zeros_test(self):
the_data_manager = DataManager()
an_array_of_all_ones = np.ones((37, 397))
the_model = svm.SVR()
the_data_manager.set_data(an_array_of_all_ones)
the_data_manager.split_data(test_split=0.19, train_split=0.62)
exp = Experiment(the_data_manager, the_model)
exp.run_experiment()
sum_of_squares_test = exp.get_sum_of_squares(SplitTypes.Test)
expected = 0
self.assertEquals(expected, sum_of_squares_test)
示例9: test_experiment_svm_svr_37dataset_r2_train
def test_experiment_svm_svr_37dataset_r2_train(self):
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
loaded_data = FileLoader.load_file(file_path)
the_data_manager = DataManager()
the_data_manager.set_data(loaded_data)
the_data_manager.split_data(test_split=0.19, train_split=0.62)
the_model = svm.SVR()
exp = Experiment(the_data_manager, the_model)
exp.run_experiment()
r2_train = exp.get_r2(SplitTypes.Train)
expected_svm_r2_value = 0.93994377385638073
self.assertEqual(r2_train, expected_svm_r2_value)
示例10: test_split_merge_csv_4_25_8
def test_split_merge_csv_4_25_8(self):
file_loader = FileLoader()
data_manager = DataManager()
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
result = file_loader.load_file(file_path)
data_manager.set_data(result)
data_manager.split_data(test_split=0.11,train_split=0.22)
test_shapes = np.zeros((4, 397)).shape
valid_shapes = np.zeros((25,397)).shape
train_shapes = np.zeros((8, 397)).shape
expected = np.array([test_shapes, valid_shapes, train_shapes])
result = np.array([data_manager.datum[SplitTypes.Test].shape, data_manager.datum[SplitTypes.Valid].shape, data_manager.datum[SplitTypes.Train].shape])
self.assertTrue(np.array_equal(result, expected))
示例11: test_experiment_svr_37dataset_r2_test
def test_experiment_svr_37dataset_r2_test(self):
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
loaded_data = FileLoader.load_file(file_path)
the_data_manager = DataManager()
the_data_manager.set_data(loaded_data)
the_data_manager.split_data(test_split=0.19, train_split=0.62)
the_model = svm.SVR()
exp = Experiment(the_data_manager, the_model)
exp.run_experiment()
r2_test = exp.get_r2(SplitTypes.Test)
expected_svm_r2_value = -0.33005242525900247
self.assertEqual(r2_test, expected_svm_r2_value)
示例12: on_message
def on_message(client, userdata, msg):
print ('Topic: ', msg.topic, '\nMessage: ', str(msg.payload))
print("Peter:" + str(msg.payload))
arr = [x.strip() for x in str(msg.payload).split(',')]
devId = (arr[0])[2:]
tmStmp = arr[1]
x = arr[2]
y = arr[3]
z = arr[4]
lat = arr[5]
long = arr[6]
dm = DataManager()
dm.insertDeviceData(devId,tmStmp,x,y,z,lat,long)
return
示例13: Test_1_DataManagerFunctionTest
class Test_1_DataManagerFunctionTest(unittest.TestCase):
def setUp(self):
self.dm = DataManager()
def tearDown(self):
self.dm.close()
def test10_parseAddressTest(self):
'''Tests whether a valid address object is returned on json decoded arg'''
assert True
def test20_pullTest(self):
'''Tests whether we get a valid list[group[address]]'''
assert True
示例14: test_split_merge_csv_7_7_23
def test_split_merge_csv_7_7_23(self):
file_loader = FileLoader()
data_manager = DataManager()
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
result = file_loader.load_file(file_path)
data_manager.set_data(result)
data_manager.split_data(test_split=0.19,train_split=0.62)
valid_and_test_shapes = (7, 397)
train_shapes = (23, 397)
expected = np.array([valid_and_test_shapes, valid_and_test_shapes, train_shapes])
result = np.array([data_manager.datum[SplitTypes.Test].shape, data_manager.datum[SplitTypes.Valid].shape, data_manager.datum[SplitTypes.Train].shape])
self.assertTrue(np.array_equal(result, expected))
示例15: test_experiment_sum_of_squares_real37_test
def test_experiment_sum_of_squares_real37_test(self):
file_path = "../Datasets/HIV_37_Samples/MergedDataset.csv"
loaded_data = FileLoader.load_file(file_path)
the_data_manager = DataManager()
the_data_manager.set_data(loaded_data)
the_model = svm.SVR()
the_data_manager.split_data(test_split=0.19, train_split=0.62)
exp = Experiment(the_data_manager, the_model)
exp.run_experiment()
sum_of_squares_test = exp.get_sum_of_squares(SplitTypes.Test)
expected = 6.708898437500002
self.assertAlmostEqual(expected, sum_of_squares_test)