Python 贝叶斯在文本分类的应用案例

2023-11-09

关注微信公共号:小程在线

关注CSDN博客:程志伟的博客

 

1.1 文本编码技术简介
1.1.1 单词计数向量

在开始分类之前,我们必须先将文本编码成数字。一种常用的方法是单词计数向量。在这种技术中,一个样本可以包
含一段话或一篇文章,这个样本中如果出现了10个单词,就会有10个特征(n=10),每个特征 代表一个单词,特征
的取值 表示这个单词在这个样本中总共出现了几次,是一个离散的,代表次数的,正整数。
在sklearn当中,单词计数向量计数可以通过feature_extraction.text模块中的CountVectorizer类实现,来看一个简
单的例子:
 

sample = ["Machine learning is fascinating, it is wonderful"
          ,"Machine learning is a sensational techonology"
          ,"Elsa is a popular character"]

from sklearn.feature_extraction.text import CountVectorizer
vec = CountVectorizer()
X = vec.fit_transform(sample)
X
Out[8]: 
<3x11 sparse matrix of type '<class 'numpy.int64'>'
    with 15 stored elements in Compressed Sparse Row format>

 

#使用接口get_feature_names()调用每个列的名
vec.get_feature_names()
Out[9]: 
['character',
 'elsa',
 'fascinating',
 'is',
 'it',
 'learning',
 'machine',
 'popular',
 'sensational',
 'techonology',
 'wonderful']


import pandas as pd
#注意稀疏矩阵是无法输入pandas的,1表示出现,0表示未出现
CVresult = pd.DataFrame(X.toarray(),columns = vec.get_feature_names())
CVresult
Out[11]: 
   character  elsa  fascinating  ...  sensational  techonology  wonderful
0          0     0            1  ...            0            0          1
1          0     0            0  ...            1            1          0
2          1     1            0  ...            0            0          0

[3 rows x 11 columns]

如果我们将每一列加和,除以整个特征矩阵的和,就是每一列对应的概率 。由于是将 进行加和,对于一个在很多个特征下都有值的样本来说,这个样本在对 的贡献就会比其他的样本更大。对于句子特别长的样本而言,这个样本对 的影响是巨大的。因此补集朴素贝叶斯让每个特征的权重除以自己的L2范式,就是为了避免这种情况发生。


第二个问题,观察我们的矩阵,会发现"is"这个单词出现了四次,那经过计算,这个单词出现的概率就会最大,但其实它对我们的语义并没有什么影响(除非我们希望判断的是,文章描述的是过去的事件还是现在发生的事件)。可以遇见,如果使用单词计数向量,可能会导致一部分常用词(比如中文中的”的“)频繁出现在我们的矩阵中并且占有很高的权重,对分类来说,这明显是对算法的一种误导。为了解决这个问题,比起使用次数,我们使用单词在句子中所占的比例来编码我们的单词,这就是我们著名的TF-IDF方法
 

1.1.2 TF-IDF
IDF的大小与一个词的常见程度成反比,这个词越常见,编码后为它设置的权重会倾向于越小,以此来压制频繁出现的一些无意义的词

from sklearn.feature_extraction.text import TfidfVectorizer as TFIDF
vec = TFIDF()
X = vec.fit_transform(sample)
X
Out[12]: 
<3x11 sparse matrix of type '<class 'numpy.float64'>'
    with 15 stored elements in Compressed Sparse Row format>

 

#同样使用接口get_feature_names()调用每个列的名称
TFIDFresult = pd.DataFrame(X.toarray(),columns=vec.get_feature_names())
TFIDFresult
Out[13]: 
   character      elsa  fascinating  ...  sensational  techonology  wonderful
0   0.000000  0.000000     0.424396  ...     0.000000     0.000000   0.424396
1   0.000000  0.000000     0.000000  ...     0.534093     0.534093   0.000000
2   0.546454  0.546454     0.000000  ...     0.000000     0.000000   0.000000

[3 rows x 11 columns]

CVresult.sum(axis=0).sum()
Out[14]: 16

 

#使用TF-IDF编码之后,出现得多的单词的权重被降低了么?
CVresult.sum(axis=0)/CVresult.sum(axis=0).sum()
Out[15]: 
character      0.0625
elsa           0.0625
fascinating    0.0625
is             0.2500
it             0.0625
learning       0.1250
machine        0.1250
popular        0.0625
sensational    0.0625
techonology    0.0625
wonderful      0.0625
dtype: float64

TFIDFresult.sum(axis=0) / TFIDFresult.sum(axis=0).sum()
Out[16]: 
character      0.083071
elsa           0.083071
fascinating    0.064516
is             0.173225
it             0.064516
learning       0.110815
machine        0.110815
popular        0.083071
sensational    0.081192
techonology    0.081192
wonderful      0.064516
dtype: float64

可以发现is的权重由0.25下降为0.17

 

 

1.2 探索文本数据

#初次使用这个数据集的时候,会在实例化的时候开始下载
from sklearn.datasets import fetch_20newsgroups

data = fetch_20newsgroups()

 

#通常我们使用data来查看data里面到底包含了什么内容,但由于fetch_20newsgourps这个类加载出的数据巨大,数
据结构中混杂很多文字,因此很难去看清
#不同类型的新闻

data.target_names
Out[19]: 
['alt.atheism',
 'comp.graphics',
 'comp.os.ms-windows.misc',
 'comp.sys.ibm.pc.hardware',
 'comp.sys.mac.hardware',
 'comp.windows.x',
 'misc.forsale',
 'rec.autos',
 'rec.motorcycles',
 'rec.sport.baseball',
 'rec.sport.hockey',
 'sci.crypt',
 'sci.electronics',
 'sci.med',
 'sci.space',
 'soc.religion.christian',
 'talk.politics.guns',
 'talk.politics.mideast',
 'talk.politics.misc',
 'talk.religion.misc']

fetch_20newsgroups 参数列表:
subset : 选择类中包含的数据子集
输入"train"表示选择训练集,“test"表示输入测试集,”all"表示加载所有的数据
categories : 可输入None或者数据所在的目录
选择一个子集下,不同类型或不同内容的数据所在的目录。如果不输入默认None,则会加载全部的目录。
download_if_missing:可选,默认是True
如果发现本地数据不全,是否自动进行下载
shuffle : 布尔值,可不填,表示是否打乱样本顺序
对于假设样本之间互相独立并且服从相同分布的算法或模型(比如随机梯度下降)来说可能很重要


 

import numpy as np
import pandas as pd
categories = ["sci.space" #科学技术 - 太空
              ,"rec.sport.hockey" #运动 - 曲棍球
              ,"talk.politics.guns" #政治 - 枪支问题
              ,"talk.politics.mideast"] #政治 - 中东问题
train = fetch_20newsgroups(subset="train",categories = categories)
test = fetch_20newsgroups(subset="test",categories = categories)

train.target_names
Out[21]: 
['rec.sport.hockey',
 'sci.space',
 'talk.politics.guns',
 'talk.politics.mideast']

 

#查看总共有多少篇文章存在

len(train.data)
Out[22]: 2303

 

#随意提取一篇文章来看看
train.data[0]
Out[23]: "From: tvartiai@vipunen.hut.fi (Tommi Vartiainen)\nSubject: Re: Finland/Sweden vs.NHL teams (WAS:Helsinki/Stockholm & NHL expansion)\nNntp-Posting-Host: vipunen.hut.fi\nOrganization: Helsinki University of Technology, Finland\nLines: 51\n\nIn <1993Apr16.195754.5476@ousrvr.oulu.fi> mep@phoenix.oulu.fi (Marko Poutiainen) writes:\n\n>: FINLAND:  \n>: \n>: D-Jyrki Lumme.......20\n>: D-Teppo Numminen....20\n>: D-Peter Ahola.......13\n>: \n>Well well, they don't like our defenders (mainly Lumme and Numminen)...\n\nAbout 25 is correct for Numminen and Lumme.\n\n\n>: R-Teemu Selanne.....27\n>: \n>Compared to Kurri, Selanne's points are too high, lets make it 25 or 26.\n\nNo, Kurri's points are too low. 27 for Kurri and 28 for Sel{nne.\n\n>: well in the Canada Cup and World Championships largely due to the efforts of\n>: Markus Ketterer (the goalie), 3-4 or the players listed above and luck. There's\n>: presumably a lot of decent players in Finland that wouldn't be superstars at\n>: the highest level but still valuable role players, however. My guess would be\n>: that the Finnish Canada Cup team would be a .500 team in the NHL.\n\n>Wow, now, it looks like you don't like our players? What about guys like:\n>Nieminen, Jutila, Riihijarvi, Varvio, Laukkanen, Makela, Keskinen and (even\n>if he is aging) Ruotsalainen? The main difference between finnish and North-\n>American players is, that our players tend to be better in the larger rink.\n>The Canadian defenders are usually slower that defenders in Europe. \n>And I think that there was more in our success than Ketterer and luck (though\n>they helped). I think that the main reason was, that the team worked well\n>together.\n\n\nThat's true. Game is so different here in Europe compared to NHL. North-ame-\nricans are better in small rinks and europeans in large rinks. An average\neuropean player from Sweden, Finland, Russian or Tsech/Slovakia is a better \nskater and  puckhandler than his NHL colleague. Especially defenders in NHL\nare mainly slow and clumsy. Sel{nne has also said that in the Finnish Sm-league\ngame is more based on skill than in NHL. In Finland he couldn't get so many \nbreakaways because defenders here are an average much better skaters than in\nNHL. Also Alpo Suhonen said that in NHL Sel{nne's speed accentuates because\nof clumsy defensemen.\n\nI have to admit that the best players come from Canada, but those regulars\naren't as skilful as regulars in the best european leagues. Also top europeans\nare in the same level as the best north-americans.(except Lemieux is in the\nclass of his own). \n\nTommi\n"

 

#查看一下我们的标签
np.unique(train.target)
Out[24]: array([0, 1, 2, 3], dtype=int64)

len(train.target)
Out[25]: 2303

 

#是否存在样本不平衡问题?
for i in [1,2,3]:
    print(i,(train.target == i).sum()/len(train.target))
1 0.25749023013460703
2 0.23708206686930092
3 0.24489795918367346

 

1.3 使用TF-IDF将文本数据编码
from sklearn.feature_extraction.text import TfidfVectorizer as TFIDF

Xtrain = train.data
Xtest = test.data
Ytrain = train.target
Ytest = test.target

tfidf = TFIDF().fit(Xtrain)
Xtrain_ = tfidf.transform(Xtrain)
Xtest_ = tfidf.transform(Xtest)
Xtrain_
Out[29]: 
<2303x40725 sparse matrix of type '<class 'numpy.float64'>'
    with 430306 stored elements in Compressed Sparse Row format>

tosee = pd.DataFrame(Xtrain_.toarray(),columns=tfidf.get_feature_names())
tosee.head()
Out[30]: 
    00       000  0000  00000  000000  ...   zy  zyg   zz  zz_g9q3  zzzzzz
0  0.0  0.000000   0.0    0.0     0.0  ...  0.0  0.0  0.0      0.0     0.0
1  0.0  0.000000   0.0    0.0     0.0  ...  0.0  0.0  0.0      0.0     0.0
2  0.0  0.058046   0.0    0.0     0.0  ...  0.0  0.0  0.0      0.0     0.0
3  0.0  0.000000   0.0    0.0     0.0  ...  0.0  0.0  0.0      0.0     0.0
4  0.0  0.000000   0.0    0.0     0.0  ...  0.0  0.0  0.0      0.0     0.0

[5 rows x 40725 columns]

tosee.shape
Out[31]: (2303, 40725)

 

 

1.4 在贝叶斯上分别建模,查看结果from sklearn.naive_bayes import MultinomialNB, ComplementNB, BernoulliNB
from sklearn.metrics import brier_score_loss as BS
name = ["Multinomial","Complement","Bournulli"]
#注意高斯朴素贝叶斯不接受稀疏矩阵
models = [MultinomialNB(),ComplementNB(),BernoulliNB()]
for name,clf in zip(name,models):
    clf.fit(Xtrain_,Ytrain)
    y_pred = clf.predict(Xtest_)
    proba = clf.predict_proba(Xtest_)
    score = clf.score(Xtest_,Ytest)
    print(name)
    #4个不同的标签取值下的布里尔分数
    Bscore = []
    for i in range(len(np.unique(Ytrain))):
        bs = BS(Ytest==i,proba[:,i],pos_label=i)
        Bscore.append(bs)
        print("\tBrier under {}:{:.3f}".format(train.target_names[i],bs))
    print("\tAverage Brier:{:.3f}".format(np.mean(Bscore)))
    print("\tAccuracy:{:.3f}".format(score))
    print("\n")
Multinomial
        Brier under rec.sport.hockey:0.857
        Brier under sci.space:0.033
        Brier under talk.politics.guns:0.169
        Brier under talk.politics.mideast:0.178
        Average Brier:0.309
        Accuracy:0.975


Complement
        Brier under rec.sport.hockey:0.804
        Brier under sci.space:0.039
        Brier under talk.politics.guns:0.137
        Brier under talk.politics.mideast:0.160
        Average Brier:0.285
        Accuracy:0.986


Bournulli
        Brier under rec.sport.hockey:0.925
        Brier under sci.space:0.025
        Brier under talk.politics.guns:0.205
        Brier under talk.politics.mideast:0.193
        Average Brier:0.337
        Accuracy:0.902

从结果上来看,两种贝叶斯的效果都很不错。虽然补集贝叶斯的布里尔分数更高,但它的精确度更高。我们可以使用
概率校准来试试看能否让模型进一步突破。

 

from sklearn.calibration import CalibratedClassifierCV
name = ["Multinomial"
        ,"Multinomial + Isotonic"
        ,"Multinomial + Sigmoid"
        ,"Complement"
        ,"Complement + Isotonic"
        ,"Complement + Sigmoid"
        ,"Bernoulli"
        ,"Bernoulli + Isotonic"
        ,"Bernoulli + Sigmoid"]
models = [MultinomialNB()
    ,CalibratedClassifierCV(MultinomialNB(), cv=2, method='isotonic')
    ,CalibratedClassifierCV(MultinomialNB(), cv=2, method='sigmoid')
    ,ComplementNB()
    ,CalibratedClassifierCV(ComplementNB(), cv=2, method='isotonic')
    ,CalibratedClassifierCV(ComplementNB(), cv=2, method='sigmoid')
    ,BernoulliNB()
    ,CalibratedClassifierCV(BernoulliNB(), cv=2, method='isotonic')
    ,CalibratedClassifierCV(BernoulliNB(), cv=2, method='sigmoid')
    ]
for name,clf in zip(name,models):
    clf.fit(Xtrain_,Ytrain)
    y_pred = clf.predict(Xtest_)
    proba = clf.predict_proba(Xtest_)
    score = clf.score(Xtest_,Ytest)
    print(name)
    Bscore = []
    for i in range(len(np.unique(Ytrain))):
        bs = BS(Ytest==i,proba[:,i],pos_label=i)
        Bscore.append(bs)
        print("\tBrier under {}:{:.3f}".format(train.target_names[i],bs))
    print("\tAverage Brier:{:.3f}".format(np.mean(Bscore)))
    print("\tAccuracy:{:.3f}".format(score))
    print("\n")
Multinomial
        Brier under rec.sport.hockey:0.857
        Brier under sci.space:0.033
        Brier under talk.politics.guns:0.169
        Brier under talk.politics.mideast:0.178
        Average Brier:0.309
        Accuracy:0.975


Multinomial + Isotonic
        Brier under rec.sport.hockey:0.980
        Brier under sci.space:0.012
        Brier under talk.politics.guns:0.226
        Brier under talk.politics.mideast:0.228
        Average Brier:0.362
        Accuracy:0.973


Multinomial + Sigmoid
        Brier under rec.sport.hockey:0.968
        Brier under sci.space:0.012
        Brier under talk.politics.guns:0.219
        Brier under talk.politics.mideast:0.222
        Average Brier:0.355
        Accuracy:0.973


Complement
        Brier under rec.sport.hockey:0.804
        Brier under sci.space:0.039
        Brier under talk.politics.guns:0.137
        Brier under talk.politics.mideast:0.160
        Average Brier:0.285
        Accuracy:0.986


Complement + Isotonic
        Brier under rec.sport.hockey:0.984
        Brier under sci.space:0.007
        Brier under talk.politics.guns:0.227
        Brier under talk.politics.mideast:0.230
        Average Brier:0.362
        Accuracy:0.985


Complement + Sigmoid
        Brier under rec.sport.hockey:0.970
        Brier under sci.space:0.009
        Brier under talk.politics.guns:0.217
        Brier under talk.politics.mideast:0.221
        Average Brier:0.354
        Accuracy:0.986


Bernoulli
        Brier under rec.sport.hockey:0.925
        Brier under sci.space:0.025
        Brier under talk.politics.guns:0.205
        Brier under talk.politics.mideast:0.193
        Average Brier:0.337
        Accuracy:0.902


Bernoulli + Isotonic
        Brier under rec.sport.hockey:0.957
        Brier under sci.space:0.014
        Brier under talk.politics.guns:0.164
        Brier under talk.politics.mideast:0.181
        Average Brier:0.329
        Accuracy:0.952


Bernoulli + Sigmoid
        Brier under rec.sport.hockey:0.825
        Brier under sci.space:0.030
        Brier under talk.politics.guns:0.153
        Brier under talk.politics.mideast:0.160
        Average Brier:0.292
        Accuracy:0.879

可以观察到,多项式分布下无论如何调整,算法的效果都不如补集朴素贝叶斯来得好。因此我们在分类的时候,应该
选择补集朴素贝叶斯。对于补集朴素贝叶斯来说,使用Sigmoid进行概率校准的模型综合最优秀:准确率最高,对数
损失和布里尔分数都在0.1以下,可以说是非常理想的模型了。
 

对于机器学习而言,朴素贝叶斯也许不是最常用的分类算法,但作为概率预测算法中唯一一个真正依赖概率来进行计
算,并且简单快捷的算法,朴素贝叶斯还是常常被人们提起。并且,朴素贝叶斯在文本分类上的效果的确非常优秀。
由此可见,只要我们能够提供足够的数据,合理利用高维数据进行训练,朴素贝叶斯就可以为我们提供意想不到的效
果。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Python 贝叶斯在文本分类的应用案例 的相关文章

  • 如何打印前面有一定数量空格的整数?

    C has printf Xd Y 它只打印整数 X 并使其在控制台窗口上占据 Y 空格 例如 printf 3d 10 console 10 printf 5d 5 console 5 我如何在 python 3 中使用它 This pr
  • 函数名称未定义

    我有一段代码 看起来像这样 if name main main def main print hello 但是 当我尝试运行此代码时 出现错误 NameError 名称 main 未定义 我是否没有在函数 def main 的第一行定义名称
  • 在 SQLAlchemy 中,过滤器是在连接之前还是之后应用?

    使用 SQLAlchemy 我执行如下查询 import models as m import sqlalchemy as sa s session maker q s query m ShareCount m Article join m
  • 有什么好的适用于 Google App Engine 应用程序的 AJAX 框架吗? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我正在尝试在我的 Google App Engine 应用程序中实现 AJAX 因此我正在寻找一个好的
  • 是否可以在 IPython 控制台中显示 pandas 样式?

    是否可以显示熊猫风格 https pandas pydata org pandas docs stable user guide style html在 iPython 控制台中 Jupyter 笔记本中的以下代码 import panda
  • 在 Python 中延迟转置列表

    所以 我有一个延迟生成的可迭代的三元组 我试图弄清楚如何将其转换为 3 个可迭代对象 分别由元组的第一个 第二个和第三个元素组成 然而 我希望这件事能懒惰地完成 所以 举例来说 我希望 1 2 3 4 5 6 7 8 9 将变成 1 4 7
  • caffe安装:opencv libpng16.so.16链接问题

    我正在尝试在 Ubuntu 14 04 机器上使用 python 接口编译 caffe 我已经安装了 Anaconda 和 opencvconda install opencv 我还安装了咖啡中规定的所有要求 并更改了注释块makefile
  • DataFrame.loc 的“索引器太多”

    我读了关于切片器的文档 http pandas pydata org pandas docs stable advanced html using slicers一百万次 但我从来没有理解过它 所以我仍在试图弄清楚如何使用loc切片Data
  • 获取字符串模板中所有标识符列表的函数(Python)

    对于标准库string template在Python中 有没有一个函数可以获取所有标识符的列表 例如 使用以下 xml 文件
  • lmfit模型拟合然后预测

    我正在领养lmfit进行曲线拟合并使用拟合模型进行预测 然而下面的代码并没有达到我想要的效果 能否请你帮忙 谢谢 import numpy as np from lmfit import Model def linearModel x a0
  • argparse 不检查位置参数

    我正在创建一个脚本 它使用 argparse 接受位置参数和可选参数 我已经阅读了 Doug 的教程和 python 文档 但找不到答案 parser argparse ArgumentParser description script t
  • 尝试校准keras模型

    我正在尝试通过 Sklearn 实现来校准我的 CNN 模型CalibratedClassifierCV 尝试将其包装为KerasClassifier并覆盖预测功能但没有成功 有人可以说我做错了什么吗 这是模型代码 def create m
  • Python FTP下载550错误

    我编写了一个 ftp 爬虫来下载特定文件 它会一直工作 直到找到要下载的特定文件 然后抛出此错误 ftplib error perm 550 该文件存在于我的下载文件夹中 但文件大小为 0 kb 我需要转换某些内容才能下载吗 我可以访问 f
  • 如何在 python 中使用交叉验证执行 GridSearchCV

    我正在执行超参数调整RandomForest如下使用GridSearchCV X np array df features all features y np array df gold standard labels x train x
  • Pandas 中每列的曲线拟合 + 外推值

    我有一个包含大约 300 列的数据集 每一列都与深度相关 Pandas DataFrame 的简化版本看起来像这样 import matplotlib pyplot as plt import numpy as np import pand
  • 为什么 pip 已经是最新的了却要求我升级?

    我全新安装了 python 3 7 1 64 位 并使用最新的 pyCharm 作为我的 IDE 我在这台机器上没有安装其他 python 我去安装 numpy 并收到以下消息 venv C Users John PycharmProjec
  • Pygame:有人可以帮我实现双跳吗?

    我知道已经有其他关于此问题的帖子了 但我的运动系统与我发现的有点不同 所以随后我问这个问题 我的运动系统基于一个名为的命名元组Move up left right down 然后就是这个 def update self move block
  • 如何将 pandas DataFrame 转换为 TimeSeries?

    我正在寻找一种将 DataFrame 转换为 TimeSeries 而不拆分索引和值列的方法 有任何想法吗 谢谢 In 20 import pandas as pd In 21 import numpy as np In 22 dates
  • Django 中使用外键的抽象基类继承

    我正在尝试在 Django 支持的网站上进行模型继承 以遵守 DRY 我的目标是使用一个名为 BasicCompany 的抽象基类来为三个子类提供通用信息 Butcher Baker CandlestickMaker 它们位于各自的应用程序
  • 如何使用 keras.backend.gradients() 获取梯度值

    我试图获得 Keras 模型的输出相对于模型输入 x 而不是权重 的导数 似乎最简单的方法是使用 keras backend 中的 梯度 它返回梯度张量 https keras io backend https keras io backe

随机推荐

  • Acwing789. 数的范围

    Acwing789 数的范围 题目描述 代码展示 题目描述 代码展示 include
  • C# 获取System.Color 中所有颜色

    将 System Color 中的全部颜色提取出来 经过简单筛选后打乱顺序 做成随机颜色数组 用于存取取出的颜色对象 List
  • node + alipay-sdk 沙箱环境简单测试电脑网站支付

    正式上线需要上传营业执照 不知道怎么去申请一个 使用沙箱测试 首先前往支付宝开放平台控制台可看到左下方的沙箱测试链接 然后设置接口加签方式 选择系统默认密钥 系统默认密钥 gt 公钥模式 gt 查看 相关密钥分3种 应用公钥 应用私钥 选择
  • nestjs:使用nodemailer发送邮件提示mailer Error: Unexpected socket close

    问题 如上 参考 javascript nodemailer Connection closed unexpectedly Stack Overflow 解决办法 如果端口用的465 需要加上 secure true 之前没加导致上述报错
  • qt中将按钮指向的鼠标变成手型

    具体操作的方式有两种 一种是直接通过界面来进行更改 如下 第二种 就是使用代码的形式 ui gt pushButton gt setCursor QCursor Qt PointingHandCursor
  • unix时间戳c语言源码

    在单片机程序开发中 经常会遇到做数据存储 利用时间信息做数据的搜索查询 时间格式最好还是用unix时间戳的形式 可以直接对时间进行加减运算 从RTC中读取的时间一般都是BCD码 如何转换成unix时间戳 简单的做了实现 并开N台电脑从0开始
  • meidaPlayer java.io.IOException: setDataSource failed.: status=0x800000

    1 权限
  • pfSense多拨网速叠加教程

    0 废话 前后一共折腾了两天 发现网上很少有pfsense的多拨教程 查了好多资料终于摸索出来了方法 记录一下 坐标山东 联通光纤入户 200兆 实测稳定在250兆 赞 但是上行只有40兆 最后弄完 下行到了450M 一超过500就全部掉线
  • 杭电OJ 1003 Max Sum

    Max Sum 页面数据来自 this page from http acm hdu edu cn showproblem php pid 1003 Time Limit 2000 1000 MS Java Others Memory Li
  • Leetcode-1991. Find the Middle Index in Array

    Topic Background Given a 0 indexed integer array nums find the leftmost iddleIndex i e the smallest amongst all the poss
  • vben:vue3后台管理项目框架

    前言 Vue Vben Admin 是一个基于 Vue3 0 Vite Ant Design Vue TypeScript 的后台解决方案 目标是为开发中大型项目提供开箱即用的解决方案 包括二次封装组件 utils hooks 动态菜单 权
  • c++ const & constexpr c++98 c++11 c++14

    文章目录 c const 和 constexpr 知识点总结 一 const 1 const修饰变量 修饰普通变量 常量 修饰指针类型 修饰引用类型 2 const修饰函数 const修饰函数参数 const修饰函数返回值 const修饰成
  • 接口超时分析

    原文 接口突然超时 1 网络异常 1 1 网络抖动 经常上网的我们 肯定遇到过这样的场景 大多数情况下我们访问某个网站很快 但偶尔会出现网页一直转圈 加载不出来的情况 有可能是你的网络出现了抖动 丢包了 网页请求API接口 或者接口返回数据
  • Ubuntu16.04下caffe安装编译全过程(CPU)

    caffe是深度学习最好用的框架之一 但caffe的安装编译过程相对较复杂 本人在安装编译时百度了好几个版本 都没有一次成功过 因此在此总结一下自己的编译过程 本文是在Ubuntu16 04下安装编译caffe 其他版本会略有不同 该教程本
  • com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl.

    问题 IDEA调试JDBC出错 com alibaba druid support logging JakartaCommonsLoggingImpl error create connection SQLException url jdb
  • 外包测试3年,离职后成功入职阿里,拿到offer的那天我泪目了...

    一提及外包测试 大部分人的第一印象就是 工作强度大 技术含量低 没有归属感 外包工作三年总体感受就是这份工作缺乏归属感 心里总有一种落差 进步空间不大 接触不到核心技术 公司没有针对你的技术培训与探究 工作简单 业务重复 通常是工具人的存在
  • QDockWidget布局方式

    上图为DockWidget多控件效果图 QDockWidget dock QLatin1String Last filters QWidget multiWidget new QWidget QVBoxLayout layout new Q
  • oracle生成不同uuid,oracle生成uuid

    select sys guid from dual gt 78AE331ADB2B4CE7AB598B1317B39D58 但该函数如下问题 1 返回类型为RAW 2 没有 dash 分隔符 3 返回的字母大写 为了使产生的uuid符合rf
  • vue3之createApp分析

    函数定义 createApp函数定义在文件 packages runtime dom src index ts中 export const createApp args gt const app ensureRenderer createA
  • Python 贝叶斯在文本分类的应用案例

    关注微信公共号 小程在线 关注CSDN博客 程志伟的博客 1 1 文本编码技术简介 1 1 1 单词计数向量 在开始分类之前 我们必须先将文本编码成数字 一种常用的方法是单词计数向量 在这种技术中 一个样本可以包 含一段话或一篇文章 这个样