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


Python StringCharFeatures.obtain_by_sliding_window方法代码示例

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


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

示例1: get_test_features

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import obtain_by_sliding_window [as 别名]
    def get_test_features(self, seq, window):
        start = self.window[0] - window[0]
        end = len(seq) - window[1] + self.window[2]
        size = self.window[2] - self.window[0] + 1
        seq = seq[start:end]
        seq = seq.replace("N", "A").replace("R", "A").replace("M", "A")
        f = StringCharFeatures([seq], DNA)

        if self.preproc:
            wf = StringWordFeatures(f.get_alphabet())
            o = self.train_features.get_order()
            wf.obtain_from_char(f, 0, o, 0, False)
            f = wf
            f.obtain_by_sliding_window(size, 1, o - 1)
        else:
            f.obtain_by_sliding_window(size, 1)

        return f
开发者ID:Anshul-Bansal,项目名称:gsoc,代码行数:20,代码来源:signal_sensor.py

示例2: features_string_sliding_window_modular

# 需要导入模块: from shogun.Features import StringCharFeatures [as 别名]
# 或者: from shogun.Features.StringCharFeatures import obtain_by_sliding_window [as 别名]
def features_string_sliding_window_modular(strings):
    from shogun.Features import StringCharFeatures, DNA
    from shogun.Library import DynamicIntArray

    f = StringCharFeatures([strings], DNA)

    # slide a window of length 5 over features
    # (memory efficient, does not copy strings)
    f.obtain_by_sliding_window(5, 1)
    # print(f.get_num_vectors())
    # print(f.get_vector_length(0))
    # print(f.get_vector_length(1))
    # print(f.get_features())

    # slide a window of length 4 over features
    # (memory efficient, does not copy strings)
    f.obtain_by_sliding_window(4, 1)
    # print(f.get_num_vectors())
    # print(f.get_vector_length(0))
    # print(f.get_vector_length(1))
    # print(f.get_features())

    # extract string-windows at position 0,6,16,25 of window size 4
    # (memory efficient, does not copy strings)
    f.set_features([s])
    positions = DynamicIntArray()
    positions.append_element(0)
    positions.append_element(6)
    positions.append_element(16)
    positions.append_element(25)

    f.obtain_by_position_list(4, positions)
    # print(f.get_features())

    # now extract windows of size 8 from same positon list
    f.obtain_by_position_list(8, positions)
    # print(f.get_features())
    return f
开发者ID:behollis,项目名称:muViewBranch,代码行数:40,代码来源:features_string_sliding_window_modular.py


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