<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《Google&#8217;s Python Class &#8211; SOS》的评论</title>
	<atom:link href="http://www.52nlp.cn/googles-python-class-sos/feed" rel="self" type="application/rss+xml" />
	<link>http://www.52nlp.cn/googles-python-class-sos</link>
	<description>I Love Natural Language Processing</description>
	<lastBuildDate>Sun, 05 Feb 2012 11:54:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>作者：52nlp</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1222</link>
		<dc:creator>52nlp</dc:creator>
		<pubDate>Tue, 18 May 2010 15:30:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1222</guid>
		<description>不客气，欢迎你写完后再转发到这里。</description>
		<content:encoded><![CDATA[<p>不客气，欢迎你写完后再转发到这里。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：我是一头驴子</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1218</link>
		<dc:creator>我是一头驴子</dc:creator>
		<pubDate>Tue, 18 May 2010 02:18:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1218</guid>
		<description>还是非常感谢你。我昨天贴代码，目的就是为了说明python库在专业数学计算方面还是有欠缺的。最近考试，等考完试写篇博客，总结下python调用matlab的方法~</description>
		<content:encoded><![CDATA[<p>还是非常感谢你。我昨天贴代码，目的就是为了说明python库在专业数学计算方面还是有欠缺的。最近考试，等考完试写篇博客，总结下python调用matlab的方法~</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：52nlp</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1215</link>
		<dc:creator>52nlp</dc:creator>
		<pubDate>Mon, 17 May 2010 16:26:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1215</guid>
		<description>惭愧，Python和Matlab我属于初级水平，没仔细看你的代码。

关于“python和matlab怎么混合编程”这个问题，昨晚回答的比较仓促，抱歉。我搜了一下，你看看下面的几个方案是否能解决：

1：An Open-Source MATLAB®-to-Python® Compiler

http://ompc.juricap.com/

OMPC allows running MATLAB®&#039;s m-files using Python interpreter. OMPC reads m-files and translates them into Python compatible code. Just like in the following example

从描述来看OMPC的目标是将Matlab代码转换成Python代码，可以试试利用OMPC“翻译”你的Matlab代码。

2. PyMat - An interface between Python and MATLAB

http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html

The PyMat module acts as an interface between NumPy arrays in Python and a MATLAB engine session, allowing arrays to be passed back and forth and arbitrary commands to be executed in the MATLAB workspace. 

这个我估计你可能测试过了。

如果上述方案不能解决，这里再写个SOS吧，呵呵。</description>
		<content:encoded><![CDATA[<p>惭愧，Python和Matlab我属于初级水平，没仔细看你的代码。</p>
<p>关于“python和matlab怎么混合编程”这个问题，昨晚回答的比较仓促，抱歉。我搜了一下，你看看下面的几个方案是否能解决：</p>
<p>1：An Open-Source MATLAB®-to-Python® Compiler</p>
<p><a href="http://ompc.juricap.com/" rel="nofollow">http://ompc.juricap.com/</a></p>
<p>OMPC allows running MATLAB®&#8217;s m-files using Python interpreter. OMPC reads m-files and translates them into Python compatible code. Just like in the following example</p>
<p>从描述来看OMPC的目标是将Matlab代码转换成Python代码，可以试试利用OMPC“翻译”你的Matlab代码。</p>
<p>2. PyMat &#8211; An interface between Python and MATLAB</p>
<p><a href="http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html" rel="nofollow">http://claymore.engineer.gvsu.edu/~steriana/Python/pymat.html</a></p>
<p>The PyMat module acts as an interface between NumPy arrays in Python and a MATLAB engine session, allowing arrays to be passed back and forth and arbitrary commands to be executed in the MATLAB workspace. </p>
<p>这个我估计你可能测试过了。</p>
<p>如果上述方案不能解决，这里再写个SOS吧，呵呵。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：finallyliuyu</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1211</link>
		<dc:creator>finallyliuyu</dc:creator>
		<pubDate>Mon, 17 May 2010 01:34:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1211</guid>
		<description>上面写错了。glmfit几句话就搞定了。开源有开源的好处，可以看源码，供学习用。但是它的优化不到位，比如Newton-Raphson方法，有一些特殊情况，optimize module的作者就没有考虑进去。他仅仅写了个wrapper,里面的一些细节还需要自己读源码，去补充。所以，对于简单的运算可以信赖numpy,scipy,matlotlib，但是复杂的还是相信matlab好。。。不然耗时太多了。。。</description>
		<content:encoded><![CDATA[<p>上面写错了。glmfit几句话就搞定了。开源有开源的好处，可以看源码，供学习用。但是它的优化不到位，比如Newton-Raphson方法，有一些特殊情况，optimize module的作者就没有考虑进去。他仅仅写了个wrapper,里面的一些细节还需要自己读源码，去补充。所以，对于简单的运算可以信赖numpy,scipy,matlotlib，但是复杂的还是相信matlab好。。。不然耗时太多了。。。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：finallyliuyu</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1210</link>
		<dc:creator>finallyliuyu</dc:creator>
		<pubDate>Mon, 17 May 2010 01:28:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1210</guid>
		<description>结果就不能求出正确解，还老出bug. 但是matlab中如下代码就搞定了。
dataX=[53,57,58,63,66,67,68,69,70,72,73,75,76,78,79,81]
dataY=[0,0,0,0,1,3,1,1,2,1,1,1,2,1,1,1]
dataZ=[1,1,1,1,1,3,1,1,4,1,1,2,2,1,1,1]
dataX=dataX&#039;
dataY=dataY&#039;
dataZ=dataZ&#039;
dataY=[dataY,dataZ]
B=lmfit(dataX, dataY, &#039;binomial&#039;, &#039;link&#039;, &#039;logit&#039;)
结果如下：
B=-15.0429
    0.2322
目前用statistic inference上面的数据做的测试，结果和书上的一样。</description>
		<content:encoded><![CDATA[<p>结果就不能求出正确解，还老出bug. 但是matlab中如下代码就搞定了。<br />
dataX=[53,57,58,63,66,67,68,69,70,72,73,75,76,78,79,81]<br />
dataY=[0,0,0,0,1,3,1,1,2,1,1,1,2,1,1,1]<br />
dataZ=[1,1,1,1,1,3,1,1,4,1,1,2,2,1,1,1]<br />
dataX=dataX&#8217;<br />
dataY=dataY&#8217;<br />
dataZ=dataZ&#8217;<br />
dataY=[dataY,dataZ]<br />
B=lmfit(dataX, dataY, &#8216;binomial&#8217;, &#8216;link&#8217;, &#8216;logit&#8217;)<br />
结果如下：<br />
B=-15.0429<br />
    0.2322<br />
目前用statistic inference上面的数据做的测试，结果和书上的一样。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：finallyliuyu</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1209</link>
		<dc:creator>finallyliuyu</dc:creator>
		<pubDate>Mon, 17 May 2010 01:25:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1209</guid>
		<description>最近想做一个判别式模型分类器。其中就涉及logisitic regression model.
我看sci有optimize包，包中有牛顿迭代法。ncg，而且用它自带的例子运行是成功的。我把最优化函数换成了是的似然函数，函数编写如下
rom scipy.optimize import fmin_ncg
from scipy import *
from numpy import *
import math
dataX=[53,57,58,63,66,67,68,69,70,72,73,75,76,78,79,81]
dataY=[0,0,0,0,1,3,1,1,2,1,1,1,2,1,1,1]
dataZ=[1,1,1,1,1,3,1,1,4,1,1,2,2,1,1,1]
g=[]
def F(A,x):
    result=-exp(A[0]+A[1]*x)/(1+exp(A[0]+A[1]*x))
    return result

def Likelihoood(A,X=dataX,Y=dataY):
    result=0
    
    for i in range(0,len(X)):
            tmp=F(A,X[i])
            if tmp==1:
                tmp==0.9999999
            if tmp&lt;=0:
                tmp=0.0000001
            print tmp
            result=result+ math.log((1-tmp),e)+Y[i]*math.log((tmp/(1-tmp)),e)
    return result
def GradientLikelihoood(A,X=dataX,Y=dataY,Z=dataZ):
    #Z为正例个数
    #求F梯度
    result0=0
    result1=0
    gradientMatrix=zeros(A.shape)
    for i in range(0,len(X)):
        result0=result0+Y[i]-Z[i]*F(A,X[i])
        result1=result1+(Y[i]-Z[i]*F(A,X[i]))*X[i]
    
    gradientMatrix[0]=result0
    gradientMatrix[1]=result1
    return gradientMatrix
def HessianLikelihoood(A,X=dataX,Y=dataY,Z=dataZ):
    HessianMatrix=zeros((2,2))
    for i in range(0,len(X)):
        tmp=F(A,X[i])*(1-F(A,X[i]))
        HessianMatrix[0][0]=HessianMatrix[0][0]+Z[i]*tmp
        HessianMatrix[0][1]=HessianMatrix[0][1]+X[i]*Z[i]*tmp
        HessianMatrix[1][1]=HessianMatrix[1][1]=X[i]**2*Z[i]*tmp
    HessianMatrix[1][0]=HessianMatrix[0][1]
    return HessianMatrix

A0=[10,-9.6]
xopt = fmin_ncg(Likelihoood,A0,GradientLikelihoood,HessianLikelihoood)
print xopt</description>
		<content:encoded><![CDATA[<p>最近想做一个判别式模型分类器。其中就涉及logisitic regression model.<br />
我看sci有optimize包，包中有牛顿迭代法。ncg，而且用它自带的例子运行是成功的。我把最优化函数换成了是的似然函数，函数编写如下<br />
rom scipy.optimize import fmin_ncg<br />
from scipy import *<br />
from numpy import *<br />
import math<br />
dataX=[53,57,58,63,66,67,68,69,70,72,73,75,76,78,79,81]<br />
dataY=[0,0,0,0,1,3,1,1,2,1,1,1,2,1,1,1]<br />
dataZ=[1,1,1,1,1,3,1,1,4,1,1,2,2,1,1,1]<br />
g=[]<br />
def F(A,x):<br />
    result=-exp(A[0]+A[1]*x)/(1+exp(A[0]+A[1]*x))<br />
    return result</p>
<p>def Likelihoood(A,X=dataX,Y=dataY):<br />
    result=0</p>
<p>    for i in range(0,len(X)):<br />
            tmp=F(A,X[i])<br />
            if tmp==1:<br />
                tmp==0.9999999<br />
            if tmp&lt;=0:<br />
                tmp=0.0000001<br />
            print tmp<br />
            result=result+ math.log((1-tmp),e)+Y[i]*math.log((tmp/(1-tmp)),e)<br />
    return result<br />
def GradientLikelihoood(A,X=dataX,Y=dataY,Z=dataZ):<br />
    #Z为正例个数<br />
    #求F梯度<br />
    result0=0<br />
    result1=0<br />
    gradientMatrix=zeros(A.shape)<br />
    for i in range(0,len(X)):<br />
        result0=result0+Y[i]-Z[i]*F(A,X[i])<br />
        result1=result1+(Y[i]-Z[i]*F(A,X[i]))*X[i]</p>
<p>    gradientMatrix[0]=result0<br />
    gradientMatrix[1]=result1<br />
    return gradientMatrix<br />
def HessianLikelihoood(A,X=dataX,Y=dataY,Z=dataZ):<br />
    HessianMatrix=zeros((2,2))<br />
    for i in range(0,len(X)):<br />
        tmp=F(A,X[i])*(1-F(A,X[i]))<br />
        HessianMatrix[0][0]=HessianMatrix[0][0]+Z[i]*tmp<br />
        HessianMatrix[0][1]=HessianMatrix[0][1]+X[i]*Z[i]*tmp<br />
        HessianMatrix[1][1]=HessianMatrix[1][1]=X[i]**2*Z[i]*tmp<br />
    HessianMatrix[1][0]=HessianMatrix[0][1]<br />
    return HessianMatrix</p>
<p>A0=[10,-9.6]<br />
xopt = fmin_ncg(Likelihoood,A0,GradientLikelihoood,HessianLikelihoood)<br />
print xopt</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：52nlp</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1205</link>
		<dc:creator>52nlp</dc:creator>
		<pubDate>Sun, 16 May 2010 15:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1205</guid>
		<description>numpy,scipy除了在美国NASA图像处理中使用外，另外一个主要好处在于开源免费。</description>
		<content:encoded><![CDATA[<p>numpy,scipy除了在美国NASA图像处理中使用外，另外一个主要好处在于开源免费。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：finallyliuyu</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1203</link>
		<dc:creator>finallyliuyu</dc:creator>
		<pubDate>Sun, 16 May 2010 10:06:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1203</guid>
		<description>其实主要是大学matlab用的比较熟，用起来更顺手些，现在正在学那几个工具呢。听说numpy,scipy,在美国NASA图像处理中也用~~</description>
		<content:encoded><![CDATA[<p>其实主要是大学matlab用的比较熟，用起来更顺手些，现在正在学那几个工具呢。听说numpy,scipy,在美国NASA图像处理中也用~~</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：52nlp</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1201</link>
		<dc:creator>52nlp</dc:creator>
		<pubDate>Sun, 16 May 2010 06:18:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1201</guid>
		<description>从你的描述来看，这一块儿你比我清楚很多，不过虽然没有matlab那么强，但也不能说python长于字符串处理而不长于科学计算，好像numpy,scipy,matplotlib这几个工具是很被推崇的，可以仔细研究对比一下。</description>
		<content:encoded><![CDATA[<p>从你的描述来看，这一块儿你比我清楚很多，不过虽然没有matlab那么强，但也不能说python长于字符串处理而不长于科学计算，好像numpy,scipy,matplotlib这几个工具是很被推崇的，可以仔细研究对比一下。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：finallyliuyu</title>
		<link>http://www.52nlp.cn/googles-python-class-sos/comment-page-1#comment-1200</link>
		<dc:creator>finallyliuyu</dc:creator>
		<pubDate>Sun, 16 May 2010 03:12:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.52nlp.cn/?p=3278#comment-1200</guid>
		<description>虽然python带有一些开源的库如numpy,scipy,matplotlib,但是觉得完成python matlab之间的通讯是必要的，python长于字符串处理，而且很多自然语言处理算法是用python实现的，matlab长于大规模科学计算</description>
		<content:encoded><![CDATA[<p>虽然python带有一些开源的库如numpy,scipy,matplotlib,但是觉得完成python matlab之间的通讯是必要的，python长于字符串处理，而且很多自然语言处理算法是用python实现的，matlab长于大规模科学计算</p>
]]></content:encoded>
	</item>
</channel>
</rss>

