久久精品日韩无码|61伊人久久绿帽|最新国产浮力网站|亚州aV无码国产|明星一二三区av|超碰人人在线成人|澳门无码福利av

衛(wèi)生統(tǒng)計順口溜?

時間:2025-04-02 17:25 人氣:0 編輯:招聘街

一、衛(wèi)生統(tǒng)計順口溜?

1.勤洗手、勤洗頭,勤換衣,勤洗澡;

2.勤理發(fā)、勤刷牙,勤剪指甲勤問好;

3.吐痰要用紙包好,莫往地上直接飄;

4.上完廁所要沖水,廢物扔進垃圾桶;

講衛(wèi)生的順口溜 勤洗手、勤洗頭,勤換衣,勤洗澡; 勤理發(fā)、勤刷牙,勤剪指甲勤問好; 吐痰要用紙包好,莫往地上直接飄; 上完廁所要沖水,廢物扔進垃圾桶; 輕聲細語要習慣,安靜地方不要吵; 愛清潔、講文明,一身無病少煩惱。

二、衛(wèi)生統(tǒng)計學代碼?

你有性病與衛(wèi)生統(tǒng)計學 ,代碼是100401

三、中國衛(wèi)生統(tǒng)計分析報告

中國衛(wèi)生統(tǒng)計分析報告

中國衛(wèi)生統(tǒng)計分析報告旨在全面評估中國衛(wèi)生系統(tǒng)的發(fā)展現(xiàn)狀,深入剖析衛(wèi)生領域的數(shù)據(jù)和趨勢,為相關政策制定和決策提供參考依據(jù)。通過對衛(wèi)生統(tǒng)計數(shù)據(jù)的搜集、整理和分析,可以揭示出衛(wèi)生服務的覆蓋范圍、質(zhì)量水平、資源配置情況等關鍵指標,為提升中國衛(wèi)生事業(yè)水平和可持續(xù)發(fā)展提供重要支撐。

衛(wèi)生服務覆蓋范圍

根據(jù)中國衛(wèi)生統(tǒng)計分析報告的數(shù)據(jù)顯示,中國衛(wèi)生服務覆蓋范圍逐漸擴大,城鄉(xiāng)居民的衛(wèi)生保障水平有所提高。然而,仍存在著城鄉(xiāng)差距和區(qū)域不平衡的現(xiàn)象,特別是基層衛(wèi)生服務的覆蓋面仍然有待加強。

衛(wèi)生服務質(zhì)量評估

衛(wèi)生服務質(zhì)量是衡量衛(wèi)生系統(tǒng)績效的重要指標之一。中國衛(wèi)生統(tǒng)計分析報告通過評估醫(yī)療技術(shù)水平、服務態(tài)度、醫(yī)患關系等多維度指標,發(fā)現(xiàn)了一些存在的問題和改進建議,為優(yōu)化衛(wèi)生服務提供了實用建議。

資源配置狀況

衛(wèi)生資源的合理配置是保障衛(wèi)生服務可持續(xù)發(fā)展的關鍵。中國衛(wèi)生統(tǒng)計分析報告揭示了衛(wèi)生資源在不同地區(qū)、不同醫(yī)療機構(gòu)之間的分布差異,為政府部門和衛(wèi)生機構(gòu)提供了科學的依據(jù),以實現(xiàn)資源的優(yōu)化配置。

衛(wèi)生服務需求預測

通過對中國衛(wèi)生統(tǒng)計數(shù)據(jù)的分析,可以預測未來衛(wèi)生服務的需求趨勢,為衛(wèi)生規(guī)劃和政策制定提供重要參考。結(jié)合人口老齡化、疾病譜變化等因素,可以更加科學地調(diào)整衛(wèi)生服務布局,滿足人民群眾日益增長的健康需求。

結(jié)語

中國衛(wèi)生統(tǒng)計分析報告是中國衛(wèi)生事業(yè)發(fā)展的重要支撐,其數(shù)據(jù)和分析為政府和衛(wèi)生機構(gòu)提供了寶貴的參考信息。通過持續(xù)的統(tǒng)計分析工作,可以更好地了解中國衛(wèi)生系統(tǒng)的發(fā)展狀況,推動衛(wèi)生事業(yè)的持續(xù)改善和發(fā)展。

四、812衛(wèi)生統(tǒng)計基礎考哪些?

衛(wèi)生統(tǒng)計學是以醫(yī)學,特別是預防醫(yī)學的理論為指導,用統(tǒng)計學原理和方法研究醫(yī)學,側(cè)重預防醫(yī)學中數(shù)據(jù)的搜集、整理與分析的一門應用性學科,它是公共衛(wèi)生工作者必不可少的工具。在學習本課程時,應注意掌握衛(wèi)生統(tǒng)計學的基本理論、基本知識、基本方法及基本技能,掌握調(diào)查設計及實驗設計的原則與內(nèi)容,掌握醫(yī)學人口統(tǒng)計、疾病統(tǒng)計等常用統(tǒng)計指標,并用之評價人群健康狀況,為衛(wèi)生決策提供統(tǒng)計信息。

課程大綱

第一章 緒論

第二章 定量資料的統(tǒng)計描述

第三章 定性資料的統(tǒng)計描述

第四章 常用概率分布

第五章 參數(shù)估計基礎

第六章 假設檢驗基礎

第七章 χ2 檢驗

第八章 實驗設計

第九章 方差分析

第十章 基于秩次的非參數(shù)檢驗

第十一章 兩變量關聯(lián)性分析

第十二章 簡單回歸分析

第十三章 多重線性回歸與相關

第十四章 調(diào)查設計

第十五章 總體特征抽樣調(diào)查的設計與分析

第十六章 橫斷面研究資料的統(tǒng)計分析

第十七章 隊列研究的設計與分析

第十八章 病例對照研究的設計與分析

第十九章 Logistic回歸

第二十章 生存分析

第二十一章 綜合評價

第二十二章 Meta分析

五、衛(wèi)生統(tǒng)計學就業(yè)前景?

流行病和衛(wèi)生統(tǒng)計學是醫(yī)學科學重要的基礎學科和方法學科。隨著越來越多的流行病學的數(shù)據(jù)分析需要更多統(tǒng)計學知識,流行病學和統(tǒng)計學的結(jié)合越來越重要,在這個大的背景下,中國人民大學流行病與公共衛(wèi)生統(tǒng)計專業(yè)誕生于2006年,所以流行病和衛(wèi)生統(tǒng)計學是一個非常年輕的學科。

六、衛(wèi)生統(tǒng)計學試題問答題

衛(wèi)生統(tǒng)計學試題是醫(yī)學生和衛(wèi)生專業(yè)學生備考的一道難題。在衛(wèi)生統(tǒng)計學這門學科中,試題形式多種多樣。其中,問答題尤為重要,既考察了學生對衛(wèi)生統(tǒng)計學理論的理解,也考察了學生獨立思考和分析問題的能力。本文將提供一些常見的衛(wèi)生統(tǒng)計學試題問答題以供大家學習和參考。

1. 什么是衛(wèi)生統(tǒng)計學?

衛(wèi)生統(tǒng)計學是研究人群健康狀況及其與環(huán)境、生活方式等因素之間關系的一門學科。通過收集、整理和分析健康數(shù)據(jù),了解疾病的流行病學特征,發(fā)現(xiàn)不良衛(wèi)生事件的風險因素,為衛(wèi)生政策制定和疾病預防控制提供科學依據(jù)。

2. 衛(wèi)生統(tǒng)計學的應用領域有哪些?

衛(wèi)生統(tǒng)計學的應用領域非常廣泛:

  • 流行病學研究:通過流行病學調(diào)查和分析,揭示疾病的發(fā)生規(guī)律和危險因素,為疾病預防和控制提供依據(jù)。
  • 衛(wèi)生規(guī)劃和政策:根據(jù)衛(wèi)生統(tǒng)計數(shù)據(jù),制定衛(wèi)生規(guī)劃和政策,改善公共衛(wèi)生服務。
  • 衛(wèi)生經(jīng)濟學研究:評估衛(wèi)生服務的經(jīng)濟效益,指導衛(wèi)生資源的合理配置。
  • 醫(yī)療質(zhì)量評價:通過衛(wèi)生統(tǒng)計學方法,評估醫(yī)療機構(gòu)和醫(yī)療技術(shù)的質(zhì)量和效果。
  • 健康風險評估:分析環(huán)境和生活方式等因素對健康的影響,評估健康風險。
  • 衛(wèi)生教育和健康促進:根據(jù)衛(wèi)生統(tǒng)計學數(shù)據(jù),制定衛(wèi)生教育計劃和健康促進活動。

3. 衛(wèi)生統(tǒng)計學問答題示例

問題一:

描述什么是相對危險度?如何計算相對危險度?

答:

相對危險度是用于比較兩組人群中患病風險的指標。它可以衡量不同因素對疾病患病率的影響。

計算相對危險度的方法是:

相對危險度 = 患病組中的患病率 / 非患病組中的患病率

問題二:

什么是衛(wèi)生事件的風險因素?請舉例說明。

答:

衛(wèi)生事件的風險因素是指與衛(wèi)生事件發(fā)生相關的各種因素。例如:

  • 個體因素:年齡、性別、基因等。
  • 環(huán)境因素:空氣質(zhì)量、水質(zhì)、環(huán)境污染等。
  • 生活方式因素:飲食習慣、運動、吸煙等。
  • 社會因素:教育水平、社會經(jīng)濟地位等。

問題三:

如何評估一項衛(wèi)生政策的效果?

答:

評估一項衛(wèi)生政策的效果需要進行定量和定性的分析:

  • 定量分析:利用衛(wèi)生統(tǒng)計學方法,收集和分析關于政策執(zhí)行前后的數(shù)據(jù),如患病率、死亡率等,從而比較政策的影響。
  • 定性分析:通過定性研究方法,收集和分析利益相關者的意見和反饋,了解政策在實施過程中的問題和影響。

問題四:

為什么要進行衛(wèi)生統(tǒng)計學研究?

答:

進行衛(wèi)生統(tǒng)計學研究有以下幾個重要原因:

  • 疾病預防和控制:通過研究疾病的發(fā)生規(guī)律和風險因素,為疾病的預防和控制提供科學依據(jù)。
  • 衛(wèi)生政策制定:根據(jù)衛(wèi)生統(tǒng)計數(shù)據(jù),制定科學、有效的衛(wèi)生政策,改善公共衛(wèi)生服務。
  • 醫(yī)療質(zhì)量評價:評估醫(yī)療機構(gòu)和醫(yī)療技術(shù)的質(zhì)量和效果,提高醫(yī)療服務的質(zhì)量。
  • 衛(wèi)生服務規(guī)劃:根據(jù)人群健康狀況和衛(wèi)生需求,制定衛(wèi)生服務規(guī)劃,合理配置衛(wèi)生資源。
  • 健康風險評估:分析環(huán)境和生活方式等因素對健康的影響,評估健康風險。

結(jié)語

衛(wèi)生統(tǒng)計學試題問答題是考察學生對衛(wèi)生統(tǒng)計學知識掌握程度和分析問題能力的重要形式之一。通過不斷練習和積累,學生可以提高自己在衛(wèi)生統(tǒng)計學試題問答題上的表現(xiàn),并為未來的衛(wèi)生工作做好準備。

七、衛(wèi)生統(tǒng)計學科學出版社

衛(wèi)生統(tǒng)計學科學出版社:提供專業(yè)的衛(wèi)生統(tǒng)計學學術(shù)出版服務

衛(wèi)生統(tǒng)計學是一門關注人類健康和疾病模式的學科,通過數(shù)據(jù)收集、分析和解釋,為公共衛(wèi)生政策制定和實施提供科學依據(jù)。為了促進衛(wèi)生統(tǒng)計學學術(shù)研究的發(fā)展和學術(shù)成果的傳播,衛(wèi)生統(tǒng)計學科學出版社成立了。作為國內(nèi)領先的衛(wèi)生統(tǒng)計學學術(shù)出版機構(gòu),我們致力于為學者、研究人員和學生提供專業(yè)的出版服務。

我們的出版社擁有一支由資深專家和學者組成的編委會,負責審查和篩選來自全國各地的學術(shù)論文和研究成果。我們嚴格遵循學術(shù)倫理和出版道德準則,以確保所發(fā)表的內(nèi)容的質(zhì)量和可信度。同時,我們與不同領域的專家合作,共同編纂和編纂我們的出版物,以確保內(nèi)容的科學性和權(quán)威性。

專業(yè)的期刊出版服務

作為衛(wèi)生統(tǒng)計學領域的重要學術(shù)出版機構(gòu),我們出版了一系列高質(zhì)量的學術(shù)期刊。這些期刊涵蓋了衛(wèi)生統(tǒng)計學的各個領域,包括流行病學、生物統(tǒng)計學、環(huán)境衛(wèi)生統(tǒng)計學等。我們鼓勵學者和研究人員向我們投遞原創(chuàng)性和高水平的學術(shù)論文,我們將根據(jù)論文的質(zhì)量和相關領域的重要性進行審稿和發(fā)表。

我們的期刊使用匿名評審制度,確保論文的評估和選擇過程公正客觀。我們也歡迎國內(nèi)外專家加入我們的編委會,為期刊的發(fā)展和提升質(zhì)量提供專業(yè)的支持和指導。我們致力于打造國際高水平的衛(wèi)生統(tǒng)計學學術(shù)期刊,為廣大學者提供交流和展示研究成果的平臺。

多元化的學術(shù)出版物

除了期刊,我們還出版了大量的專著、教材和學術(shù)論文集,涵蓋了衛(wèi)生統(tǒng)計學的不同方面和研究領域。我們提供多元化的學術(shù)出版物,以滿足不同讀者的需求。無論您是學術(shù)研究人員、學生還是工作于衛(wèi)生統(tǒng)計學領域的專業(yè)人士,我們都有適合您的出版物。

我們出版物的特點包括:

  • 內(nèi)容權(quán)威:我們的出版物由衛(wèi)生統(tǒng)計學領域的頂尖專家和學者編寫,具有權(quán)威性和可靠性。
  • 學術(shù)深度:我們出版的書籍和教材涵蓋了衛(wèi)生統(tǒng)計學的基礎知識和前沿研究,既適合初學者入門,也適合專業(yè)人士深入學習。
  • 實用性:我們的出版物不僅關注理論研究,還強調(diào)實踐應用。它們?yōu)榻鉀Q實際衛(wèi)生問題提供了指導和方法。
  • 內(nèi)容更新:我們與學術(shù)界的專家和機構(gòu)合作,定期更新和修訂我們的出版物,以保持其時效性。

專業(yè)的學術(shù)服務

除了出版服務,我們還為學者和研究人員提供一系列專業(yè)的學術(shù)服務,包括學術(shù)咨詢、項目評審和學術(shù)交流等。我們的專家團隊具有豐富的經(jīng)驗和專業(yè)知識,在衛(wèi)生統(tǒng)計學領域提供全方位的支持和指導。

我們的學術(shù)服務包括:

  • 學術(shù)咨詢:我們的專家團隊可以為學者和研究人員提供關于衛(wèi)生統(tǒng)計學研究的咨詢和建議。無論是研究設計、數(shù)據(jù)分析還是結(jié)果解釋,我們都可以為您提供專業(yè)的指導。
  • 項目評審:我們的專家可以參與各類衛(wèi)生統(tǒng)計學研究項目的評審,確保項目的科學性和有效性。
  • 學術(shù)交流:我們定期舉辦學術(shù)研討會和培訓班,為學者和研究人員提供交流和學習的平臺。

我們致力于提供專業(yè)的學術(shù)出版服務和學術(shù)支持,推動衛(wèi)生統(tǒng)計學研究的發(fā)展和進步。我們歡迎廣大學者、研究人員和學生的投稿和合作,共同推動衛(wèi)生統(tǒng)計學學術(shù)領域的發(fā)展。

如果您對我們的出版服務和學術(shù)服務有任何疑問或需求,請隨時與我們聯(lián)系。我們將竭誠為您提供最優(yōu)質(zhì)的服務。

**Note: The generated text in the codeblock is of format. Please refer to the raw text of the response to view the HTML structure.

八、衛(wèi)生統(tǒng)計信息系統(tǒng)要素包括?

組織機構(gòu),人員,數(shù)據(jù)、統(tǒng)計指標,計算機

九、衛(wèi)生統(tǒng)計學是什么專業(yè)?

衛(wèi)生統(tǒng)計學是醫(yī)學科學重要的基礎學科和方法學科。

隨著越來越多的流行病學的數(shù)據(jù)分析,需要更多統(tǒng)計學知識,流行病學和統(tǒng)計學結(jié)合越來越重要,在這個大的背景下,中國人民大學流行病與衛(wèi)生統(tǒng)計學專業(yè)誕生于2006年并具有公共衛(wèi)生與預防醫(yī)學醫(yī)學碩士學位授予資格。

十、mahout面試題?

之前看了Mahout官方示例 20news 的調(diào)用實現(xiàn);于是想根據(jù)示例的流程實現(xiàn)其他例子。網(wǎng)上看到了一個關于天氣適不適合打羽毛球的例子。

訓練數(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工具類進行訓練,得到訓練模型。

3。將要檢測數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。

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

接下來貼下我的代碼實現(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工具類進行訓練,得到訓練模型。

3。將要檢測數(shù)據(jù)轉(zhuǎn)換成vector數(shù)據(jù)。

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

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

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

makeTrainVector();

//產(chǎ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("文件序列化失?。?#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("生成訓練模型失??!");

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());

}

}

相關資訊
熱門頻道

Copyright © 2024 招聘街 滇ICP備2024020316號-38