当前位置: 首页>>代码示例>>Python>>正文


Python DataModel.set_data方法代码示例

本文整理汇总了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()
开发者ID:narendergupta,项目名称:cs598hs,代码行数:33,代码来源:main_data_vs_accuracy.py

示例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)
开发者ID:narendergupta,项目名称:cs598hs,代码行数:21,代码来源:experimenter.py

示例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)
开发者ID:narendergupta,项目名称:cs598hs,代码行数:24,代码来源:experimenter.py


注:本文中的datamodel.DataModel.set_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。