在日常工作中應(yīng)重點鉆研政工領(lǐng)域國家政策、理論、工作技能及業(yè)務(wù)知識,并且具有較強(qiáng)的實際問題解決能力。
政工干部應(yīng)具備較強(qiáng)的語言表達(dá)能力,牢牢把握交流技巧與方法,日常生活當(dāng)中應(yīng)重視知識累積,可通過閱讀與觀看書籍、新聞以及報告等方式積累知識,并加強(qiáng)自身語言表達(dá)能力。
同時政工干部應(yīng)善于和群眾交流、善于向領(lǐng)導(dǎo)進(jìn)行工作匯報,在對群眾進(jìn)行政策解讀時應(yīng)該有針對性地運用講解語言,深入淺出地解讀,使各層次群眾均可理解政策內(nèi)涵。
政工干部崗位如下
專職黨總支、黨支部書記
在行政系列宣傳、宣教部門中直接從事思想政治工作的專職人員
企業(yè)工會的負(fù)責(zé)人,宣教、組織、研究、女工部門中直接從事思想政治工作的專職人員
企業(yè)共青團(tuán)組織負(fù)責(zé)人和宣傳、組織部門中專職從事思想政治工作的人員
兼有政工或技術(shù)工作的人員,應(yīng)按有關(guān)規(guī)定在其主要工作崗位參加專業(yè)技術(shù)職務(wù)的評聘。
總之,政工系列的崗位主要是指從事黨政管理、宣傳教育、工青群眾團(tuán)體工作的專職崗位。政工崗位人員一般要求評聘政工系列職稱,由高到低為:高級政工師、政工師、助理政工師、政工員。
記得當(dāng)年草上飛,戰(zhàn)錦方為大問題。斥鷃每聞欺大鳥,昆雞長笑老鷹非。君今不幸離人世,國有疑難可問誰?這是毛主席為悼念政工元帥羅榮桓的詩句。羅帥跟隨毛主席從井岡山到長征,抗日戰(zhàn)爭,解放戰(zhàn)爭立下了不朽功勛。
政工干部就是專門做員工思想工作的,就象軍隊里的指導(dǎo)員.
員工平時思想上有什么波動啊,嘴巴上有什么牢騷啊,暗地里有什么意見啊.你都要盡量去了解清楚.然后想辦法穩(wěn)定他們的思想,調(diào)動他們的積極性.平息他們的情緒.
政工干部比較鮮明的優(yōu)點:就是一副和藹可親的樣子.
政工干部比較鮮明的缺點:就是婆婆媽媽象唐僧一樣.
政工干部培訓(xùn)結(jié)束后,每一位接受培訓(xùn)的政工干部都要選寫自我鑒定。自我鑒定是針對培訓(xùn)內(nèi)容,結(jié)合自己的工作實際,寫出自己那些地方能夠完成上級黨組織交給的任務(wù),還有哪些地方存在著不足之處,對照培訓(xùn)要求今后努力的方向,更踏實地做好本職工作,這樣培訓(xùn)的目的基本上達(dá)到了。
公安局內(nèi)部也是有很多機(jī)構(gòu),如政治部,人事處,宣傳處,辦公室等部門,在政治宣傳部門工作得民警一般成為公安政工民警,其工作職責(zé)就是負(fù)責(zé)政治宣傳教育,負(fù)責(zé)黨政黨建工作。
組工干部和政工干部的主要區(qū)別在于:
1、工作職責(zé)范圍不同,組工干部(即組織工作干部)是負(fù)責(zé)黨組織工作的,如黨員和黨組織的管理;政工干部(即政治工作干部)是負(fù)責(zé)全員思想政治工作和宣傳教育。
2、任職人員的政治面貌要求有所不同,組工干部必須由黨員干部擔(dān)任,而政工干部除黨員干部外也可以由非黨員干部擔(dān)任。
一、政工干部要不斷強(qiáng)化自身素質(zhì),做到業(yè)務(wù)精、作風(fēng)正、能力強(qiáng)
首先,合格的政工干部綜合素質(zhì)要“硬”.新時期的思想政治工作者可以說具有政工干部和管理干部的雙重身份和職能,新的角色提出了新的工作標(biāo)準(zhǔn),轉(zhuǎn)變思想觀念、突破傳統(tǒng)模式、跟得上形勢變化、向復(fù)合型人才發(fā)展……
這就要求政工干部在抓好政治理論學(xué)習(xí)的同時,更要重視業(yè)務(wù)知識的學(xué)習(xí),不斷拓寬知識面,努力提高做好本職工作的水平和適應(yīng)未來工作的能力,通過精選學(xué)習(xí)內(nèi)容,系統(tǒng)地掌握思想政治工作的相關(guān)專業(yè)知識,不斷強(qiáng)化思想政治工作的理論基礎(chǔ),才能全面提高政工干部的綜合素質(zhì),使政工干部既具備研究政策的能力和探索管理途徑的能力,又具有扎實的理論基礎(chǔ)和較豐富的工作經(jīng)驗,為更好地融入港口生產(chǎn)經(jīng)營管理,更好地配合行政工作,適應(yīng)港口改革發(fā)展和新形勢的需要創(chuàng)造條件。其次,合格的政工干部工作作風(fēng)要“實”.
一是要樹立求真務(wù)實、勤奮上進(jìn)的作風(fēng)。政工干部要有針對性地多深入基層調(diào)研、了解情況,要勤于動腦,真抓實干,將安排的工作謀劃好,增強(qiáng)處理問題的預(yù)見性;
二是要樹立精干務(wù)實、嚴(yán)謹(jǐn)高效的作風(fēng)。要高效率、高質(zhì)量地開展工作,善于抓重點、抓關(guān)鍵,成為多面手,提高處理復(fù)雜問題的能力;
三是要樹立親和但不失原則的作風(fēng)。要充分發(fā)揮政工干部的優(yōu)勢,貼近職工,有效溝通,同時必須要求自己嚴(yán)格遵守黨紀(jì)、政紀(jì)和規(guī)章制度,嚴(yán)于律己,明白做人,踏實做事,以一名合格黨員干部的形象出現(xiàn)在職工群眾中間。
此外,政工干部自身對本職工作的性質(zhì)要有深刻的理解和執(zhí)著的精神,要把服務(wù)對象贊成不贊成、滿意不滿意作為檢驗自身服務(wù)工作質(zhì)量和效率的根本標(biāo)準(zhǔn),針對服務(wù)對象廣泛的工作特點,堅持從強(qiáng)化服務(wù)意識,提高服務(wù)質(zhì)量入手,力求做到對待群眾政治上關(guān)心、生活上貼心、服務(wù)上誠心、遇事將心比心,以朗朗的工作作風(fēng),以樸實無華、不計名利、無私奉獻(xiàn)的工作精神,教育和感染人,讓廣大干部職工親身體會到合格的政工干部是實實在在干實事的人,思想政治工作不是簡單的說教主義。
再次,合格的政工干部創(chuàng)新觀念要“強(qiáng)”.一是要對履職范圍有新認(rèn)識,在做好本職工作的同時加強(qiáng)管理知識的學(xué)習(xí),可以采取集中與自學(xué)相結(jié)合的方式,加強(qiáng)業(yè)務(wù)學(xué)習(xí),全面了解生產(chǎn)組織、經(jīng)營管理、安全質(zhì)量、裝卸設(shè)備、工藝流程等方面基本業(yè)務(wù)知識,力求實現(xiàn)政治工作與經(jīng)濟(jì)工作的更好融合,使政工干部成為既掌握本職業(yè)務(wù),又通曉生產(chǎn)管理知識的復(fù)合型人才;二是要學(xué)習(xí)和嘗試不同的工作方法,豐富和創(chuàng)新學(xué)習(xí)教育活動內(nèi)容,深入做好信息和調(diào)查研究工作,依靠組織及組織資源解決好復(fù)雜問題,并且要加強(qiáng)上下級和部門之間的交流,確保工作質(zhì)量和工作效率。除此之外,服務(wù)對象的廣泛性和多層次性還要求政工干部具有多種能力。
二、政工干部要在思想政治工作中求創(chuàng)新、求落實、求實效
第一,工作思路求創(chuàng)新。一是思想觀念創(chuàng)新,通過多種形式啟發(fā)干部群眾解放思想,更新觀念。在工作指導(dǎo)上,強(qiáng)調(diào)在加強(qiáng)的前提下改進(jìn),在繼承的基礎(chǔ)上創(chuàng)新。盡管思想政治工作不斷受到各種社會流行風(fēng)的干擾,但要強(qiáng)化思想政治工作力度不減少,思想政治工作形式多樣不斷線。二是方式方法創(chuàng)新,在堅持思想政治工作的超前性、針對性和實效性的同時,努力探索形式的多樣性。根據(jù)新形勢新情況的不斷變化,善于在實踐中探索符合實際情況的思想政治工作新路子,力爭做到輿論宣傳與思想疏導(dǎo)相結(jié)合,思想教育工作與常規(guī)工作相結(jié)合,落實工作與具體的人和事相結(jié)合。
第二,工作內(nèi)容求落實。思想政治工作是維護(hù)人們思想穩(wěn)定,解決工作中出現(xiàn)的矛盾,提升職工整體素養(yǎng),確保工作順利推進(jìn)的工作。思想政治工作不是簡單的說教,而是一項保障事業(yè)順利穩(wěn)定發(fā)展的實際工程,因此,只有圍繞實際中心工作,把思想政治工作落到實處,才能增強(qiáng)思想政治工作的活力。
新形式下的政工干部要敏銳的把握服務(wù)對象的思想活動規(guī)律,使思想政治工作有依托和載體,通過抓學(xué)習(xí)教育、座談討論、組織活動、解決問題等基本環(huán)節(jié),采取有力措施具體抓落實,使廣大職工在過程中形成思想互動、產(chǎn)生心靈共鳴,看到事業(yè)發(fā)展的巨大潛力,增強(qiáng)信心,激發(fā)干勁,以高漲的凝聚力推動整體工作的快速發(fā)展。
第三,工作效果求實效。以人為本,注重關(guān)愛,是增強(qiáng)思想政治工作實效性的法寶。具體操作要注重幾個方面:
一是堅持人性化管理,注重人文關(guān)愛。堅持以理服人、以事感人、以情動人,將思想政治工作與廣大職工的生活實際有機(jī)結(jié)合。政工干部要定期深入基層班組,通過加強(qiáng)與班組長聯(lián)系、適時參加班組活動、與班組職工談心、個別走訪等方式,把握職工的思想脈搏,使思想政治工作重心前移,增強(qiáng)主動性、前瞻性和實效性,密切黨群、干群關(guān)系,激發(fā)職工的生產(chǎn)熱情。
二是倡導(dǎo)情感感化,通過深入開展貼心支部等特色活動,落實“四主動”要求,即主動講港口改革政策和形勢任務(wù),做好思想疏導(dǎo)與解疑釋惑工作;主動聽群眾的意見和建議,真實把握群眾的利益訴求;主動做服務(wù)群眾的好事實事,解決職工群眾關(guān)注的熱點難點問題;主動改進(jìn)黨建活動方式,不斷增強(qiáng)黨組織的活力,努力搭建黨組織聯(lián)系群眾的橋梁和平臺,及時解決職工群眾關(guān)注的熱點難點問題,使職工工作順心,生活舒心,思想政治工作就會收到事半功倍的效果。
主要工作是思想工作和組織工作。思想工作方面主要有學(xué)習(xí)、教育和經(jīng)常性思想工作等方面的組織工作就比較多了,比如黨的工作、基層建設(shè)、干部工作、宣傳工作、保衛(wèi)工作、群眾工作、青年工作等等。
之前看了Mahout官方示例 20news 的調(diào)用實現(xiàn);于是想根據(jù)示例的流程實現(xiàn)其他例子。網(wǎng)上看到了一個關(guān)于天氣適不適合打羽毛球的例子。
訓(xùn)練數(shù)據(jù):
Day Outlook Temperature Humidity Wind PlayTennis
D1 Sunny Hot High Weak No
D2 Sunny Hot High Strong No
D3 Overcast Hot High Weak Yes
D4 Rain Mild High Weak Yes
D5 Rain Cool Normal Weak Yes
D6 Rain Cool Normal Strong No
D7 Overcast Cool Normal Strong Yes
D8 Sunny Mild High Weak No
D9 Sunny Cool Normal Weak Yes
D10 Rain Mild Normal Weak Yes
D11 Sunny Mild Normal Strong Yes
D12 Overcast Mild High Strong Yes
D13 Overcast Hot Normal Weak Yes
D14 Rain Mild High Strong No
檢測數(shù)據(jù):
sunny,hot,high,weak
結(jié)果:
Yes=》 0.007039
No=》 0.027418
于是使用Java代碼調(diào)用Mahout的工具類實現(xiàn)分類。
基本思想:
1. 構(gòu)造分類數(shù)據(jù)。
2. 使用Mahout工具類進(jìn)行訓(xùn)練,得到訓(xùn)練模型。
3。將要檢測數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。
4. 分類器對vector數(shù)據(jù)進(jìn)行分類。
接下來貼下我的代碼實現(xiàn)=》
1. 構(gòu)造分類數(shù)據(jù):
在hdfs主要創(chuàng)建一個文件夾路徑 /zhoujainfeng/playtennis/input 并將分類文件夾 no 和 yes 的數(shù)據(jù)傳到hdfs上面。
數(shù)據(jù)文件格式,如D1文件內(nèi)容: Sunny Hot High Weak
2. 使用Mahout工具類進(jìn)行訓(xùn)練,得到訓(xùn)練模型。
3。將要檢測數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。
4. 分類器對vector數(shù)據(jù)進(jìn)行分類。
這三步,代碼我就一次全貼出來;主要是兩個類 PlayTennis1 和 BayesCheckData = =》
package myTesting.bayes;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.util.ToolRunner;
import org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob;
import org.apache.mahout.text.SequenceFilesFromDirectory;
import org.apache.mahout.vectorizer.SparseVectorsFromSequenceFiles;
public class PlayTennis1 {
private static final String WORK_DIR = "hdfs://192.168.9.72:9000/zhoujianfeng/playtennis";
/*
* 測試代碼
*/
public static void main(String[] args) {
//將訓(xùn)練數(shù)據(jù)轉(zhuǎn)換成 vector數(shù)據(jù)
makeTrainVector();
//產(chǎn)生訓(xùn)練模型
makeModel(false);
//測試檢測數(shù)據(jù)
BayesCheckData.printResult();
}
public static void makeCheckVector(){
//將測試數(shù)據(jù)轉(zhuǎn)換成序列化文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"testinput";
String output = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();
String[] params = new String[]{"-i",input,"-o",output,"-ow"};
ToolRunner.run(sffd, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("文件序列化失敗!");
System.exit(1);
}
//將序列化文件轉(zhuǎn)換成向量文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";
String output = WORK_DIR+Path.SEPARATOR+"tennis-test-vectors";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();
String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};
ToolRunner.run(svfsf, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("序列化文件轉(zhuǎn)換成向量失敗!");
System.out.println(2);
}
}
public static void makeTrainVector(){
//將測試數(shù)據(jù)轉(zhuǎn)換成序列化文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"input";
String output = WORK_DIR+Path.SEPARATOR+"tennis-seq";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();
String[] params = new String[]{"-i",input,"-o",output,"-ow"};
ToolRunner.run(sffd, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("文件序列化失??!");
System.exit(1);
}
//將序列化文件轉(zhuǎn)換成向量文件
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-seq";
String output = WORK_DIR+Path.SEPARATOR+"tennis-vectors";
Path in = new Path(input);
Path out = new Path(output);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();
String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};
ToolRunner.run(svfsf, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("序列化文件轉(zhuǎn)換成向量失??!");
System.out.println(2);
}
}
public static void makeModel(boolean completelyNB){
try {
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String input = WORK_DIR+Path.SEPARATOR+"tennis-vectors"+Path.SEPARATOR+"tfidf-vectors";
String model = WORK_DIR+Path.SEPARATOR+"model";
String labelindex = WORK_DIR+Path.SEPARATOR+"labelindex";
Path in = new Path(input);
Path out = new Path(model);
Path label = new Path(labelindex);
FileSystem fs = FileSystem.get(conf);
if(fs.exists(in)){
if(fs.exists(out)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(out, true);
}
if(fs.exists(label)){
//boolean參數(shù)是,是否遞歸刪除的意思
fs.delete(label, true);
}
TrainNaiveBayesJob tnbj = new TrainNaiveBayesJob();
String[] params =null;
if(completelyNB){
params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow","-c"};
}else{
params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow"};
}
ToolRunner.run(tnbj, params);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("生成訓(xùn)練模型失??!");
System.exit(3);
}
}
}
package myTesting.bayes;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.mahout.classifier.naivebayes.BayesUtils;
import org.apache.mahout.classifier.naivebayes.NaiveBayesModel;
import org.apache.mahout.classifier.naivebayes.StandardNaiveBayesClassifier;
import org.apache.mahout.common.Pair;
import org.apache.mahout.common.iterator.sequencefile.PathType;
import org.apache.mahout.common.iterator.sequencefile.SequenceFileDirIterable;
import org.apache.mahout.math.RandomAccessSparseVector;
import org.apache.mahout.math.Vector;
import org.apache.mahout.math.Vector.Element;
import org.apache.mahout.vectorizer.TFIDF;
import com.google.common.collect.ConcurrentHashMultiset;
import com.google.common.collect.Multiset;
public class BayesCheckData {
private static StandardNaiveBayesClassifier classifier;
private static Map<String, Integer> dictionary;
private static Map<Integer, Long> documentFrequency;
private static Map<Integer, String> labelIndex;
public void init(Configuration conf){
try {
String modelPath = "/zhoujianfeng/playtennis/model";
String dictionaryPath = "/zhoujianfeng/playtennis/tennis-vectors/dictionary.file-0";
String documentFrequencyPath = "/zhoujianfeng/playtennis/tennis-vectors/df-count";
String labelIndexPath = "/zhoujianfeng/playtennis/labelindex";
dictionary = readDictionnary(conf, new Path(dictionaryPath));
documentFrequency = readDocumentFrequency(conf, new Path(documentFrequencyPath));
labelIndex = BayesUtils.readLabelIndex(conf, new Path(labelIndexPath));
NaiveBayesModel model = NaiveBayesModel.materialize(new Path(modelPath), conf);
classifier = new StandardNaiveBayesClassifier(model);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("檢測數(shù)據(jù)構(gòu)造成vectors初始化時報錯。。。。");
System.exit(4);
}
}
/**
* 加載字典文件,Key: TermValue; Value:TermID
* @param conf
* @param dictionnaryDir
* @return
*/
private static Map<String, Integer> readDictionnary(Configuration conf, Path dictionnaryDir) {
Map<String, Integer> dictionnary = new HashMap<String, Integer>();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(Path path) {
String name = path.getName();
return name.startsWith("dictionary.file");
}
};
for (Pair<Text, IntWritable> pair : new SequenceFileDirIterable<Text, IntWritable>(dictionnaryDir, PathType.LIST, filter, conf)) {
dictionnary.put(pair.getFirst().toString(), pair.getSecond().get());
}
return dictionnary;
}
/**
* 加載df-count目錄下TermDoc頻率文件,Key: TermID; Value:DocFreq
* @param conf
* @param dictionnaryDir
* @return
*/
private static Map<Integer, Long> readDocumentFrequency(Configuration conf, Path documentFrequencyDir) {
Map<Integer, Long> documentFrequency = new HashMap<Integer, Long>();
PathFilter filter = new PathFilter() {
@Override
public boolean accept(Path path) {
return path.getName().startsWith("part-r");
}
};
for (Pair<IntWritable, LongWritable> pair : new SequenceFileDirIterable<IntWritable, LongWritable>(documentFrequencyDir, PathType.LIST, filter, conf)) {
documentFrequency.put(pair.getFirst().get(), pair.getSecond().get());
}
return documentFrequency;
}
public static String getCheckResult(){
Configuration conf = new Configuration();
conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
String classify = "NaN";
BayesCheckData cdv = new BayesCheckData();
cdv.init(conf);
System.out.println("init done...............");
Vector vector = new RandomAccessSparseVector(10000);
TFIDF tfidf = new TFIDF();
//sunny,hot,high,weak
Multiset<String> words = ConcurrentHashMultiset.create();
words.add("sunny",1);
words.add("hot",1);
words.add("high",1);
words.add("weak",1);
int documentCount = documentFrequency.get(-1).intValue(); // key=-1時表示總文檔數(shù)
for (Multiset.Entry<String> entry : words.entrySet()) {
String word = entry.getElement();
int count = entry.getCount();
Integer wordId = dictionary.get(word); // 需要從dictionary.file-0文件(tf-vector)下得到wordID,
if (StringUtils.isEmpty(wordId.toString())){
continue;
}
if (documentFrequency.get(wordId) == null){
continue;
}
Long freq = documentFrequency.get(wordId);
double tfIdfValue = tfidf.calculate(count, freq.intValue(), 1, documentCount);
vector.setQuick(wordId, tfIdfValue);
}
// 利用貝葉斯算法開始分類,并提取得分最好的分類label
Vector resultVector = classifier.classifyFull(vector);
double bestScore = -Double.MAX_VALUE;
int bestCategoryId = -1;
for(Element element: resultVector.all()) {
int categoryId = element.index();
double score = element.get();
System.out.println("categoryId:"+categoryId+" score:"+score);
if (score > bestScore) {
bestScore = score;
bestCategoryId = categoryId;
}
}
classify = labelIndex.get(bestCategoryId)+"(categoryId="+bestCategoryId+")";
return classify;
}
public static void printResult(){
System.out.println("檢測所屬類別是:"+getCheckResult());
}
}