本文整理匯總了Python中datamodel.DataModel.set_data方法的典型用法代碼示例。如果您正苦於以下問題:Python DataModel.set_data方法的具體用法?Python DataModel.set_data怎麽用?Python DataModel.set_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datamodel.DataModel
的用法示例。
在下文中一共展示了DataModel.set_data方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_data_size_vs_diff
# 需要導入模塊: from datamodel import DataModel [as 別名]
# 或者: from datamodel.DataModel import set_data [as 別名]
def test_data_size_vs_diff(dm, given_dict, infer_dict):
#Read all data from data model
dm.read_data(normalize_data=False)
#attr_list = [U_UNIVERSITY_CODE, PROGRAM_CODE, UNIVERSITY, MAJOR_CODE, TERM]
attr_list = [U_UNIVERSITY_CODE, PROGRAM_CODE, UNIVERSITY]
#attr_list = [MAJOR_CODE, PROGRAM_CODE, TERM]
#Size of data
data_size = len(dm.data)
#Step size = 10 steps
step_size = data_size//10
#Get experiment data in a dict
size = []
accuracy = []
for i in xrange(step_size, data_size, step_size):
dm_test = DataModel("")
dm_test.set_data(dm.data[:i])
exp_test = Experimenter(dm_test, attr_list)
actual = exp_test.get_actual_result(given_dict, infer_dict)
estimation = exp_test.generic_get_estimated_result(given_dict, infer_dict)
size.append(i)
accuracy.append(abs(estimation - actual))
print("Step:%d--->Actual:%f--->Estimate:%f" %(i, actual, estimation))
print "-------------------------------------------------------------"
plt.figure()
plt.plot(size, accuracy)
plt.title("Data Size vs Accuracy")
plt.show()
示例2: perform_datasize_vs_efficiency
# 需要導入模塊: from datamodel import DataModel [as 別名]
# 或者: from datamodel.DataModel import set_data [as 別名]
def perform_datasize_vs_efficiency(self, given_dict, infer_dict, max_datasize=None, steps=10):
sizes, est_times, acc_times = [], [], []
if max_datasize is None:
max_datasize = len(self.dm.data)
data_step = max_datasize / steps
for i in range(steps):
cur_datasize = (i+1) * data_step
data = self.dm.data
while len(data) < cur_datasize:
data.extend(self.dm.data)
cur_data = data[:cur_datasize]
cur_dm = DataModel("")
cur_dm.set_data(cur_data)
cur_exp = Experimenter(cur_dm, self.attr_list)
(cur_est, cur_acc) = cur_exp.time_n_queries(given_dict, infer_dict)
sizes.append(cur_datasize)
est_times.append(float(sum(cur_est))/len(cur_est))
acc_times.append(float(sum(cur_acc))/len(cur_acc))
return (sizes, est_times, acc_times)
示例3: perform_datasize_vs_accuracy
# 需要導入模塊: from datamodel import DataModel [as 別名]
# 或者: from datamodel.DataModel import set_data [as 別名]
def perform_datasize_vs_accuracy(self, given_dict, infer_dict, max_datasize=None, steps=10):
#Get experiment data in a dict
size = []
accuracy = []
if max_datasize is None:
max_datasize = len(self.dm.data)
data_step = max_datasize / steps
for i in range(steps):
cur_datasize = (i+1) * data_step
data = self.dm.data
while len(data) < cur_datasize:
data.extend(self.dm.data)
cur_data = data[:cur_datasize]
cur_dm = DataModel("")
cur_dm.set_data(cur_data)
cur_exp = Experimenter(cur_dm, self.attr_list)
actual = cur_exp.get_actual_result(given_dict, infer_dict)
estimation = cur_exp.generic_get_estimated_result(given_dict, infer_dict)
size.append(cur_datasize)
accuracy.append(abs(estimation - actual))
return (size, accuracy)