2007年10月31日 星期三 21:34
各位大虾, 本人是新手,以前接触过MATLAB,向大家求助一段程序的理解,标注红色的部分怎么理解?training_data的格式:{0 or 1, [x1 x2 x3 ......] } for后面跟两项是什么意思? def makeBalls(training_data, distance_function, epsilon = 1): balls = [] # loop through center points for (is_positive, center_datapoint ) in training_data: # loop through edge points for (edge_is_positive, edge_datapoint) in training_data: if (not edge_is_positive): continue radius = distance_function(center_datapoint, edge_datapoint) #if (radius==0): # continue # skip over 0-radius balls (TODO: this could be optimized) if (is_positive): new_ball = ddBall(is_positive, center_datapoint, radius+epsilon, distance_function) else: new_ball = ddBall(is_positive, center_datapoint, radius-epsilon, distance_function) balls.append ( new_ball ) return balls -- XunKai Wei IEEE Member Air Force Engineering University Xi'an, China Email:xunkai.wei at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20071031/a4406246/attachment.html
2007年10月31日 星期三 21:38
training_dataÀïÃæÊǶþÔª×éÁÐ±í¡£Äã¿ÉÒÔÏëÏó³É((x1,y1),(x2,y2)....)ÕâÑùµÄ£¬Ã¿´Îfor¶¼°Ñx1ºÍx2Ò»ÆðÈ¡³öÀ´¡£ gaohawk 2007-10-31 ·¢¼þÈË£º xunkai wei ·¢ËÍʱ¼ä£º 2007-10-31 21:35:54 ÊÕ¼þÈË£º python-chinese在lists.python.cn ³ËÍ£º Ö÷Ì⣺ [python-chinese] Help ¸÷λ´óϺ£¬ ±¾ÈËÊÇÐÂÊÖ£¬ÒÔÇ°½Ó´¥¹ýMATLAB£¬Ïò´ó¼ÒÇóÖúÒ»¶Î³ÌÐòµÄÀí½â£¬±ê×¢ºìÉ«µÄ²¿·ÖÔõôÀí½â£¿training_dataµÄ¸ñʽ£º{0 or 1, [x1 x2 x3 ......] } forºóÃæ¸úÁ½ÏîÊÇʲôÒâ˼£¿ def makeBalls(training_data, distance_function, epsilon = 1): balls = [] # loop through center points for (is_positive, center_datapoint ) in training_data: # loop through edge points for (edge_is_positive, edge_datapoint) in training_data: if (not edge_is_positive): continue radius = distance_function(center_datapoint, edge_datapoint) #if (radius==0): # continue # skip over 0-radius balls (TODO: this could be optimized) if (is_positive): new_ball = ddBall(is_positive, center_datapoint, radius+epsilon, distance_function) else: new_ball = ddBall(is_positive, center_datapoint, radius-epsilon, distance_function) balls.append ( new_ball ) return balls -- XunKai Wei IEEE Member Air Force Engineering University Xi'an, China Email:xunkai.wei在gmail.com -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071031/963c117d/attachment.htm
2007年10月31日 星期三 21:44
哈哈,茅塞顿开啊,谢谢您的热心帮助! 相当于每次一个元组,而这个元组包含两项是吗?我查半天没有见过这种格式,非常感谢! 询楷 On 10/31/07, gaohawk <gaohawk at gmail.com> wrote: > > training_data里面是二元组列表。你可以想象成((x1,y1),(x2,y2)....)这样的,每次for都把x1和x2一起取出来。 > > ------------------------------ > gaohawk > 2007-10-31 > ------------------------------ > *发件人:* xunkai wei > *发送时间:* 2007-10-31 21:35:54 > *收件人:* python-chinese at lists.python.cn > *抄送:* > *主题:* [python-chinese] Help > > 各位大虾, > > 本人是新手,以前接触过MATLAB,向大家求助一段程序的理解,标注红色的部分怎么理解?training_data的格式:{0 or 1, [x1 > x2 x3 ......] } > > for后面跟两项是什么意思? > > > def makeBalls(training_data, distance_function, epsilon = 1): > > balls = [] > > # loop through center points > for (is_positive, center_datapoint ) in training_data: > > # loop through edge points > for (edge_is_positive, edge_datapoint) in training_data: > > if (not edge_is_positive): > > continue > > radius = distance_function(center_datapoint, edge_datapoint) > > #if (radius==0): > # continue # skip over 0-radius balls (TODO: this could be > optimized) > > if (is_positive): > new_ball = ddBall(is_positive, center_datapoint, > radius+epsilon, distance_function) > else: > new_ball = ddBall(is_positive, center_datapoint, > radius-epsilon, distance_function) > balls.append ( new_ball ) > > return balls > > -- > XunKai Wei > IEEE Member > Air Force Engineering University > Xi'an, China > Email:xunkai.wei at gmail.com > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -- XunKai Wei IEEE Member Air Force Engineering University Xi'an, China Email:xunkai.wei at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20071031/56c6cfd8/attachment-0001.html
Zeuux © 2025
京ICP备05028076号