Code Monkey home page Code Monkey logo

lsa's Introduction

LSA(lag sequential analysis)

滞后序列分析python版

安装

pip install pyseqlsa

或者

pip3 install pyseqlsa

快速使用

from pyseqlsa import LSA
data = [['A', 'B', 'C', 'B', 'C', 'B', 'C'],
        ['C', 'C', 'B', 'A', 'C', 'A', 'B', 'C', 'B', 'C']]

lsa = LSA(['A', 'B', 'C'])
lsa.fit(data)

若不想打印输出,可以设置output=False

lsa.fit(data,output=False)

单独查看Z矩阵的方法

# 属性Z即是残差显著性的矩阵,大于1.96即显著
lsa.Z

如果想转换Gseq5为sds文件,可以调用

lsa.to_sds(data, "filename.sds")

通过csv获得seqs,并进行滞后序列分析

注意此处默认csv的格式,第一列为序列的id,第二列为code,标题名可以随意,从第二行开始读取,如下所示

id code
1 a
1 b
1 a
2 a
2 b
2 c

读取后的数据即可直接用于LSA代码如下所示

from pyseqlsa import read_seqs_from_csv
from pyseqlsa import LSA

data = read_seqs_from_csv('test.csv')
lsa = LSA(['A', 'B', 'C'])
lsa.fit(data)

通过excel获得seqs,并进行滞后序列分析

excel 请按照以下的格式设置,第一列为序列的id,第二列为code,标题名可以随意,从第二行开始读取,如下所示

id code
1 a
1 b
1 a
2 a
2 b
2 c

读取后的数据即可直接用于LSA代码如下所示

from pyseqlsa import read_seqs_from_excel
from pyseqlsa import LSA

data = read_seqs_from_excel('test.xlsx')
lsa = LSA(['a', 'b', 'c'])
lsa.fit(data)

lsa's People

Contributors

junlei007 avatar

Stargazers

SheepInn avatar  avatar  avatar  avatar  avatar  avatar  avatar shirey avatar  avatar  avatar  avatar Gershun Yuan avatar  avatar  avatar 宋义深 avatar Ypin avatar  avatar  avatar

Watchers

 avatar

Forkers

897354667

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.