Giter VIP home page Giter VIP logo

Comments (12)

zj1244 avatar zj1244 commented on August 17, 2024 3

你说的是对的,这个肯定是错误。不止这里有问题,12-3.py也有这个问题。作者好像对于FreqDist这个理解有误了。
dist_max=set(fdist[0:50])
作者理解的是fdist应该是从大到小的排列,所以才会用[0:50],但是实际上fdist是无序排列的。这也导致了之后的代码都是错的

from 1book.

Hecbi avatar Hecbi commented on August 17, 2024

多谢楼上的回答。

from 1book.

HackBraid avatar HackBraid commented on August 17, 2024

多谢楼上的楼上解答了,囧

from 1book.

UnnameBao avatar UnnameBao commented on August 17, 2024

请问大家改对以后算出的准确率是多少啊,我的是100%....

from 1book.

lhwlhw90 avatar lhwlhw90 commented on August 17, 2024

@UnnameBao 我也是100%哎

from 1book.

aviraonepiece avatar aviraonepiece commented on August 17, 2024

@UnnameBao @lhwlhw90 请问你们是怎么改正的?求代码,我机器学习刚入门,求指教

from 1book.

UnnameBao avatar UnnameBao commented on August 17, 2024

@aviraonepiece 我是这样改的

fdist = FreqDist(dist).keys()
dist_max=set(fdist[0:50])
dist_min = set(fdist[-50:])
改成
fdist = sorted(FreqDist(dist).items(),key = operator.itemgetter(1),reverse = True) #获得操作命令使用频率并排序
dist_max = set([item[0] for item in fdist[:50]]) #取出前50个操作命令的指令
dist_min = set([item[0] for item in fdist[-50:]]) #取出前50个操作命令的指令

from 1book.

aviraonepiece avatar aviraonepiece commented on August 17, 2024

@UnnameBao 十分感谢!!!!!!follow

from 1book.

xiaoyuge16 avatar xiaoyuge16 commented on August 17, 2024

可以利用pandas来做:
import pandas as pd
fdist=nltk.FreqDist(dist)
ser=pd.Series(fdist)
sersort = ser.sort_values()#按照升序排列
dist_min = sersort.index[0:50].tolist()#取出频率最小的前50个操作命令
dist_max = sersort.index[-50:].tolist()#取出频率最大的最后50个操作命令

from 1book.

UnnameBao avatar UnnameBao commented on August 17, 2024

@xiaoyuge16 学习了,pandas了解的少。

from 1book.

HersinSu avatar HersinSu commented on August 17, 2024

到这里才发现代码是python2,orz。
FreqDist.keys()在python3返回的不再是一个列表了
需要自己转换一下

from 1book.

zxibang avatar zxibang commented on August 17, 2024

我用的python3.8,这部分代码我改成这样:
fdist = FreqDist(dist)
keys = np.array(fdist.most_common(len(fdist)))[:,0].tolist()
dist_max = keys[:50] #取出频率最大的前50个操作命令
dist_min = keys[-50:] #取出频率最小的前50个操作命令
改完以后算出的准确率是100%,就很迷。。

from 1book.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.