上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页
摘要: 经过对Logistic回归理论的学习,推导出取对数后的似然函数为 现在我们的目的是求一个向量,使得最大。其中 对这个似然函数求偏导后得到 根据梯度上升算法有 进一步得到我们可以初始化向量为0,或者随机值,然后进行迭代达到指定的精度为止。1 def sigmoid(inX):2 retur... 阅读全文
posted @ 2014-10-24 09:52 yyxayz 阅读(1473) 评论(0) 推荐(0) 编辑
摘要: python中r的用法,r'str'表示raw string,既忽略转义字符。因为和windows不一样,python中认为\就是转义字符escape sequences的标志。在python2.x中,unicode字符串需要在字符串前加u来表示,比如 str=u'汉字'而在python3.x中,u... 阅读全文
posted @ 2014-10-22 22:41 yyxayz 阅读(2704) 评论(0) 推荐(0) 编辑
摘要: 中文编码问题是用中文的程序员经常头大的问题,在python下也是如此,那么应该怎么理解和解决python的编码问题呢?我们要知道python内部使用的是unicode编码,而外部却要面对千奇百怪的各种编码,比如作为中国程序经常要面对的gbk,gb2312,utf8等,那这些编码是怎么转换成内部的un... 阅读全文
posted @ 2014-10-22 22:40 yyxayz 阅读(77819) 评论(2) 推荐(13) 编辑
摘要: 输出最大长度的回文子串。 1 string longestPalindrome(string s) 2 { 3 4 5 int id, mx, i, j, len, maxlen; 6 vector cvec; 7 vector ivec; 8 string st... 阅读全文
posted @ 2014-10-21 10:17 yyxayz 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters... 阅读全文
posted @ 2014-10-20 19:30 yyxayz 阅读(209) 评论(0) 推荐(0) 编辑
摘要: python print格式化输出。1. 打印字符串print ("His name is %s"%("Aviad"))效果:2.打印整数print ("He is %d years old"%(25))效果:3.打印浮点数print ("His height is %f m"%(1.83))效果:... 阅读全文
posted @ 2014-10-19 20:14 yyxayz 阅读(399) 评论(0) 推荐(0) 编辑
摘要: strip函数原型声明:s为字符串,rm为要删除的字符序列. 只能删除开头或是结尾的字符或是字符串。不能删除中间的字符或是字符串。s.strip(rm) 删除s字符串中开头、结尾处,位于rm删除序列的字符s.lstrip(rm) 删除s字符串中开头处,位于rm删除序列的字符s.rstrip(rm) ... 阅读全文
posted @ 2014-10-19 09:54 yyxayz 阅读(95139) 评论(0) 推荐(11) 编辑
摘要: operator.itemgetter函数operator模块提供的itemgetter函数用于获取对象的哪些维的数据,参数为一些序号(即需要获取的数据在对象中的序号),下面看例子。a = [1,2,3]>>> b=operator.itemgetter(1) //定义函数b,获取对象的第1个域... 阅读全文
posted @ 2014-10-19 08:18 yyxayz 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 在Python中使用help帮助>>> import numpy>>> help(numpy.argsort)Help on function argsort in module numpy.core.fromnumeric:argsort(a, axis=-1, kind='quicksort',... 阅读全文
posted @ 2014-10-18 23:21 yyxayz 阅读(1035) 评论(0) 推荐(0) 编辑
摘要: http://blog.csdn.net/nkwangjie/article/details/17298851 阅读全文
posted @ 2014-10-18 22:39 yyxayz 阅读(538) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 下一页