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


Python regression_model.RegressionModel类代码示例

本文整理汇总了Python中opus_core.regression_model.RegressionModel的典型用法代码示例。如果您正苦于以下问题:Python RegressionModel类的具体用法?Python RegressionModel怎么用?Python RegressionModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RegressionModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, group_member, datasets_grouping_attribute,  **kwargs):
     """ 'group_member' is of type ModelGroupMember. 'datasets_grouping_attribute' is attribute of the dataset
     (passed to the 'run' and 'estimate' method) that is used for grouping.
     """
     self.group_member = group_member
     group_member_name = group_member.get_member_name()
     self.group_member.set_agents_grouping_attribute(datasets_grouping_attribute)
     self.model_name = "%s %s" % (group_member_name.capitalize(), self.model_name)
     self.model_short_name = "%s %s" % (group_member_name.capitalize(), self.model_short_name),
     RegressionModel.__init__(self, **kwargs)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:10,代码来源:regression_model_member.py

示例2: __init__

 def __init__(self, regression_procedure="opus_core.linear_regression",
              filter_attribute="urbansim.gridcell.has_residential_units",
              submodel_string="development_type_id",
              run_config=None,
              estimate_config=None,
              debuglevel=0):
     self.filter_attribute = filter_attribute
     RegressionModel.__init__(self,
                              regression_procedure=regression_procedure,
                              submodel_string=submodel_string,
                              run_config=run_config,
                              estimate_config=estimate_config,
                              debuglevel=debuglevel)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:13,代码来源:housing_price_model.py

示例3: __init__

 def __init__(self, regression_procedure="opus_core.linear_regression",
               submodel_string=None, outcome_attribute = None,
               run_config=None, estimate_config=None, debuglevel=None, dataset_pool=None):
     """'outcome_attribute' must be specified in order to compute the residuals.
     """
     RegressionModel.__init__(self,
                              regression_procedure=regression_procedure,
                              submodel_string=submodel_string,
                              run_config=run_config,
                              estimate_config=estimate_config,
                              debuglevel=debuglevel, dataset_pool=dataset_pool)
     self.outcome_attribute = outcome_attribute
     if (self.outcome_attribute is not None) and not isinstance(self.outcome_attribute, VariableName):
         self.outcome_attribute = VariableName(self.outcome_attribute)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:14,代码来源:regression_model_with_addition_initial_residuals.py

示例4: run

    def run(self, specification, coefficients, dataset, index=None, chunk_specification=None, 
             data_objects=None, run_config=None, debuglevel=0):
        """ For info on the arguments see RegressionModel.
        dataset should be an instance of DevelopmentProjectProposalDataset, if it isn't,
        create dataset on the fly with parcel and development template
        index and self.filter_attribute (passed in __init___) are relative to dataset
        """
        if data_objects is not None:
            self.dataset_pool.add_datasets_if_not_included(data_objects)
        proposal_component_set = create_from_proposals_and_template_components(dataset, 
                                                           self.dataset_pool.get_dataset('development_template_component'))
        
        self.dataset_pool.replace_dataset(proposal_component_set.get_dataset_name(), proposal_component_set)
        #proposal_component_set.flush_dataset_if_low_memory_mode()
        #dataset.flush_dataset_if_low_memory_mode()
        
        result = RegressionModel.run(self, specification, coefficients, dataset, 
                                         index=index, chunk_specification=chunk_specification, data_objects=data_objects,
                                         run_config=run_config, debuglevel=debuglevel)

        if re.search("^ln_", self.outcome_attribute_name): # if the outcome attr. name starts with 'ln_'
                                                           # the results will be exponentiated.
            self.outcome_attribute_name = self.outcome_attribute_name[3:len(self.outcome_attribute_name)]
            result = exp(result)

        if self.outcome_attribute_name not in dataset.get_known_attribute_names():
            dataset.add_primary_attribute(self.defalult_value + zeros(dataset.size()),
                                             self.outcome_attribute_name)
        
        dataset.set_values_of_one_attribute(self.outcome_attribute_name, 
                                                 result, index=index)
        self.correct_infinite_values(dataset, self.outcome_attribute_name)
        return dataset            
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:33,代码来源:development_project_proposal_regression_model.py

示例5: prepare_for_run

    def prepare_for_run(self, add_member_prefix=True, specification_storage=None, specification_table=None, coefficients_storage=None,
                         coefficients_table=None, **kwargs):
        if add_member_prefix:
            specification_table, coefficients_table = \
                self.group_member.add_member_prefix_to_table_names([specification_table, coefficients_table])

        return RegressionModel.prepare_for_run(self, specification_storage=specification_storage, specification_table=specification_table, 
                                               coefficients_storage=coefficients_storage, coefficients_table=coefficients_table, **kwargs)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:8,代码来源:regression_model_member.py

示例6: __init__

 def __init__(self, regression_procedure="opus_core.linear_regression", 
              filter_attribute=None,
              submodel_string=None, 
              outcome_attribute=None,
              run_config=None, 
              estimate_config=None, 
              debuglevel=0, dataset_pool=None):
     self.filter_attribute = filter_attribute
     if outcome_attribute is not None:
         self.outcome_attribute = outcome_attribute
     
     RegressionModel.__init__(self, 
                              regression_procedure=regression_procedure, 
                              submodel_string=submodel_string, 
                              run_config=run_config, 
                              estimate_config=estimate_config, 
                              debuglevel=debuglevel, dataset_pool=dataset_pool)
开发者ID:psrc,项目名称:urbansim,代码行数:17,代码来源:income_regression_model.py

示例7: __init__

    def __init__(self, regression_procedure="opus_core.linear_regression",
                 filter = "urbansim.gridcell.is_in_development_type_group_developable",
                 submodel_string = "development_type_id",
                 run_config=None,
                 estimate_config=None,
                 debuglevel=0, dataset_pool=None):
        self.filter = filter
        if filter is None:
            if run_config is not None and 'filter' in run_config:
                self.filter = run_config["filter"]
            elif estimate_config is not None and 'filter' in estimate_config:
                self.filter = estimate_config["filter"]

        RegressionModel.__init__(self,
                                 regression_procedure=regression_procedure,
                                 submodel_string=submodel_string,
                                 run_config=run_config,
                                 estimate_config=estimate_config,
                                 debuglevel=debuglevel, dataset_pool=dataset_pool)
开发者ID:psrc,项目名称:urbansim,代码行数:19,代码来源:land_price_model.py

示例8: estimate

 def estimate(self, specification, dataset, outcome_attribute, index=None, **kwargs):
     if index is None:
         index = arange(dataset.size())
     data_objects = kwargs.get("data_objects",{})
     if data_objects is not None:
         self.dataset_pool.add_datasets_if_not_included(data_objects)
     # filter out agents for this group
     new_index = self.group_member.get_index_of_my_agents(dataset, index, dataset_pool=self.dataset_pool)
     return RegressionModel.estimate(self,  specification, dataset, outcome_attribute,
                                            index=index[new_index], **kwargs)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:10,代码来源:regression_model_member.py

示例9: __init__

 def __init__(self, regression_procedure="opus_core.linear_regression",
              outcome_attribute="month_combination_2",
              filter_attribute=None,
              submodel_string="land_use_type_id",
              run_config=None,
              estimate_config=None,
              debuglevel=0,
              dataset_pool=None):
     self.outcome_attribute = outcome_attribute
     if (self.outcome_attribute is not None) and not isinstance(self.outcome_attribute, VariableName):
         self.outcome_attribute = VariableName(self.outcome_attribute)
     
     self.filter_attribute = filter_attribute
     RegressionModel.__init__(self,
                              regression_procedure=regression_procedure,
                              submodel_string=submodel_string,
                              run_config=run_config,
                              estimate_config=estimate_config,
                              debuglevel=debuglevel,
                              dataset_pool=dataset_pool)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:20,代码来源:water_demand_model.py

示例10: estimate

 def estimate(self, specification, dataset, outcome_attribute="urbansim.gridcell.ln_total_land_value", index = None,
                     procedure="opus_core.estimate_linear_regression", data_objects=None,
                     estimate_config=None,  debuglevel=0):
     if data_objects is not None:
         self.dataset_pool.add_datasets_if_not_included(data_objects)
     if self.filter <> None:
         res = Resources({"debug":debuglevel})
         index = dataset.get_filtered_index(self.filter, threshold=0, index=index, dataset_pool=self.dataset_pool,
                                            resources=res)
     return RegressionModel.estimate(self, specification, dataset, outcome_attribute, index, procedure,
                                  estimate_config=estimate_config, debuglevel=debuglevel)
开发者ID:psrc,项目名称:urbansim,代码行数:11,代码来源:land_price_model.py

示例11: get_configuration

 def get_configuration(self):
     return {
       "init":{
         "regression_procedure":{"default":"opus_core.linear_regression",
                                  "type":str},
         "submodel_string":{"default":"development_type_id",
                    "type":str},
         "run_config":{"default":None, "type":Resources},
         "estimate_config":{"default":None, "type":Resources},
         "debuglevel": {"default":0, "type":int}},
       "run": RegressionModel.get_configuration(self)["run"]
         }
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:12,代码来源:residential_land_share_model.py

示例12: run

 def run(self, specification, coefficients, dataset, index=None, **kwargs):
     if index is None:
         index = arange(dataset.size())
     data_objects = kwargs.get("data_objects",{})
     if data_objects is not None:
         self.dataset_pool.add_datasets_if_not_included(data_objects)
     # filter out agents for this group
     new_index = self.group_member.get_index_of_my_agents(dataset, index, dataset_pool=self.dataset_pool)
     regresult = RegressionModel.run(self,  specification, coefficients, dataset,
                                            index=index[new_index], **kwargs)
     result = zeros(index.size, dtype=float32)
     result[new_index] = regresult
     return result
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:13,代码来源:regression_model_member.py

示例13: run

    def run(self, specification, coefficients, dataset, 
            index=None, chunk_specification=None,
            data_objects=None, run_config=None, debuglevel=0):
        """ For info on the arguments see RegressionModel.
        """
        outcome_attribute_short = self.outcome_attribute.get_alias()
        if data_objects is not None:
            self.dataset_pool.add_datasets_if_not_included(data_objects)
        if self.filter_attribute <> None:
            res = Resources({"debug":debuglevel})
            index = dataset.get_filtered_index(self.filter_attribute, threshold=0, index=index,
                                               dataset_pool=self.dataset_pool, resources=res)
        
        current_year = SimulationState().get_current_time()
        current_month = int( re.search('\d+$', outcome_attribute_short).group() )
        # date in YYYYMM format, matching to the id_name field of weather dataset
        date = int( "%d%02d" % (current_year, current_month) )
        date = array([date] * dataset.size())
        
        if "date" in dataset.get_known_attribute_names():
            dataset.set_values_of_one_attribute("date", date)
        else:
            dataset.add_primary_attribute(date, "date")

        water_demand = RegressionModel.run(self, specification, coefficients, dataset, 
                                           index, chunk_specification,
                                           run_config=run_config, debuglevel=debuglevel)
        if (water_demand == None) or (water_demand.size <=0):
            return water_demand
        
        if index == None:
            index = arange(dataset.size())
            
        if re.search("^ln_", outcome_attribute_short): 
            # if the outcome attr. name starts with 'ln_' the results will be exponentiated.
            outcome_attribute_name = outcome_attribute_short[3:len(outcome_attribute_short)]
            water_demand = exp(water_demand)
        else:
            outcome_attribute_name = outcome_attribute_short

        if outcome_attribute_name in dataset.get_known_attribute_names():
            dataset.set_values_of_one_attribute(outcome_attribute_name, water_demand, index)
        else:
            results = zeros(dataset.size(), dtype=water_demand.dtype)
            results[index] = water_demand
            dataset.add_primary_attribute(results, outcome_attribute_name)

        return water_demand
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:48,代码来源:water_demand_model.py

示例14: run

    def run(self, specification, coefficients, dataset, index=None, **kwargs):
        """
        See description above. If missing values of the outcome attribute are suppose to be excluded from
        the addition of the initial residuals, set an entry of run_config 'exclude_missing_values_from_initial_error' to True.
        Additionaly, an entry 'outcome_attribute_missing_value' specifies the missing value (default is 0).
        Similarly, if outliers are to be excluded, the run_config entry "exclude_outliers_from_initial_error" should be set to True.
        In such a case, run_config entries 'outlier_is_less_than' and 'outlier_is_greater_than' can define lower and upper bounds for outliers. 
        By default, an outlier is a data point smaller than 0. There is no default upper bound.
        """
        if self.outcome_attribute is None:
            raise StandardError, "An outcome attribute must be specified for this model. Pass it into the initialization."
        
        if self.outcome_attribute.get_alias() not in dataset.get_known_attribute_names():
            try:
                dataset.compute_variables(self.outcome_attribute, dataset_pool=self.dataset_pool)
            except:
                raise StandardError, "The outcome attribute %s must be a known attribute of the dataset %s." % (
                                                                self.outcome_attribute.get_alias(), dataset.get_dataset_name())
            
        if index is None:
            index = arange(dataset.size())
        original_data = dataset.get_attribute_by_index(self.outcome_attribute, index)
        
        outcome = RegressionModel.run(self, specification, coefficients, dataset, index, initial_values=original_data.astype('float32'), **kwargs)
        initial_error_name = "_init_error_%s" % self.outcome_attribute.get_alias()


        if initial_error_name not in dataset.get_known_attribute_names():
            initial_error = original_data - outcome
            dataset.add_primary_attribute(name=initial_error_name, data=zeros(dataset.size(), dtype="float32"))
            exclude_missing_values = self.run_config.get("exclude_missing_values_from_initial_error", False)
            exclude_outliers = self.run_config.get("exclude_outliers_from_initial_error", False)
            if exclude_missing_values:
                missing_value = self.run_config.get("outcome_attribute_missing_value", 0)
                initial_error[original_data == missing_value] = 0
                logger.log_status('Values equal %s were excluded from adding residuals.' % missing_value)
            if exclude_outliers:
                outlier_low = self.run_config.get("outlier_is_less_than", 0)
                initial_error[original_data < outlier_low] = 0
                outlier_high = self.run_config.get("outlier_is_greater_than", original_data.max())
                initial_error[original_data > outlier_high] = 0
                logger.log_status('Values less than %s and larger than %s were excluded from adding residuals.' % (outlier_low, outlier_high))
            dataset.set_values_of_one_attribute(initial_error_name, initial_error, index)
        else:
            initial_error = dataset.get_attribute_by_index(initial_error_name, index)
        return outcome + initial_error
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:46,代码来源:regression_model_with_addition_initial_residuals.py

示例15: run

 def run(self, specification, coefficients, dataset, index=None, chunk_specification=None,
         data_objects=None, run_config=None, debuglevel=0):
     """ For info on the arguments see RegressionModel.
     """
     regression_outcome = RegressionModel.run(self, specification, coefficients, dataset, 
                             index=index, chunk_specification=chunk_specification, data_objects=data_objects,
                             run_config=run_config, debuglevel=debuglevel)
     if (regression_outcome == None) or (regression_outcome.size <=0):
         return regression_outcome
     if index == None:
         index = arange(dataset.size())
     result = exp(regression_outcome)
     result = result/(1.0+result)
     if  (self.attribute_to_modify not in dataset.get_known_attribute_names()):
         dataset.add_attribute(name=self.attribute_to_modify,
                                data=zeros((dataset.size(),), dtype=float32))
     dataset.set_values_of_one_attribute(self.attribute_to_modify, result, index)
     return result
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:18,代码来源:residential_land_share_model.py


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