您好,用戶可點(diǎn)擊彈窗上的關(guān)閉按鈕,點(diǎn)擊關(guān)閉設(shè)置,選擇本次關(guān)閉、本日關(guān)閉、本周關(guān)閉或本月關(guān)閉,點(diǎn)擊確定即可關(guān)閉頁(yè)面提醒服務(wù);也可通過(guò)編輯短信“00000”發(fā)送至1065934661關(guān)閉空中衛(wèi)士短信提醒服務(wù)。注意:通過(guò)彈窗上選擇對(duì)應(yīng)的關(guān)閉時(shí)間后,則關(guān)閉成功后立即失效。通過(guò)短信方式取消的,取消成功后,24小時(shí)內(nèi)失效。
優(yōu)點(diǎn):天空衛(wèi)士具有強(qiáng)大的后發(fā)優(yōu)勢(shì),成立以來(lái),博采眾長(zhǎng),加之利用高份額的研發(fā)投入,在網(wǎng)絡(luò)安全領(lǐng)域具有了天然的領(lǐng)先優(yōu)勢(shì)。
缺點(diǎn):因?yàn)槭潜O(jiān)控軟件可以截圖聊天記錄,一定有泄露的風(fēng)險(xiǎn)。比如你的電腦長(zhǎng)期使用虛擬機(jī)進(jìn)程而不是工作上的應(yīng)用,也是很明顯的。
天空衛(wèi)士以統(tǒng)一內(nèi)容安全技術(shù)UCS(Unified Content Security)為核心,在數(shù)據(jù)安全、WEB安全、郵件安全、移動(dòng)安全和接入云安全等領(lǐng)域開(kāi)展深入研究和研發(fā),公司現(xiàn)有過(guò)百位研發(fā)工程師,已完成旗艦品牌“SecGator? 安全鱷”系列產(chǎn)品(SecGator? UCSS、SecGator? UCSG-DLP以及SecGator? UCSG-ASWG)的發(fā)布與應(yīng)用,為組織有效應(yīng)對(duì)APT攻擊、釣魚信息、內(nèi)部數(shù)據(jù)竊取等威脅,保護(hù)關(guān)鍵數(shù)據(jù)資產(chǎn)。
數(shù)據(jù)安全、WEB安全、郵件安全、移動(dòng)安全和接入云安全等。
天空衛(wèi)士DLP安全終端(UCSC-DLP)安裝在企業(yè)用戶的終端上,既可以監(jiān)控和阻斷試圖離開(kāi)終端的敏感數(shù)據(jù),并以彈窗的方式警告用戶的違規(guī)情況,又可以掃描端點(diǎn)上的存儲(chǔ)介質(zhì)保存的機(jī)密數(shù)據(jù),將其記錄或移動(dòng)至安全位置,防止企業(yè)的核心數(shù)據(jù)資產(chǎn)以違反安全策略規(guī)定的形式流出企業(yè)。
任務(wù)只要你達(dá)成四鐵甲衛(wèi)士的羈絆就可以了
北京天空衛(wèi)士網(wǎng)絡(luò)安全技術(shù)有限公司是一家專注于網(wǎng)絡(luò)安全領(lǐng)域的高新技術(shù)企業(yè)。公司成立于2015年,致力于為政府、企業(yè)和個(gè)人提供全方位的網(wǎng)絡(luò)安全解決方案。憑借多年的行業(yè)經(jīng)驗(yàn)和專業(yè)技術(shù)團(tuán)隊(duì),天空衛(wèi)士已經(jīng)成為國(guó)內(nèi)網(wǎng)絡(luò)安全領(lǐng)域的領(lǐng)軍企業(yè)之一。
天空衛(wèi)士擁有一支經(jīng)驗(yàn)豐富的專業(yè)團(tuán)隊(duì),涵蓋網(wǎng)絡(luò)安全咨詢、安全評(píng)估、安全防護(hù)、安全監(jiān)測(cè)等多個(gè)領(lǐng)域。公司為客戶提供全方位的網(wǎng)絡(luò)安全解決方案,幫助客戶有效識(shí)別和應(yīng)對(duì)各類網(wǎng)絡(luò)安全風(fēng)險(xiǎn),確保信息系統(tǒng)的安全穩(wěn)定運(yùn)行。
天空衛(wèi)士擁有自主研發(fā)的一系列網(wǎng)絡(luò)安全產(chǎn)品,包括入侵檢測(cè)系統(tǒng)、漏洞掃描系統(tǒng)、安全審計(jì)系統(tǒng)等,采用前沿的人工智能和大數(shù)據(jù)分析技術(shù),為客戶提供智能化、精準(zhǔn)化的網(wǎng)絡(luò)安全防護(hù)。同時(shí),公司還積極參與國(guó)家級(jí)網(wǎng)絡(luò)安全標(biāo)準(zhǔn)的制定,為行業(yè)發(fā)展貢獻(xiàn)力量。
天空衛(wèi)士秉持"客戶至上"的服務(wù)理念,為客戶提供7x24小時(shí)的技術(shù)支持和應(yīng)急響應(yīng)。公司建立了完善的客戶服務(wù)體系,通過(guò)定期培訓(xùn)、技術(shù)交流等方式,確??蛻裟軌虺浞掷霉镜漠a(chǎn)品和服務(wù),實(shí)現(xiàn)網(wǎng)絡(luò)安全的全面防護(hù)。
總之,北京天空衛(wèi)士網(wǎng)絡(luò)安全技術(shù)有限公司是一家專業(yè)、創(chuàng)新的網(wǎng)絡(luò)安全服務(wù)商,致力于為客戶提供優(yōu)質(zhì)的網(wǎng)絡(luò)安全解決方案,為國(guó)內(nèi)網(wǎng)絡(luò)安全事業(yè)的發(fā)展貢獻(xiàn)自己的力量。感謝您閱讀本文,希望通過(guò)這篇文章,您能夠更好地了解天空衛(wèi)士及其在網(wǎng)絡(luò)安全領(lǐng)域的專業(yè)實(shí)力。
家是一個(gè)人最舒適的港灣,人們渴望在家中感到安全和舒適。然而,有時(shí)候我們不能完全控制家里的環(huán)境,可能會(huì)受到各種威脅,如空氣污染、火災(zāi)和盜竊等。幸運(yùn)的是,現(xiàn)代科技的發(fā)展為我們提供了各種解決方案,其中之一就是家居衛(wèi)士。
家居衛(wèi)士是一種智能設(shè)備,旨在提供全面的家庭安全和健康保護(hù)。它可以監(jiān)測(cè)家庭內(nèi)部和外部的各種風(fēng)險(xiǎn),并采取適當(dāng)?shù)拇胧﹣?lái)預(yù)防和處理這些威脅。下面我們將介紹一些家居衛(wèi)士的常見(jiàn)功能和優(yōu)勢(shì)。
現(xiàn)代家庭中常常存在各種空氣污染源,如煙霧、甲醛、細(xì)菌和花粉等。這些污染物可能對(duì)我們的健康造成威脅,導(dǎo)致呼吸道問(wèn)題、過(guò)敏反應(yīng)甚至疾病。家居衛(wèi)士配備了先進(jìn)的傳感器,能夠監(jiān)測(cè)室內(nèi)空氣質(zhì)量,并實(shí)時(shí)提供數(shù)據(jù)和警報(bào)。一旦檢測(cè)到污染物超過(guò)安全值,家居衛(wèi)士將會(huì)自動(dòng)啟動(dòng)空氣凈化器或報(bào)警系統(tǒng),確保家人的健康和安全。
火災(zāi)是家庭安全的重要威脅之一。家居衛(wèi)士配備了先進(jìn)的煙霧和火焰?zhèn)鞲衅?,能夠在火?zāi)發(fā)生前及時(shí)發(fā)出警報(bào)。它還可以與智能家居系統(tǒng)聯(lián)動(dòng),自動(dòng)觸發(fā)滅火裝置、關(guān)閉電源和呼叫緊急救援。這種預(yù)警系統(tǒng)大大提高了火災(zāi)發(fā)生時(shí)家人們自救和逃生的機(jī)會(huì),保護(hù)了家庭財(cái)產(chǎn)和生命安全。
家居衛(wèi)士通常配備高清攝像頭和智能監(jiān)控系統(tǒng),為家庭安全提供全方位保護(hù)。通過(guò)連接到手機(jī)或電腦,你可以隨時(shí)隨地監(jiān)視家里的情況,對(duì)家人和財(cái)產(chǎn)進(jìn)行實(shí)時(shí)監(jiān)管。一旦發(fā)現(xiàn)可疑行為,如入侵、搶劫或破壞,家居衛(wèi)士將立即發(fā)送警報(bào),并提供相關(guān)證據(jù)。這種家庭安防監(jiān)控系統(tǒng)的存在,不僅有效嚇退潛在的入侵者,還增加了家人的安全感。
家居衛(wèi)士既可以作為安全設(shè)備,也可以作為智能家居中樞。它與其他智能設(shè)備和家居系統(tǒng)無(wú)縫連接,實(shí)現(xiàn)全方位的智能控制。通過(guò)手機(jī)應(yīng)用或語(yǔ)音助手,你可以遠(yuǎn)程控制家里的燈光、溫度、門窗、電器和其他設(shè)備。這不僅提高了家庭的舒適度和便利性,還使家庭更加安全。例如,當(dāng)你不在家時(shí),可以通過(guò)智能家居控制將燈光打開(kāi),營(yíng)造出有人在家的假象,預(yù)防盜竊。
家居衛(wèi)士為我們的家庭帶來(lái)了全面的安全和健康保護(hù)。它不僅能夠監(jiān)測(cè)室內(nèi)和室外的各種風(fēng)險(xiǎn),還能及時(shí)采取措施來(lái)預(yù)防和應(yīng)對(duì)威脅。使用家居衛(wèi)士,我們可以放心地享受家庭生活,不再擔(dān)心各種意外事件的發(fā)生。家居衛(wèi)士是現(xiàn)代家庭必備的智能設(shè)備,它讓我們的家變得更安全、更健康,為我們創(chuàng)造一個(gè)更美好的家居環(huán)境。
最近,智能衛(wèi)士技術(shù)在安全領(lǐng)域引起了廣泛關(guān)注。智能衛(wèi)士系統(tǒng)是一種利用人工智能技術(shù)來(lái)提高安全性的解決方案,為我們的生活和工作環(huán)境帶來(lái)了許多好處。
智能衛(wèi)士系統(tǒng)可以監(jiān)視和保護(hù)我們的住宅和辦公場(chǎng)所,幫助減少盜竊和入侵的風(fēng)險(xiǎn)。通過(guò)使用先進(jìn)的傳感器和監(jiān)控設(shè)備,智能衛(wèi)士能夠及時(shí)發(fā)現(xiàn)異常情況并向用戶發(fā)送警報(bào)。這種系統(tǒng)還可以集成門禁系統(tǒng)、視頻監(jiān)控等功能,提供全方位的安全保障。
隨著人工智能技術(shù)和物聯(lián)網(wǎng)技術(shù)的飛速發(fā)展,智能衛(wèi)士系統(tǒng)正在不斷升級(jí)和完善。未來(lái),智能衛(wèi)士將更加智能化、智能化,并且能夠更好地滿足人們對(duì)安全的需求。
智能衛(wèi)士系統(tǒng)的出現(xiàn)為我們的生活帶來(lái)了更多便利和安全。通過(guò)建立一個(gè)智能衛(wèi)士系統(tǒng),我們可以更好地保護(hù)我們的家庭和工作環(huán)境,實(shí)現(xiàn)安全、舒適的生活。
閃電天空衛(wèi)士當(dāng)然是強(qiáng)過(guò)MAX的防空炮的,傷害強(qiáng)一些(對(duì)于雙手放空MAX),續(xù)航強(qiáng)一些(天空衛(wèi)士很少遇到和飛機(jī)對(duì)炮時(shí)沒(méi)彈藥的情況,而MAX經(jīng)常出現(xiàn),而且天空衛(wèi)士只要點(diǎn)幾級(jí)的后備彈藥就很少出現(xiàn)沒(méi)有彈藥的情況),能輕松擊中更遠(yuǎn)的目標(biāo),對(duì)坦克有較弱的殺傷力,但并不是沒(méi)有,如果你遇到一個(gè)只有駕駛員的白板決裂的話天空衛(wèi)士可以勝出,對(duì)步兵能力很差,雖然打遠(yuǎn)距離散射也不厲害但是近距離打人照樣打不到,10米外的步兵基本上不可能用天空衛(wèi)士打死,除非是在開(kāi)闊地,不如直接碾壓
之前看了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("文件序列化失?。?#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-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());
}
}