一个色的导航资源精品在线观看|手机看片在线精品视频|伊人亚洲成人电影|亚洲欧美在线男女|无码无码在线观看五月精品视频在线|超碰日韩欧美在线|午夜精品蜜桃一区二区久久久|91欧美动态国产精品女主播|色欲色香天天天综合网在线观看免费|伊人春色在线伊人

清華大學(xué)mpa面試題

時(shí)間:2024-04-22 01:36 人氣:0 編輯:admin

一、清華大學(xué)mpa面試題

清華大學(xué)MPA面試題:準(zhǔn)備迎接成功的關(guān)鍵

清華大學(xué)管理學(xué)院的MPA(公共管理碩士)項(xiàng)目是中國(guó)乃至全球頂尖的公共管理碩士項(xiàng)目之一。每年都有數(shù)千名學(xué)子志愿報(bào)考,而面試是入選清華大學(xué)MPA項(xiàng)目的關(guān)鍵環(huán)節(jié)之一。面試是考察學(xué)生綜合素質(zhì)和能力的重要手段,因此,為了在清華大學(xué)MPA面試中脫穎而出,成功邁向理想的公共管理之路,準(zhǔn)備工作至關(guān)重要。

準(zhǔn)備面試的重要性

面試是考察申請(qǐng)者綜合素質(zhì)的重要環(huán)節(jié),通過(guò)面試,面試官可以直接了解申請(qǐng)者的溝通能力、邏輯思維、團(tuán)隊(duì)合作能力以及個(gè)人品質(zhì)等方面的表現(xiàn)。準(zhǔn)備面試時(shí),申請(qǐng)者需要全面考慮面試的各個(gè)方面,從知識(shí)儲(chǔ)備到表達(dá)能力,甚至包括形象和自信心的展示。

清華大學(xué)MPA面試題的范圍和特點(diǎn)

清華大學(xué)MPA面試題主要從以下幾個(gè)方面進(jìn)行考察:

  1. 學(xué)術(shù)背景和研究興趣:清華大學(xué)MPA項(xiàng)目的學(xué)術(shù)導(dǎo)向較強(qiáng),面試官會(huì)關(guān)注申請(qǐng)者的學(xué)術(shù)背景和研究興趣,以評(píng)估其在學(xué)術(shù)研究方面的潛力和能力。
  2. 領(lǐng)導(dǎo)能力和團(tuán)隊(duì)合作:公共管理崗位需要具備良好的領(lǐng)導(dǎo)能力和團(tuán)隊(duì)合作精神,因此,面試官會(huì)通過(guò)相關(guān)問(wèn)題考察申請(qǐng)者在這方面的表現(xiàn)。
  3. 社會(huì)責(zé)任和公共服務(wù)意識(shí):公共管理的核心是為社會(huì)服務(wù),因此,面試官會(huì)關(guān)注申請(qǐng)者的社會(huì)責(zé)任感和公共服務(wù)意識(shí)。
  4. 邏輯思維和問(wèn)題解決:公共管理工作需要具備較強(qiáng)的邏輯思維和問(wèn)題解決能力,面試官會(huì)通過(guò)問(wèn)題解答環(huán)節(jié)考察申請(qǐng)者的思維方式和解決問(wèn)題的能力。

如何準(zhǔn)備清華大學(xué)MPA面試題

準(zhǔn)備清華大學(xué)MPA面試題需要充分考慮以上幾個(gè)方面,并進(jìn)行有針對(duì)性的準(zhǔn)備工作。

1. 學(xué)術(shù)背景和研究興趣

準(zhǔn)備面試時(shí),申請(qǐng)者應(yīng)充分了解自己的學(xué)術(shù)背景和研究興趣,并在面試時(shí)能夠清晰、準(zhǔn)確地表達(dá)。申請(qǐng)者可以回顧自己的學(xué)術(shù)經(jīng)歷,總結(jié)已有的研究成果,并思考未來(lái)的研究方向和目標(biāo)。

2. 領(lǐng)導(dǎo)能力和團(tuán)隊(duì)合作

為了在面試中展示自己的領(lǐng)導(dǎo)能力和團(tuán)隊(duì)合作精神,申請(qǐng)者可以準(zhǔn)備一些相關(guān)的案例和經(jīng)歷,在面試時(shí)進(jìn)行詳細(xì)描述。申請(qǐng)者可以回顧自己在學(xué)習(xí)和工作中的領(lǐng)導(dǎo)經(jīng)驗(yàn),包括帶領(lǐng)團(tuán)隊(duì)完成項(xiàng)目、解決團(tuán)隊(duì)內(nèi)部的沖突等。

3. 社會(huì)責(zé)任和公共服務(wù)意識(shí)

在面試中,申請(qǐng)者可以通過(guò)展示自己的社會(huì)責(zé)任感和公共服務(wù)意識(shí)來(lái)吸引面試官的注意。申請(qǐng)者可以回顧自己參與過(guò)的社會(huì)實(shí)踐活動(dòng)或公益項(xiàng)目,并總結(jié)自己的收獲和影響。

4. 邏輯思維和問(wèn)題解決

邏輯思維和問(wèn)題解決能力是公共管理崗位中不可或缺的能力。申請(qǐng)者可以通過(guò)閱讀相關(guān)的書籍和案例,提升自己的邏輯思維能力,并進(jìn)行模擬面試來(lái)鍛煉自己的問(wèn)題解決能力。

面試的注意事項(xiàng)

除了準(zhǔn)備面試題,申請(qǐng)者還需要注意以下幾個(gè)方面:

  • 形象儀表:面試時(shí),申請(qǐng)者應(yīng)注意自己的形象儀表,穿著得體、干凈整潔。
  • 表達(dá)和溝通:在面試過(guò)程中,申請(qǐng)者應(yīng)注意用清晰、準(zhǔn)確的語(yǔ)言表達(dá)自己的觀點(diǎn)和想法,并能夠與面試官進(jìn)行良好的溝通。
  • 自信心展示:在面試中展示自信心是非常重要的,可以通過(guò)積極的姿態(tài)、聲音的穩(wěn)定以及自信的表達(dá)方式來(lái)展示自己的自信心。

結(jié)語(yǔ)

準(zhǔn)備清華大學(xué)MPA面試題需要全面的準(zhǔn)備工作,涉及面廣,考察內(nèi)容豐富。申請(qǐng)者應(yīng)從學(xué)術(shù)背景、領(lǐng)導(dǎo)能力、社會(huì)責(zé)任和邏輯思維等方面進(jìn)行準(zhǔn)備,并關(guān)注面試的注意事項(xiàng)。通過(guò)充分的準(zhǔn)備,申請(qǐng)者能夠在清華大學(xué)MPA面試中有更好的發(fā)揮,提高成功的機(jī)會(huì),迎接理想的公共管理之路。

二、1mpa等于多少mpa?

1Mpa=1×10^6Pa,1標(biāo)準(zhǔn)大氣壓=0.101325MPa

Pa(帕)、MPa(兆帕)都是氣壓的國(guó)際制單位。通常所用的氣壓?jiǎn)挝挥信?Pa)、毫米水銀柱高(mm·Hg)、毫巴(mb)。它們之間的換算關(guān)系為:100帕=1毫巴≈3/4毫米水銀柱高。氣象觀測(cè)中常用的測(cè)量氣壓的儀器有水銀氣壓表、空盒氣壓表、氣壓計(jì)。溫度為0℃時(shí)760毫米垂直水銀柱高的壓力,標(biāo)準(zhǔn)大氣壓最先由意大利科學(xué)家托里拆利測(cè)出。

擴(kuò)展資料:

1、氣壓的大小與海拔高度、大氣溫度、大氣密度等有關(guān),一般隨高度升高按指數(shù)律遞減。氣壓有日變化和年變化。一年之中,冬季比夏季氣壓高。氣壓變化與風(fēng)、天氣的好壞等關(guān)系密切,因而是重要?dú)庀笠蜃印?/p>

2、單位換算

1MPa(兆帕)=1000kPa(千帕)=1000000Pa(帕斯卡)

1bar(巴) = 0.1MPa

1atm(標(biāo)準(zhǔn)大氣壓)=0.1013MPa=1.013bar=760mmHg=10.33mH2O

1kgf/cm2(工程公斤力)=0.981bar=0.0981Mpa

1psi(Lb/in2 )=0.07031kgf/cm2=0.06893 bar=6.893kpa

1MPa=145psi

三、MPA廣義?

央行明確提到MPA所涉及到的七大方面,包括資本和杠桿情況、資產(chǎn)負(fù)債情況、流動(dòng)性、定價(jià)行為、資產(chǎn)質(zhì)量、外債風(fēng)險(xiǎn)、信貸政策執(zhí)行。

其中,廣義信貸指標(biāo)則將此前信貸規(guī)模延展到整個(gè)社會(huì)融資。

根據(jù)流傳內(nèi)容顯示,對(duì)廣義信貸的統(tǒng)計(jì)范圍,將在原有各項(xiàng)貸款、債券投資、股權(quán)及其他投資、買入返售資產(chǎn)、存放非存款類金融機(jī)構(gòu)款項(xiàng)等五個(gè)項(xiàng)目基礎(chǔ)上,增加表外理財(cái)資金運(yùn)用項(xiàng)目。

表外理財(cái)資金的數(shù)據(jù),從央行調(diào)查統(tǒng)計(jì)部門的人民幣表外理財(cái)資產(chǎn)負(fù)債表中取數(shù)。其中,表外理財(cái)資金運(yùn)用余額=該表中的資產(chǎn)余額-現(xiàn)金余額-存款余額。

四、mpa黏度?

粘度的法定度量單位-毫帕/秒(mPa·s)。

五、mpa國(guó)標(biāo)?

國(guó)標(biāo)氣壓量程Mpa是標(biāo)準(zhǔn)的國(guó)標(biāo)壓力單位之一讀作兆帕

六、mpa證書?

MPA是公共管理碩士(Master of Public Administration) 專業(yè)學(xué)位的英文簡(jiǎn)稱,是以公共管理學(xué)科及其他相關(guān)學(xué)科為基礎(chǔ)的研究生教育項(xiàng)目,其目的是為政府部門及非政府公共機(jī)構(gòu)培養(yǎng)高層次、應(yīng)用型專門人才。

秋季MPA 學(xué)歷、學(xué)位雙證班,每年12月份參加管理類專業(yè)學(xué)位聯(lián)考,9月份入學(xué),畢業(yè)后獲公共管理碩士學(xué)位證書和研究生學(xué)歷證書。

七、mpa全稱?

Mpa的全稱是Master of Public Administration,公共管理碩士,又譯公共行政碩士(臺(tái)),是為適應(yīng)社會(huì)公共管理現(xiàn)代化、科學(xué)化和專業(yè)化的要求而設(shè)立的學(xué)科,其培養(yǎng)目標(biāo)是為政府部門及公共機(jī)構(gòu)培養(yǎng)德才兼?zhèn)洹⑦m應(yīng)社會(huì)主義現(xiàn)代化建設(shè)需要的高層次、應(yīng)用型、復(fù)合型的管理人才。要求畢業(yè)生成為掌握先進(jìn)分析方法及技術(shù),熟悉具體公共管理或政策領(lǐng)域的領(lǐng)導(dǎo)者,管理者以及其他公共服務(wù)人才。

公共管理學(xué)是一門運(yùn)用管理學(xué)、政治學(xué)、經(jīng)濟(jì)學(xué)等多學(xué)科理論與方法,專門研究公共組織尤其是政府組織的管理活動(dòng)及其規(guī)律的學(xué)科體系。

八、mpa特長(zhǎng)?

MPA是公共管理碩士(Master of Public Administration) 專業(yè)學(xué)位的英文簡(jiǎn)稱,是以公共管理學(xué)科及其他相關(guān)學(xué)科為基礎(chǔ)的研究生教育項(xiàng)目,其目的是為政府部門及非政府公共機(jī)構(gòu)培養(yǎng)高層次、應(yīng)用型專門人才。

在國(guó)外市場(chǎng)經(jīng)濟(jì)發(fā)達(dá)的國(guó)家里, 公共管理碩士、工商管理碩士(MPA)以及法律碩士被稱為文科高層次職業(yè)研究生教育的三大支柱。MPA 教育已成為這些國(guó)家培養(yǎng)高級(jí)公務(wù)員的主要途徑。

九、mpa效應(yīng)?

MPA是央行為維護(hù)金融穩(wěn)定推出的新的監(jiān)管機(jī)制。它由央行于去年12月公布,今年開(kāi)始實(shí)施。此前,央行通過(guò)差別準(zhǔn)備金動(dòng)態(tài)調(diào)整和合意貸款管理機(jī)制來(lái)控制銀行風(fēng)險(xiǎn)。隨著金融創(chuàng)新快速發(fā)展,資產(chǎn)類型更為多樣,狹義的信貸管理越來(lái)越難以有效實(shí)現(xiàn)宏觀審慎管理目標(biāo)。央行因此將原有安排升級(jí)至覆蓋面更廣的MPA考核:

MPA是一個(gè)綜合評(píng)估體系。MPA考核是基于預(yù)先設(shè)定的14項(xiàng)指標(biāo),涉及資本和杠桿情況、資產(chǎn)負(fù)債情況、流動(dòng)性、定價(jià)行為、資產(chǎn)質(zhì)量、外債風(fēng)險(xiǎn)和信貸政策執(zhí)行等7大方面。

十、mahout面試題?

之前看了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

檢測(cè)數(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。將要檢測(cè)數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。

4. 分類器對(duì)vector數(shù)據(jù)進(jìn)行分類。

接下來(lái)貼下我的代碼實(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。將要檢測(cè)數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。

4. 分類器對(duì)vector數(shù)據(jù)進(jìn)行分類。

這三步,代碼我就一次全貼出來(lái);主要是兩個(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";

/*

* 測(cè)試代碼

*/

public static void main(String[] args) {

//將訓(xùn)練數(shù)據(jù)轉(zhuǎn)換成 vector數(shù)據(jù)

makeTrainVector();

//產(chǎn)生訓(xùn)練模型

makeModel(false);

//測(cè)試檢測(cè)數(shù)據(jù)

BayesCheckData.printResult();

}

public static void makeCheckVector(){

//將測(cè)試數(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(){

//將測(cè)試數(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("文件序列化失?。?#34;);

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("檢測(cè)數(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);

}

// 利用貝葉斯算法開(kāi)始分類,并提取得分最好的分類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("檢測(cè)所屬類別是:"+getCheckResult());

}

}

相關(guān)資訊
熱門頻道

Copyright © 2024 招聘街 滇ICP備2024020316號(hào)-38