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


Python Parameters.calculate_alpha方法代码示例

本文整理汇总了Python中parameters.Parameters.calculate_alpha方法的典型用法代码示例。如果您正苦于以下问题:Python Parameters.calculate_alpha方法的具体用法?Python Parameters.calculate_alpha怎么用?Python Parameters.calculate_alpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parameters.Parameters的用法示例。


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

示例1: __init__

# 需要导入模块: from parameters import Parameters [as 别名]
# 或者: from parameters.Parameters import calculate_alpha [as 别名]

#.........这里部分代码省略.........
        return high, low

    def differentiate(self):
        for word in self.first_list:
            word.value_of_differ_feature = word.normalized_features[self.key_for_differ_feature]
        for word in self.second_list:
            word.value_of_differ_feature = word.normalized_features[self.key_for_differ_feature]
        if self.which_higher == "first":
            self.first_list, self.second_list = self.high_low(self.first_list, self.second_list)
        elif self.which_higher == "second":
            self.second_list, self.first_list = self.high_low(self.second_list, self.first_list)

    def create_list_from_to_choose(self, parameters_for_one_list):
        filtered_list = []
        for word in self.words:
            if is_match(word, parameters_for_one_list):
                # print word.features["pos"]
                filtered_list.append(word)

        return filtered_list

    def split(self):
        if self.first_list == self.second_list:
            new = []
            new += self.first_list
            random.shuffle(new)
            self.first_list = []
            self.first_list += new[: len(new) / 2]
            self.second_list = []
            self.second_list += new[len(new) / 2 :]

    def setup_parameters(self):
        if self.parameters.bonferroni != "off":
            self.parameters.calculate_alpha()

        self.same = self.parameters.same
        self.number_of_same = len(self.same)
        self.length = self.parameters.length
        self.statistics = self.parameters.statistics
        for word in self.first_list:
            # это массив из значений фич, которые не должны отличаться
            word.same = [word.normalized_features[key] for key in self.same]
        for word in self.second_list:
            word.same = [word.normalized_features[key] for key in self.same]

    def add_first(self):
        self.first_list += self.first_list_output
        self.second_list += self.second_list_output

        self.first_list_output = []
        self.second_list_output = []

        # вытаскиваем случайное слово из листа
        index = random.randint(0, len(self.first_list) - 1)

        word = self.first_list[index]

        # прибавляем параметры добавленного слова в счетчик
        for feature in self.first_list_equality_counter:
            # если значение этого параметра есть среди значений в счетчике, то плюс 1
            if word.features[feature] in self.first_list_equality_counter[feature]:
                self.first_list_equality_counter[feature][word.features[feature]] += 1

        self.first_list_output.append(word)
        del self.first_list[index]
开发者ID:gree-gorey,项目名称:losc,代码行数:69,代码来源:store.py


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