java 板


LINE

※ 引述《ken915007 (Ken_Wu)》之铭言: : 目前正在使用java实作data mining的方法... : 实作中,在想一个问题,就是字串比对 : 怎样的字串比对才有效率? : 推 qrtt1:看能不能在资料前处理时统一成数字, 要结果再转成字串 12/05 08:20 : → ken915007:若item要是多的话…这样转数字~最後在反转~也是要时间 12/05 12:12 : → ken915007:酷!! 难道不能这样用?还是比较不好?? 12/05 12:14 : → qrtt1:处理简单的型别绝对比物件来的有效率 12/05 13:41 : → qrtt1:关联用 fp-tree 比较有效率的说 :P 12/05 13:43 : 嗯! 我有看过这些方法~但精准度apriori会比较高点...所以才想用apriori, : 但缺点就是要重覆扫资料... : 有点离题了^^ 重点不是这演算法= = : 我想知道对於字串的比对~像上面的范例~大家会用什麽方法去比对是否有出现过 如果 input data 没有可 exploit 的性质 且 algorithm 一定得写成原文中所述的话 那我目前只能想到 「确认所有的 String 比对使用 hashCode 以 fail-fast」 这就要去读 JDK source code 去看 containsAll() 及 String.Equals 的实作 还有 String.hashCode 有无把 hashCode cache 起来 如果没有的话,可以把 String 包成另一个 class 再实作 hashCode cache class StringAndCachedHashCode { Int32? hashCode = null; String string; internal StringAndCachedHashCode(String string) { this.string = string. } internal Int32 hashCode() { if (hashCode.HasValue) return hashCode.Value; else { hashCode = string.hashCode(); return hashCode.Value; } } } 再要更上层楼的话,就得确认 containsAll() 有实作 fail-fast 且还可以对 input data 做 statistical analysis 看能不能让 containsAll() fail-fast-er :p (例: always 从最稀有的 element 开始 check 'containsAll()') 另外一件很重要的事,这里碎碎念一下 performance tuning 与任何其他的 scientific method 没有不一样的地方 perf tuning 的新手最常犯的一个错误就是疯狂的把所有能想到的手段都试作 却没有严谨地检视 ROI (return of investment) 我会建议原 po 这样做: 1. Identify a set of well-understood test data. 2. Set your perf. tuning goal 3. Identify a method to measure against your perf. goal. 4. Watch your code under a profiler and identify the type of improvment that can bring you the biggest ROI 5. Implement the improvement 6. Test your new implementation with the test data from step#1. 7. Measure perf. improvement with the method from step#3. 8. Only if you have not met your perf. tuning goal, go back to step#4. Otherwise, call it a day. 当然,如果没有 deadline 或有无限的时间…以上方法自然不适用… XD --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 65.87.177.87 ※ 编辑: AmosYang 来自: 65.87.177.87 (12/05 17:33)
1F:→ AmosYang:呃 那段code迷迷糊糊的写成C#了 懒得改了 看得懂就好 :) 12/05 17:39
2F:→ ken915007:呵呵~感谢^^ 刚刚在看code想说怎麽看起来怪怪的= = 12/05 17:44
3F:→ ken915007:我在想你的ROI是对哪部份?还有deadline是指哪部份? 12/05 17:59
4F:推 ken915007:我才疏学浅…会比较不快理解~请多包含^^ 12/05 18:02
5F:→ ken915007: 涵 12/05 18:04
ROI := return of investment 中文可以翻作 投资报酬 ? deadline -- 作业/报告/老板耐心 的期限 易言之,最後这一段我想讲的是「perf. tuning 的 engineer practice」 有的时候一些 tweak 在理论上会有帮助 但实质上效益却不大,且要花很多时间去实作 这就是所谓的 low ROI 这就只能靠良好的 engineer practice / scientific method 去验证 通常 80/20 rule 很少出错;在学校里教导的是 software engineering 但在现实生活中能养活人的是 software business perfect solution 的 ROI 多半不如 something just good enough 有些道理我也无法三言两言说得很清楚 :) 反正如果没有 deadline 的话一切好谈 XD ※ 编辑: AmosYang 来自: 65.87.177.87 (12/05 18:24) ※ 编辑: AmosYang 来自: 65.87.177.87 (12/05 18:25)
6F:推 ken915007:ROI我知道是什麽…只是不明你所讲的是哪部分而已^^~感谢 12/05 19:01







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Gossiping站内搜寻

TOP