國家試點(diǎn)和地方試點(diǎn)是兩種不同的試點(diǎn)形式,它們的區(qū)別如下:
1. 范圍:國家試點(diǎn)是由國家層面推動(dòng)和組織實(shí)施的試點(diǎn)項(xiàng)目,覆蓋的范圍一般是全國性的,即在全國范圍內(nèi)選擇特定地區(qū)或機(jī)構(gòu)進(jìn)行試點(diǎn)。地方試點(diǎn)則是由地方政府或相關(guān)機(jī)構(gòu)組織的試點(diǎn)項(xiàng)目,僅在某個(gè)特定地區(qū)或單位范圍內(nèi)進(jìn)行。
2. 層級:國家試點(diǎn)是由中央政府或國家相關(guān)部門牽頭,制定統(tǒng)一的試點(diǎn)方案和政策,監(jiān)督和評估試點(diǎn)效果。地方試點(diǎn)則是由地方政府或地方相關(guān)部門自行決策、實(shí)施和評估。
3. 影響力:國家試點(diǎn)具有更加廣泛的影響力,因?yàn)樗婕罢麄€(gè)國家的政策和發(fā)展方向,能夠在更大范圍內(nèi)推廣經(jīng)驗(yàn)和成果。地方試點(diǎn)的影響范圍相對較小,主要對所在地區(qū)或單位的相關(guān)政策和改革產(chǎn)生影響。
4. 政策支持:國家試點(diǎn)通常能夠得到中央政府的政策支持,獲得更多的資源和資金投入。地方試點(diǎn)則相對較為獨(dú)立,可能依賴地方自有的資源和資金。
國家試點(diǎn)和地方試點(diǎn)都是為了推進(jìn)某項(xiàng)政策、項(xiàng)目或改革的實(shí)施,但在實(shí)施范圍、層級、影響力和政策支持上存在一定的差異。它們在不同層面上共同推動(dòng)了社會變革和發(fā)展。
試點(diǎn)企業(yè)就是公告中規(guī)定的那些企業(yè),非試點(diǎn)企業(yè)就是公告中沒有規(guī)定的企業(yè)。
試點(diǎn)企業(yè)就是被政府用來嘗試某些政策或者要求的企業(yè)。試點(diǎn)創(chuàng)新企業(yè)是指經(jīng)中國證監(jiān)會核準(zhǔn)公開發(fā)行股票或者存托憑證并上市的企業(yè)。
<h2>駕校試點(diǎn):創(chuàng)新駕駛培訓(xùn)的新里程</h2>
<p>作為交通安全的重要一環(huán),駕駛培訓(xùn)一直備受關(guān)注。為了全面提高駕駛員的駕駛技能,我國近年來進(jìn)行了一系列創(chuàng)新舉措,其中之一就是駕校試點(diǎn)。駕校試點(diǎn)是指將新的交通安全理念與技術(shù)應(yīng)用到駕校教學(xué)中,以期培養(yǎng)出更優(yōu)秀、更符合實(shí)際駕駛需求的駕駛員。本文將介紹這一試點(diǎn)措施,分析其意義和影響。</p>
<h2>試點(diǎn)內(nèi)容</h2>
<p>駕校試點(diǎn)的主要內(nèi)容包括:改革教學(xué)內(nèi)容,優(yōu)化教學(xué)方式,提升教學(xué)質(zhì)量,加強(qiáng)學(xué)員評估等。首先,駕校試點(diǎn)拓寬了教學(xué)內(nèi)容的范圍。以往的駕校教學(xué)更注重技術(shù)操作,對于交通法規(guī)和安全意識的教育相對薄弱,而駕校試點(diǎn)將交通安全理念納入教學(xué)內(nèi)容,提高學(xué)員的安全意識和遵守交通規(guī)則的能力。其次,駕校試點(diǎn)還優(yōu)化了教學(xué)方式,采用現(xiàn)代化的教育手段,如虛擬仿真教學(xué)、互動(dòng)式教學(xué)等,提高學(xué)員的學(xué)習(xí)興趣和效果。此外,通過加強(qiáng)學(xué)員評估,駕校能夠更客觀地評價(jià)學(xué)員的學(xué)習(xí)情況和技能水平,及時(shí)發(fā)現(xiàn)問題并進(jìn)行針對性的輔導(dǎo)。</p>
<h2>試點(diǎn)意義</h2>
<p>駕校試點(diǎn)具有重要的意義。首先,駕校試點(diǎn)有助于提高交通安全意識和遵守交通規(guī)則的能力。通過將交通安全理念納入教學(xué)內(nèi)容,學(xué)員能夠更深入地了解交通法規(guī)和安全知識,養(yǎng)成良好的駕駛習(xí)慣和態(tài)度。其次,駕校試點(diǎn)有利于提升駕駛技能水平。優(yōu)化的教學(xué)方式和評估體系能夠更全面地培養(yǎng)學(xué)員的技能,使他們掌握更多的駕駛技巧和應(yīng)對突發(fā)情況的能力。再次,駕校試點(diǎn)有助于提高駕校的教學(xué)質(zhì)量和形象。通過改革教學(xué)內(nèi)容和方式,駕校能夠更好地適應(yīng)社會需求,培養(yǎng)更符合市場需求的駕駛員,提升駕校在業(yè)界的聲譽(yù)和競爭力。最后,駕校試點(diǎn)對于整個(gè)交通安全事業(yè)的發(fā)展也具有積極的推動(dòng)作用。它不僅能夠提高駕駛員素質(zhì),減少交通事故,還能夠促進(jìn)交通管理水平的提升,推動(dòng)交通文明建設(shè)的發(fā)展。</p>
<h2>試點(diǎn)影響</h2>
<p>駕校試點(diǎn)將產(chǎn)生重要的影響。首先,它將提高駕駛培訓(xùn)的標(biāo)準(zhǔn)化程度。通過優(yōu)化教學(xué)內(nèi)容和方式,駕校試點(diǎn)將推動(dòng)駕校教學(xué)的標(biāo)準(zhǔn)化和規(guī)范化,使駕校的教學(xué)水平得到提升和統(tǒng)一。其次,駕校試點(diǎn)將加快交通安全科技的應(yīng)用。駕校試點(diǎn)要求采用現(xiàn)代化的教育手段和技術(shù),例如虛擬仿真教學(xué),這將促進(jìn)交通安全科技的發(fā)展和應(yīng)用,推動(dòng)交通安全事業(yè)的創(chuàng)新和進(jìn)步。再次,駕校試點(diǎn)將對駕校產(chǎn)生深遠(yuǎn)的影響。駕校試點(diǎn)對駕校的教學(xué)內(nèi)容和方式提出了更高的要求,駕校需要不斷適應(yīng)和引進(jìn)先進(jìn)的教育手段和管理理念,才能更好地滿足社會和學(xué)員的需求。最后,駕校試點(diǎn)將引領(lǐng)駕駛培訓(xùn)行業(yè)的發(fā)展方向。駕校試點(diǎn)作為一種創(chuàng)新舉措,將為整個(gè)行業(yè)探索新的發(fā)展路徑和模式,推動(dòng)行業(yè)向著更加智能化、個(gè)性化、綜合化的方向發(fā)展。</p>
<h2>總結(jié)</h2>
<p>駕校試點(diǎn)是我國駕駛培訓(xùn)領(lǐng)域的一項(xiàng)重要改革舉措,它的實(shí)施將對交通安全事業(yè)產(chǎn)生深遠(yuǎn)的影響。通過改革教學(xué)內(nèi)容和方式,駕校試點(diǎn)將提高交通安全意識和駕駛技能水平,推動(dòng)駕校教學(xué)的標(biāo)準(zhǔn)化和規(guī)范化,促進(jìn)交通安全科技的發(fā)展和應(yīng)用。同時(shí),駕校試點(diǎn)還將引領(lǐng)駕駛培訓(xùn)行業(yè)的發(fā)展方向,推動(dòng)行業(yè)向著更加智能化、個(gè)性化、綜合化的方向發(fā)展。我們期待駕校試點(diǎn)的成功推廣,為交通安全事業(yè)的發(fā)展貢獻(xiàn)力量!</p>
答:英語a級考試,一般都在自己學(xué)校考,如果你們學(xué)校不設(shè)考點(diǎn),就要根據(jù)準(zhǔn)考證上的考點(diǎn)地址去考試。英語應(yīng)用能力考試a級考試一般在每年上半年6月下旬9:00-11:00、下半年12月下旬9:00-11:00 各舉行一次(一般在大學(xué)英語四、六級考試的第二天)。
是的,定州試點(diǎn)了新村。因?yàn)槎ㄖ菔呛颖笔≈匾慕?jīng)濟(jì)中心,為了解決城市發(fā)展過程中出現(xiàn)的人口聚集、資源匱乏、環(huán)境污染等問題,定州市政府決定試點(diǎn)建設(shè)新村,實(shí)施新型城鎮(zhèn)化和城市發(fā)展戰(zhàn)略。據(jù)了解,定州新村計(jì)劃通過智慧城市建設(shè)、產(chǎn)業(yè)發(fā)展、生態(tài)環(huán)保等多種方式,實(shí)現(xiàn)生態(tài)可持續(xù)發(fā)展,提高人民群眾的生活質(zhì)量和城市競爭力。同時(shí),修建文化設(shè)施和公共服務(wù)設(shè)施,帶動(dòng)區(qū)域經(jīng)濟(jì)發(fā)展,加速當(dāng)?shù)厣鐣M(jìn)步,這將是一項(xiàng)有益的嘗試和探索。
試點(diǎn)本科與統(tǒng)招本科的區(qū)別:
1、相同之處: ?。?)試點(diǎn)本科的本科生與普通本科生是在大學(xué)校內(nèi)進(jìn)行系統(tǒng)的高等教育,所以,兩者在校期間的學(xué)習(xí)、生活、環(huán)境、條件、師資、管理、畢業(yè)待遇、推薦就業(yè)等均相同?! 。?)試點(diǎn)本科的本科生在畢業(yè)后,考研、考公務(wù)員、出國留學(xué)與本科生相同。
2、不同之處: (1)、兩者在學(xué)習(xí)期間的考試方式不同。普通本科生由學(xué)校出卷、評卷給學(xué)生成績;試點(diǎn)本科生部分課程由省考試院出卷、評卷給學(xué)生成績?! 。?)、試點(diǎn)本科生的畢業(yè)證書除主考院校印章外,加蓋高等教育自學(xué)考試委員會印章。 ?。?)、高中生參加自考本科試點(diǎn)畢業(yè)的學(xué)生沒有本科學(xué)歷,試點(diǎn)本科學(xué)制考取的畢業(yè)證書不屬于第一學(xué)歷,沒有統(tǒng)招畢業(yè)生的報(bào)到證書!注: 試點(diǎn)本科屬于高等教育自學(xué)考試(自考)范疇,在校??粕鷧⒓咏y(tǒng)一的高等教育自學(xué)考試,同時(shí)報(bào)考自學(xué)考試本科段課程,國家承認(rèn)學(xué)歷,符合條件的可以授予學(xué)士學(xué)位,符合條件的也可以考研、考公務(wù)員。一般高等教育自學(xué)考試則所有課程都需要參加全國或全省的統(tǒng)一考試。
分段試點(diǎn)班是指將學(xué)習(xí)內(nèi)容分成若干個(gè)段落,每個(gè)段落都有相應(yīng)的學(xué)習(xí)目標(biāo)和教學(xué)活動(dòng)。學(xué)生在每個(gè)段落結(jié)束后進(jìn)行評估和反饋,然后再進(jìn)入下一個(gè)段落的學(xué)習(xí)。這種模式可以幫助學(xué)生更好地理解和掌握知識,同時(shí)也可以根據(jù)學(xué)生的學(xué)習(xí)情況進(jìn)行個(gè)性化的指導(dǎo)和輔導(dǎo)。連讀試點(diǎn)班是指將不同學(xué)科的知識內(nèi)容進(jìn)行整合和連接,形成一個(gè)有機(jī)的學(xué)習(xí)體系。學(xué)生在學(xué)習(xí)過程中可以更好地理解不同學(xué)科之間的關(guān)聯(lián)和應(yīng)用,提高綜合素養(yǎng)和解決問題的能力。這種模式注重跨學(xué)科的綜合性學(xué)習(xí),培養(yǎng)學(xué)生的綜合思維和創(chuàng)新能力。總的來說,分段試點(diǎn)班注重知識的分段教學(xué)和個(gè)性化指導(dǎo),而連讀試點(diǎn)班注重跨學(xué)科的綜合性學(xué)習(xí)和綜合能力的培養(yǎng)。具體選擇哪種模式要根據(jù)學(xué)生的需求和學(xué)校的教育目標(biāo)來確定。
意思分別是:試點(diǎn)成立本科院校、試點(diǎn)成立??圃盒?。
那就是屎,我只看了普通物理學(xué),如果要復(fù)習(xí)的話就把課本看一下就好了,看他的課真的就是耽誤時(shí)間。就他這樣的上課方法,找一個(gè)認(rèn)識字的就可以錄視頻了,反正照著讀唄。越說越氣。。。。。。。
之前看了Mahout官方示例 20news 的調(diào)用實(shí)現(xiàn);于是想根據(jù)示例的流程實(shí)現(xiàn)其他例子。網(wǎng)上看到了一個(gè)關(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的工具類實(shí)現(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)行分類。
接下來貼下我的代碼實(shí)現(xiàn)=》
1. 構(gòu)造分類數(shù)據(jù):
在hdfs主要?jiǎng)?chuàng)建一個(gè)文件夾路徑 /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)行分類。
這三步,代碼我就一次全貼出來;主要是兩個(gè)類 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)換成向量失?。?#34;);
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)換成向量失?。?#34;);
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)練模型失?。?#34;);
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初始化時(shí)報(bào)錯(cuò)。。。。");
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í)表示總文檔數(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());
}
}