環(huán)境藝術(shù)設(shè)計(jì)包括:室內(nèi)室外設(shè)計(jì)、建筑裝飾設(shè)計(jì)、景觀設(shè)計(jì)、園林設(shè)計(jì)、城市道路橋梁設(shè)計(jì)、環(huán)境工程改造等。
環(huán)境藝術(shù)設(shè)計(jì)的就業(yè)面很廣,原因在于我國(guó)快速發(fā)展的經(jīng)濟(jì),市政建設(shè)項(xiàng)目和房地產(chǎn)項(xiàng)目如雨后春筍,無(wú)論是室內(nèi)設(shè)計(jì)還是景觀設(shè)計(jì)均需要大量的環(huán)境藝術(shù)設(shè)計(jì)方面的人才,環(huán)境藝術(shù)的專業(yè)涵蓋從過(guò)去的室內(nèi)設(shè)計(jì)發(fā)展到今天室外設(shè)計(jì)、廣場(chǎng)設(shè)計(jì)、園林設(shè)計(jì)、街道設(shè)計(jì)、景觀設(shè)計(jì)、城市道路橋梁設(shè)計(jì)等全方位。本專業(yè)就業(yè)市場(chǎng)一直很廣闊,如建筑裝飾設(shè)計(jì),室內(nèi)外效果圖設(shè)計(jì),園林景觀設(shè)計(jì),環(huán)境工程改造等而且待遇非常高。
環(huán)境設(shè)計(jì)專業(yè)就業(yè)前景還是不錯(cuò)的。
環(huán)境藝術(shù)設(shè)計(jì)行業(yè)狀況環(huán)境藝術(shù)設(shè)計(jì)的就業(yè)面很廣,原因在于我國(guó)快速發(fā)展的經(jīng)濟(jì),市政建設(shè)項(xiàng)目和房地產(chǎn)項(xiàng)目如雨后春筍,無(wú)論是室內(nèi)設(shè)計(jì)還是景觀設(shè)計(jì)均需要大量的環(huán)境藝術(shù)設(shè)計(jì)人才,環(huán)境藝術(shù)的專業(yè)涵蓋從過(guò)去的室內(nèi)設(shè)計(jì)發(fā)展到今天室外設(shè)計(jì)、廣場(chǎng)設(shè)計(jì)、園林設(shè)計(jì)、街道設(shè)計(jì)、景觀設(shè)計(jì)、城市道路橋梁設(shè)計(jì)等全方位、多范圍的設(shè)計(jì)領(lǐng)域。
學(xué)生畢業(yè)以后可在建筑公司、裝飾工程公司、園林工程公司、環(huán)境設(shè)計(jì)研究院所及相關(guān)管理部門(mén)和專業(yè)協(xié)會(huì)從事室內(nèi)設(shè)計(jì)、景觀設(shè)計(jì)、商品展示設(shè)計(jì)、環(huán)境綠化設(shè)計(jì)等環(huán)境藝術(shù)設(shè)計(jì)、預(yù)算編制和管理等工作;可從事相應(yīng)的工程施工管理工作和專業(yè)培訓(xùn)。
在職業(yè)發(fā)展的道路上,環(huán)境設(shè)計(jì)師的面試是至關(guān)重要的一步。為了幫助求職者更好地準(zhǔn)備面試,我們整理了一些常見(jiàn)的面試題及其答案。這些問(wèn)題不僅能幫助你理解崗位要求,還能激發(fā)你的思考,讓你在面試時(shí)更加自信。
在開(kāi)始之前,了解環(huán)境設(shè)計(jì)師的角色和職責(zé)是十分必要的。環(huán)境設(shè)計(jì)師主要負(fù)責(zé)創(chuàng)造合適的空間環(huán)境,以達(dá)到美學(xué)與功能的高度統(tǒng)一。他們通常需要考慮以下幾個(gè)方面:
下面是一些在環(huán)境設(shè)計(jì)師面試中常見(jiàn)的問(wèn)題及其簡(jiǎn)要解析,幫助你更好地準(zhǔn)備:
在回答這個(gè)問(wèn)題時(shí),候選人應(yīng)展示他們對(duì)設(shè)計(jì)的思考過(guò)程以及所追求的設(shè)計(jì)目標(biāo)。比如,可以提及如何將功能性與美感結(jié)合,或者如何在設(shè)計(jì)中融入人類與自然的關(guān)系等。
這一問(wèn)題是考察應(yīng)聘者的專業(yè)經(jīng)驗(yàn)和對(duì)來(lái)訪者影響力。候選人應(yīng)選擇一個(gè)具體的項(xiàng)目,描述其面臨的挑戰(zhàn)、解決方案以及最終結(jié)果。此外,指出在該項(xiàng)目中所使用的設(shè)計(jì)工具和技術(shù)也很重要。
在這個(gè)問(wèn)題上,面試官希望了解候選人的溝通技巧和解決問(wèn)題的能力。候選人可以分享一個(gè)具體的例子,描述如何與客戶溝通、處理不同意見(jiàn),最終達(dá)成一致。
環(huán)境設(shè)計(jì)離不開(kāi)可持續(xù)發(fā)展的理念。候選人可以談?wù)勗谠O(shè)計(jì)中使用環(huán)保材料、節(jié)能技術(shù)以及如何通過(guò)設(shè)計(jì)減少對(duì)環(huán)境的影響等方面的經(jīng)驗(yàn)和見(jiàn)解。
應(yīng)聘者需要列舉出熟悉的設(shè)計(jì)軟件,諸如AutoCAD、SketchUp、Adobe Creative Suite等。同時(shí),可以討論在實(shí)際項(xiàng)目中使用這些軟件的經(jīng)歷,體現(xiàn)出自身的技術(shù)能力。
設(shè)計(jì)師的靈感來(lái)自于多個(gè)方面,可以談?wù)勅绾瓮ㄟ^(guò)閱讀、參加展覽、旅行等方式汲取新的創(chuàng)意和靈感。強(qiáng)調(diào)自己的好奇心與探索精神也是至關(guān)重要的。
除了回答常見(jiàn)面試問(wèn)題,求職者還應(yīng)注意以下幾點(diǎn):
成功的環(huán)境設(shè)計(jì)師面試不僅需要專業(yè)技能的展示,更需要優(yōu)秀的溝通能力和團(tuán)隊(duì)協(xié)作精神。通過(guò)本篇文章提供的面試題及解析,希望能幫助你更自信、有效地準(zhǔn)備即將到來(lái)的面試。
感謝您閱讀這篇文章!希望通過(guò)這些示例和建議,能夠?yàn)槟拿嬖嚋?zhǔn)備提供實(shí)際的幫助和指導(dǎo)。
環(huán)境設(shè)計(jì)是普通高等學(xué)校本科專業(yè),屬于設(shè)計(jì)學(xué)類專業(yè)。本專業(yè)培養(yǎng)適應(yīng)中國(guó)社會(huì)主義經(jīng)濟(jì)建設(shè)的發(fā)展需要,掌握專業(yè)基礎(chǔ)理論、相關(guān)學(xué)科領(lǐng)域理論知識(shí)與專業(yè)技能,并具有創(chuàng)新能力的和設(shè)計(jì)實(shí)踐能力,能在高等藝術(shù)學(xué)校從事環(huán)境設(shè)計(jì)或教學(xué)、研究工作,在藝術(shù)環(huán)境設(shè)計(jì)機(jī)構(gòu)從事公共建筑室內(nèi)設(shè)計(jì)、居住空間設(shè)計(jì)、城市環(huán)境景觀與社區(qū)環(huán)境景觀設(shè)計(jì)、園林設(shè)計(jì),并具備項(xiàng)目策劃與經(jīng)營(yíng)管理、教學(xué)與科研工作能力的高素質(zhì)環(huán)境藝術(shù)應(yīng)用型和研究型人才。
學(xué)生畢業(yè)后可在建筑設(shè)計(jì)研究院、室內(nèi)裝飾設(shè)計(jì)或工程公司、景觀設(shè)計(jì)工程公司等各類相關(guān)行業(yè)企業(yè)從事環(huán)境藝術(shù)設(shè)計(jì)和建筑設(shè)計(jì)工作,可在大專院校等教育單位從事該專業(yè)的教學(xué)工作,也可在房地產(chǎn)開(kāi)發(fā)公司或政府部門(mén)從事城市規(guī)劃和建筑設(shè)計(jì)管理以及相關(guān)領(lǐng)域的研發(fā)應(yīng)用工作。環(huán)境藝術(shù)設(shè)計(jì)專業(yè)畢業(yè)生可從事數(shù)字藝術(shù)設(shè)計(jì)、環(huán)境藝術(shù)設(shè)計(jì)、新聞出版行業(yè)、室內(nèi)設(shè)計(jì)、會(huì)展設(shè)計(jì)行業(yè)、建筑效果圖設(shè)計(jì)、繪圖員、 平面設(shè)計(jì)師 、櫥柜設(shè)計(jì)師、家具設(shè)計(jì)師、施工圖設(shè)計(jì)師、效果圖表現(xiàn)、預(yù)算員、工裝設(shè)計(jì)師、設(shè)計(jì)師助理、施工監(jiān)理等行業(yè)。
環(huán)境設(shè)計(jì)是一門(mén)普通高等學(xué)校本科專業(yè),屬設(shè)計(jì)學(xué)類,該專業(yè)培養(yǎng)掌握專業(yè)基礎(chǔ)理論、相關(guān)學(xué)科領(lǐng)域理論知識(shí)與專業(yè)技能,并具備項(xiàng)目策劃與經(jīng)營(yíng)管理、教學(xué)與科研工作能力的高素質(zhì)環(huán)境藝術(shù)應(yīng)用型和研究型人才。
環(huán)境設(shè)計(jì)專業(yè)專門(mén)培養(yǎng)設(shè)計(jì)公共和私人空間,室內(nèi)和室外空間的設(shè)計(jì)人才。環(huán)境設(shè)計(jì)在一定程度上恢復(fù),改造,保持建筑物和自然環(huán)境的關(guān)系。將來(lái)職業(yè)導(dǎo)向?yàn)榄h(huán)境設(shè)計(jì)師或者是建筑師。
從設(shè)計(jì)的角度來(lái)研究環(huán)境的各個(gè)方面,整體考慮人工和自然等空間要素。目標(biāo)是設(shè)計(jì)出使這些要素和諧統(tǒng)一的建筑和環(huán)境空間,即滿足功能需求,又考慮到環(huán)境安全和生態(tài)的可持續(xù)發(fā)展。
環(huán)境設(shè)計(jì)是一門(mén)交叉學(xué)科,把建筑學(xué),園林,室內(nèi)裝潢,環(huán)境繪圖(如標(biāo)志牌和信息公告牌)的創(chuàng)意結(jié)合在一起,并涵蓋了社會(huì)科學(xué),衛(wèi)生保健學(xué),環(huán)境科學(xué)和自然科學(xué)。
學(xué)習(xí)公共文理課程,同時(shí)還會(huì)上一些介紹環(huán)境設(shè)計(jì)的專業(yè)基礎(chǔ)課。
環(huán)境設(shè)計(jì)專業(yè)會(huì)有很多的結(jié)合實(shí)際工程的實(shí)踐課,實(shí)踐課和實(shí)習(xí)將會(huì)使你了解規(guī)劃和設(shè)計(jì)的真實(shí)世界。你會(huì)在政府部門(mén),非盈利組織,私人企業(yè)中實(shí)習(xí),學(xué)習(xí)到在社區(qū)規(guī)劃,項(xiàng)目開(kāi)發(fā)中如何綜合考慮經(jīng)濟(jì),社會(huì),政治,以及設(shè)計(jì)要素。
環(huán)境設(shè)計(jì)(environment design)是一門(mén)復(fù)雜的交叉學(xué)科,涉及的學(xué)科包括建筑學(xué)、城市規(guī)劃學(xué)、景觀設(shè)計(jì)學(xué)、人類工程學(xué)、環(huán)境心理學(xué)、設(shè)計(jì)美學(xué)、社會(huì)學(xué)、史學(xué)、考古學(xué)、宗教學(xué)、環(huán)境生態(tài)學(xué)、環(huán)境行為學(xué)等學(xué)科。
環(huán)境設(shè)計(jì)通過(guò)一定的組織、圍合手段、對(duì)空間界面(室內(nèi)外墻柱面、地面、頂棚、門(mén)窗等)進(jìn)行藝術(shù)處理(形態(tài)、色彩、質(zhì)地等),運(yùn)用自然光、人工照明、家具、飾物的布置、造型等設(shè)計(jì)語(yǔ)言,以及植物花卉、水體、小品、雕塑等的配置,使建筑物的室內(nèi)外空間環(huán)境體現(xiàn)出特定的氛圍和一定的風(fēng)格,來(lái)滿足人們的功能使用及視覺(jué)審美上的需要。
環(huán)境設(shè)計(jì)專業(yè)的對(duì)聯(lián):
上聯(lián):保護(hù)環(huán)境風(fēng)景這邊獨(dú)好;
下聯(lián):美化家園江山如此多嬌。
上聯(lián):保護(hù)環(huán)境描繪藍(lán)天碧水;
下聯(lián):關(guān)愛(ài)生命創(chuàng)建和諧魅力。
上聯(lián):保護(hù)環(huán)境人人有責(zé);
下聯(lián):造福家園個(gè)個(gè)參與。
上聯(lián):摒除穢物潔凈污流教河水永碧;
下聯(lián):逐去煙塵濾清空氣讓日月更明。
上聯(lián):打造一方凈土;
下聯(lián):共享一片藍(lán)天。
上聯(lián):改造自然年年風(fēng)調(diào)雨順;
下聯(lián):平衡生態(tài)處處水秀山青。
上聯(lián):環(huán)境美花香月下三春醉;
下聯(lián):年成佳雨潤(rùn)寰中五谷豐。
上聯(lián):積雪清垃圾除送走白銀冬季;
下聯(lián):草坪鋪鮮花種迎來(lái)紅粉春天。
上聯(lián):建設(shè)藍(lán)天碧水和諧長(zhǎng)治;
下聯(lián):打造生態(tài)文明魅力上黨。
上聯(lián):科學(xué)發(fā)展政通人和;
下聯(lián):生態(tài)文明山清水秀。
上聯(lián):藍(lán)天碧水生態(tài)文明千秋歲;
下聯(lián):花香鳥(niǎo)語(yǔ)科學(xué)發(fā)展萬(wàn)里春。
上聯(lián):綠化祖國(guó)山青水碧千秋美;
下聯(lián):平衡生態(tài)人杰地靈萬(wàn)物春。
上聯(lián):綠色走進(jìn)家園處處春光無(wú)限;
下聯(lián):生命遠(yuǎn)離污染人人健康長(zhǎng)壽。
2021年12月中旬的星期六和星期天。
環(huán)境藝術(shù)的專業(yè)涵蓋從過(guò)去的室內(nèi)設(shè)計(jì)發(fā)展到今天室外設(shè)計(jì)、廣場(chǎng)設(shè)計(jì)、園林設(shè)計(jì)、街道設(shè)計(jì)、景觀設(shè)計(jì)、城市道路橋梁設(shè)計(jì)等全方位、多范圍的設(shè)計(jì)領(lǐng)域。
現(xiàn)代人們生活水平和公共場(chǎng)所消費(fèi)檔次的提高,設(shè)計(jì)也由過(guò)去偏重于硬件設(shè)施環(huán)境的設(shè)計(jì)轉(zhuǎn)變?yōu)榻裉熘匾暼说纳怼⑿袨椤⑿睦憝h(huán)境創(chuàng)造等更廣泛和更深意義的理解,除了美觀外還要有藝術(shù)性、欣賞性、創(chuàng)造聯(lián)想性等,是近年來(lái)的一個(gè)新興的行業(yè)。
之前看了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)換成向量失敗!");
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("文件序列化失敗!");
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());
}
}