파이썬에 로그 라인 모델을 훈련시키는 기존 패키지가 있는지 아는 사람 있습니까? 2000 개의 변수와 1000 개의 레코드가있는 데이터 집합이 있습니다. 주파수를 추정하기 위해 로그 선형 모델을 사용하려고합니다.교육용 loglinear 모델을위한 python 패키지가 있습니까?
3
A
답변
1
"기계 학습"에 대해 언급 한대로 문제가 해결되는지, 어떤 종류의 데이터가 있는지 확실하지 않습니다. 그러나 "예측"과 "추정 주파수"에 대해서도 언급 했으므로 보간이 도움이 될 수 있다고 생각합니다. 이 경우 scipy.interpolate
을 볼 수 있습니다.
보간 기는 "방사형 기저 함수 근사/보간 n 차원 분산 데이터 용 클래스 ..."입니다. 그것은 다음과 같은 기능을 지원합니다
'multiquadric': sqrt((r/self.epsilon)**2 + 1)
'inverse': 1.0/sqrt((r/self.epsilon)**2 + 1)
'gaussian': exp(-(r/self.epsilon)**2)
'linear': r
'cubic': r**3
'quintic': r**5
'thin_plate': r**2 * log(r)
3
당신이 SciPy (즉 0.10 이전)의 이전 버전을 사용하는 경우 (NLP, MaxEnt = 최대 엔트로피 모델링 = 로그 - 선형 모델에서) scipy.maxentropy
를 사용할 수 있습니다. 이 모듈은 버전 0.11.0이 출시되었을 때 SciPy를 제거했고, SciPy 팀은 sklearn.linear_model.LogisticRegression을 대체로 사용했습니다 (both 로그 선형 모델 및 로지스틱 회귀는 generalized linear models의 예이며, 선형 예측 자).
#!/usr/bin/env python
""" Example use of the maximum entropy module:
Machine translation example -- English to French -- from the paper 'A
maximum entropy approach to natural language processing' by Berger et
al., 1996.
Consider the translation of the English word 'in' into French. We
notice in a corpus of parallel texts the following facts:
(1) p(dans) + p(en) + p(a) + p(au cours de) + p(pendant) = 1
(2) p(dans) + p(en) = 3/10
(3) p(dans) + p(a) = 1/2
This code finds the probability distribution with maximal entropy
subject to these constraints.
"""
__author__ = 'Ed Schofield'
__version__= '2.1'
from scipy import maxentropy
a_grave = u'\u00e0'
samplespace = ['dans', 'en', a_grave, 'au cours de', 'pendant']
def f0(x):
return x in samplespace
def f1(x):
return x=='dans' or x=='en'
def f2(x):
return x=='dans' or x==a_grave
f = [f0, f1, f2]
model = maxentropy.model(f, samplespace)
# Now set the desired feature expectations
K = [1.0, 0.3, 0.5]
model.verbose = True
# Fit the model
model.fit(K)
# Output the distribution
print "\nFitted model parameters are:\n" + str(model.params)
print "\nFitted distribution is:"
p = model.probdist()
for j in range(len(model.samplespace)):
x = model.samplespace[j]
print ("\tx = %-15s" %(x + ":",) + " p(x) = "+str(p[j])).encode('utf-8')
# Now show how well the constraints are satisfied:
print
print "Desired constraints:"
print "\tp['dans'] + p['en'] = 0.3"
print ("\tp['dans'] + p['" + a_grave + "'] = 0.5").encode('utf-8')
print
print "Actual expectations under the fitted model:"
print "\tp['dans'] + p['en'] =", p[0] + p[1]
print ("\tp['dans'] + p['" + a_grave + "'] = " + str(p[0]+p[2])).encode('utf-8')
# (Or substitute "x.encode('latin-1')" if you have a primitive terminal.)
다른 아이디어 : 답장을 http://homepages.inf.ed.ac.uk/lzhang10/maxent.html
관련 문제
- 1. 회귀 모델을위한 도구가 있습니까?
- 2. 클라이언트 - 서버 모델을위한 Python 소켓 지원/스레딩
- 3. Python 패키지가 업그레이드되지 않습니다
- 4. 배포시 Python 패키지가 누락되었습니다.
- 5. WWW :: Mechanize가 perl에서하는 일을하는 python 패키지가 있습니까?
- 6. Perl의 Archive :: Extract와 비슷한 Python 패키지가 있습니까?
- 7. Python 용 문자 감지 패키지가 있습니까?
- 8. Python에는 XML 스키마 콘텐츠 모델을위한 라이브러리가 있습니까?
- 9. UML 모델을위한 포터블 형식
- 10. 모델을위한 Unity 의존성 주입
- 11. 교육용 Google+ API 범위
- 12. 기존 모델을위한 발판 생성
- 13. 퀴즈 모델을위한 레일 라우팅
- 14. 지속적인 모델을위한 C# 인터페이스
- 15. 교육용 D-lib 이미지
- 16. 전자 메일 익명화 기능을 제공하는 Django 또는 Python 패키지가 있습니까?
- 17. 이동용 Lucene 패키지가 있습니까?
- 18. Silverlight에 WmpBitmapDecoder 패키지가 있습니까?
- 19. 완전한 이클립스 패키지가 있습니까?
- 20. 패키지에 Java 패키지가 있습니까?
- 21. 패키지 안에 패키지가 있습니까?
- 22. 교육용 SQL 주입
- 23. 대기열 시뮬레이션 시각화에 적합한 Python 패키지가 필요합니다.
- 24. Python - 다른 작업 공간의 패키지가 호출됩니까?
- 25. 데이터베이스가 아닌 모델을위한 Django MVC 패턴?
- 26. python 패키지가 이미 설치되어 있는지 확인 C#
- 27. Python 패키지가 터미널이 아닌 Pycharm에서 인식되었습니다.
- 28. Python Requests 패키지가 url을 두 번 조회합니다
- 29. python - 패키지에서 가져온 하위 패키지가 작동하지 않습니까?
- 30. Python 로컬 패키지가 PHP에서 호출되지 않음
감사 (SciPy 0.11.0에서 제거) SciPy의 maxentropy 모듈을 사용
Example. 나는이 신문에이 모델을 구현하는 더 쉬운 방법이 있는지 알아 내려고 노력 중이다. http://users.cis.fiu.edu/~lzhen001/activities/KDD_USB_key_2010/docs/p213.pdf – user2322784