去公园里面不要喂猴子。因为猴子有专业的饲养员。经常喂猴子,可以让他们养成一个坏习惯。
《水怪》里的水猴子就是被男主角水生的傻弟弟傻东放出来的。影片《水怪》取材自中国民间传说,讲述了男主水生年少时父亲被怪物“水猴子”所杀,十年后为了拯救村民,水生与怪物“水猴子”展开激烈大战,破除封建迷信,彰显正义的故事。影片不仅融合了时下流行的冒险、怪兽等元素,也从民间传说中汲取营养,把“水猴子”这样一个怪物形象搬上了银幕。
因为笼子是栅栏,都有空隙。如果有人靠近笼子,有可能猴子从栅栏空隙伸出手抓住你的衣服。猴子为了跟人要好吃的,经常在笼子里上窜下跳,翻跟头,逗得游客驻足而观。
这是猴子就会伸出手,跟人要吃的。如果手里正好拿着苹果等吃的东西,就放在猴子手里。
有俏皮的猴子,见到靠近笼子的人,去抓他们的衣服,吓得游人跑的老远,这时猴子会来个猴脸,龇牙咧嘴。逗得被抓游人,从惊到笑。
分别有1, 2 , 3 , ,4 5只,因为1+2+3+4+5=15,而且每个笼子的只数都不同
给你找到啦! 科学家把六只猴子关在一个笼子里,并在显要的位置放了一串香蕉.猴子看见了香蕉,理所应当的要去吃咯.可就在猴子快要拿到香蕉的时候,科学家立刻用高压水枪击它,迫使它后退.第二只猴子快要拿到香蕉时,同样家法伺候,几个回合下来,再也没有猴子敢接近香蕉了.这时,科学家放走了一猴子,又放进来一只新猴子.新猴子没吃过水枪的苦头,看见了香蕉,很自然的去拿.令人吃惊的事情发生了:另外5只猴子一起跳过去,对这只新猴子一顿暴打,阻止它去拿香蕉.可怜的新猴子被痛扁,也不敢再去碰那个香蕉了.科学家继续试验,从最先的五只猴子中放出一只,再放一只新猴子进来.相同的情况出现了,新猴子去拿香蕉,其它五只对它一顿海K,而打的最凶的,居然是刚才那只新猴子.所以,这只新换进的猴子,也不碰香蕉了.科学家又拿出去一只老猴子,放进一只新的.最后试验的结果的是,笼子里的六只猴子都不在是原先的六只,也没有被水枪击过,但是都不吃香蕉了.
之前看了Mahout官方示例 20news 的调用实现;于是想根据示例的流程实现其他例子。网上看到了一个关于天气适不适合打羽毛球的例子。
训练数据:
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
检测数据:
sunny,hot,high,weak
结果:
Yes=》 0.007039
No=》 0.027418
于是使用Java代码调用Mahout的工具类实现分类。
基本思想:
1. 构造分类数据。
2. 使用Mahout工具类进行训练,得到训练模型。
3。将要检测数据转换成vector数据。
4. 分类器对vector数据进行分类。
接下来贴下我的代码实现=》
1. 构造分类数据:
在hdfs主要创建一个文件夹路径 /zhoujainfeng/playtennis/input 并将分类文件夹 no 和 yes 的数据传到hdfs上面。
数据文件格式,如D1文件内容: Sunny Hot High Weak
2. 使用Mahout工具类进行训练,得到训练模型。
3。将要检测数据转换成vector数据。
4. 分类器对vector数据进行分类。
这三步,代码我就一次全贴出来;主要是两个类 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) {
//将训练数据转换成 vector数据
makeTrainVector();
//产生训练模型
makeModel(false);
//测试检测数据
BayesCheckData.printResult();
}
public static void makeCheckVector(){
//将测试数据转换成序列化文件
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参数是,是否递归删除的意思
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);
}
//将序列化文件转换成向量文件
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参数是,是否递归删除的意思
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("序列化文件转换成向量失败!");
System.out.println(2);
}
}
public static void makeTrainVector(){
//将测试数据转换成序列化文件
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参数是,是否递归删除的意思
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);
}
//将序列化文件转换成向量文件
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参数是,是否递归删除的意思
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("序列化文件转换成向量失败!");
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参数是,是否递归删除的意思
fs.delete(out, true);
}
if(fs.exists(label)){
//boolean参数是,是否递归删除的意思
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("检测数据构造成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时表示总文档数
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());
}
}
1. 请介绍一下WebGIS的概念和作用,以及在实际应用中的优势和挑战。
WebGIS是一种基于Web技术的地理信息系统,通过将地理数据和功能以可视化的方式呈现在Web浏览器中,实现地理空间数据的共享和分析。它可以用于地图浏览、空间查询、地理分析等多种应用场景。WebGIS的优势包括易于访问、跨平台、实时更新、可定制性强等,但也面临着数据安全性、性能优化、用户体验等挑战。
2. 请谈谈您在WebGIS开发方面的经验和技能。
我在WebGIS开发方面有丰富的经验和技能。我熟悉常用的WebGIS开发框架和工具,如ArcGIS API for JavaScript、Leaflet、OpenLayers等。我能够使用HTML、CSS和JavaScript等前端技术进行地图展示和交互设计,并能够使用后端技术如Python、Java等进行地理数据处理和分析。我还具备数据库管理和地理空间数据建模的能力,能够设计和优化WebGIS系统的架构。
3. 请描述一下您在以往项目中使用WebGIS解决的具体问题和取得的成果。
在以往的项目中,我使用WebGIS解决了许多具体问题并取得了显著的成果。例如,在一次城市规划项目中,我开发了一个基于WebGIS的交通流量分析系统,帮助规划师们评估不同交通方案的效果。另外,在一次环境监测项目中,我使用WebGIS技术实现了实时的空气质量监测和预警系统,提供了准确的空气质量数据和可视化的分析结果,帮助政府和公众做出相应的决策。
4. 请谈谈您对WebGIS未来发展的看法和期望。
我认为WebGIS在未来会继续发展壮大。随着云计算、大数据和人工智能等技术的不断进步,WebGIS将能够处理更大规模的地理数据、提供更丰富的地理分析功能,并与其他领域的技术进行深度融合。我期望未来的WebGIS能够更加智能化、个性化,为用户提供更好的地理信息服务,助力各行各业的决策和发展。
这块您需要了解下stm32等单片机的基本编程和简单的硬件设计,最好能够了解模电和数电相关的知识更好,还有能够会做操作系统,简单的有ucos,freeRTOS等等。最好能够使用PCB画图软件以及keil4等软件。希望对您能够有用。
哈士奇是一种受欢迎的犬种,但要确保它们健康快乐地成长,选择合适的哈士奇笼子至关重要。无论是用于训练、安全还是休息,哈士奇笼子都扮演着重要的角色。在选择哈士奇笼子时,有几个关键因素需要考虑。
首先要考虑的是哈士奇笼子的尺寸。笼子应该足够宽敞,让哈士奇能够自由站立、躺下和转身,但又不能太大以至于让哈士奇感到不安全。一般来说,哈士奇笼子的尺寸应该能容纳哈士奇舒适地伸展身体。记得留有足够的空间放置水碗、玩具等必需品。
哈士奇笼子的材质也是选择时需要考虑的重要因素之一。一般来说,金属笼子更耐用且易于清洁,但也更冷。塑料笼子轻便且适合旅行,但通风可能不如金属笼子。选择适合自己和哈士奇需求的材质至关重要。
确保选择的哈士奇笼子易于清洁。保持哈士奇的生活环境清洁是确保其健康的重要因素。选择可以快速拆卸、易于清洁的笼子将为您节省大量时间和精力。
哈士奇笼子的安全性是最重要的考量之一。确保笼子的锁扣牢固可靠,避免哈士奇因为逃离笼子而受伤。此外,检查笼子的边缘和零部件是否完好,以避免哈士奇被卡住或受伤。
最后,关注哈士奇笼子的舒适度也是重要的考量因素。选择一个配有舒适垫和空间充足的笼子,确保哈士奇在其中能够感到安全和舒适。适当的垫子可以帮助减少哈士奇长时间处于笼子中的不适感。
选择合适的哈士奇笼子是照顾您的宠物健康和幸福的重要一环。通过考虑尺寸、材质、易于清洁、安全性和舒适度等关键因素,您可以为您的哈士奇提供一个舒适安全的生活空间。
狗是人类最忠诚的朋友之一,而萨摩耶是其中一种受欢迎的狗狗品种。无论是其迷人的外表还是友好的性格,萨摩耶都能成为家庭中的忠实伙伴。然而,作为萨摩耶主人,我们有责任确保他们得到良好的照顾和舒适的生活环境。在这篇博客文章中,我们将探讨关于萨摩耶和使用笼子的一些重要信息。
萨摩耶是一种来自西伯利亚的犬种,以其浓密的白色双层毛发和友好的性格而闻名。它们通常被认为是温顺、友善且喜欢交往的狗狗,适合作为家庭宠物。萨摩耶对人类充满热情,喜欢与人互动,是一种非常适合家庭生活的狗狗。
尽管萨摩耶是一种友好和温顺的狗狗,但在某些情况下,使用笼子可以成为一种有益的工具。笼子可以提供安全的独立空间,帮助狗狗感到安全和舒适。此外,训练狗狗进入笼子也可以帮助他们学会自我控制和规律生活。
使用笼子时,重要的是确保萨摩耶感到舒适和安全。首先,选择一个适合尺寸的笼子,让萨摩耶能够自由转身和舒展身体,但又不会太大而让他们感到不安。在早期训练阶段,逐渐引导萨摩耶进入笼子,并确保给予奖励和赞扬来巩固积极行为。
另外,不要长时间将萨摩耶放在笼子里,避免让他们感到焦虑和孤独。给予他们足够的活动时间和互动,使他们能够快乐和健康地成长。最重要的是,不要将笼子作为惩罚的工具,而是要让萨摩耶将其视为一个安全和舒适的地方。
在选择笼子时,考虑到萨摩耶的尺寸和行为习性非常重要。笼子应该足够宽敞,让萨摩耶能够在里面舒适地移动,并且要具有足够的通风性和安全性。材质也是一个考虑因素,最好选择坚固耐用且易清洁的材质。
总而言之,使用笼子可以帮助萨摩耶获得安全和舒适的环境,同时可以帮助主人更好地管理和训练他们的狗狗。然而,使用笼子的过程中要注意萨摩耶的感受和需求,确保他们能够快乐健康地成长。希望本篇博客文章能够为养萨摩耶的主人提供一些有益的建议和信息。