通过MapReduce计算拉勾网技能标签分布占比(如Spring、SSM、分布式等等)
时间: 2023-08-14 13:03:48 浏览: 29
这个问题需要一些数据和计算环境的支持。如果有拉勾网的技能标签数据和MapReduce的计算环境,可以按照以下步骤进行计算:
1. 将拉勾网的技能标签数据按照标签名称进行分组,并统计每个标签出现的次数。
2. 计算所有标签出现次数的总和。
3. 对于每个标签,计算它出现的次数与总次数的比例,即占比。
4. 将所有标签的名称和占比输出。
在MapReduce中实现这个过程,可以将技能标签作为Mapper的输入键,出现次数作为值,使用Combiner和Reducer进行合并和计算。最终输出的结果可以保存在HDFS中,或者输出到其他目标系统。
相关问题
使用java编写hadoop实现Java岗位数据分析 公司规模的统计(民营、私企、国企等等) 学历要求分布统计 工作地区的平均工资排行榜 技能标签分布占比(如Spring、SSM、分布式等等) 工作经验的要求分布占比
这是一个非常有意思的数据分析任务!为了实现这个任务,你需要进行以下步骤:
1. 数据收集:从招聘网站上收集相关的数据,包括公司规模、学历要求、工作地区、技能标签、工作经验等信息。
2. 数据预处理:对于收集到的数据进行清洗和处理,例如去除重复数据、处理缺失值、数据格式转换等等。
3. 数据分析:使用Hadoop进行分布式计算,对数据进行统计和分析,包括公司规模的统计、学历要求分布统计、工作地区的平均工资排行榜、技能标签分布占比、工作经验的要求分布占比等等。
4. 数据可视化:将分析结果可视化,例如使用图表展示不同公司规模的数量、不同学历要求的分布、不同工作地区的平均工资等等。
在实现这个任务的过程中,你需要熟练掌握Hadoop的相关技术,例如HDFS、MapReduce、Pig等等。同时,你还需要具备数据分析和可视化的能力,例如使用Python的pandas、matplotlib等库进行数据处理和可视化。
通过MapReduce计算拉勾网工作经验的要求分布百分比
假设我们有一个数据集,其中存储了拉勾网上的招聘信息,包括职位名称和工作经验要求。我们可以使用MapReduce计算出工作经验要求分布的百分比,步骤如下:
1. Map阶段:将数据集中每一条记录中的工作经验要求作为Key,将Value设为1,表示出现了一次该工作经验要求。
2. Reduce阶段:将Map阶段输出的结果按Key聚合,得到每种工作经验要求出现的次数。
3. 计算百分比:将Reduce阶段输出的结果进行处理,计算每种工作经验要求出现的百分比。
下面是Java伪代码:
Map阶段:
```
public static class Map extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text experience = new Text();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String[] fields = value.toString().split(",");
String exp = fields[1]; // 工作经验要求在第二个字段中
experience.set(exp);
context.write(experience, one);
}
}
```
Reduce阶段:
```
public static class Reduce extends Reducer<Text, IntWritable, Text, DoubleWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
int count = 0;
for (IntWritable value : values) {
count += value.get();
}
context.write(key, new DoubleWritable(count));
}
}
```
计算百分比:
```
public static class PercentageMapper extends Mapper<Text, DoubleWritable, Text, DoubleWritable> {
private double totalCount;
protected void setup(Context context) throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
totalCount = conf.getDouble("totalCount", 0.0);
}
public void map(Text key, DoubleWritable value, Context context) throws IOException, InterruptedException {
double percentage = (value.get() / totalCount) * 100;
context.write(key, new DoubleWritable(percentage));
}
}
```
最后,我们需要在驱动程序中设置总记录数并启动作业:
```
public static void main(String[] args) throws Exception {
Job job1 = Job.getInstance(new Configuration());
job1.setJobName("Experience Distribution");
job1.setOutputKeyClass(Text.class);
job1.setOutputValueClass(IntWritable.class);
job1.setMapperClass(Map.class);
job1.setReducerClass(Reduce.class);
FileInputFormat.setInputPaths(job1, new Path(args[0]));
FileOutputFormat.setOutputPath(job1, new Path(args[1]));
job1.waitForCompletion(true);
long totalCount = job1.getCounters().findCounter(TaskCounter.MAP_INPUT_RECORDS).getValue();
Job job2 = Job.getInstance(new Configuration());
job2.setJobName("Experience Percentage");
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(DoubleWritable.class);
job2.setMapperClass(PercentageMapper.class);
job2.getConfiguration().setDouble("totalCount", totalCount);
FileInputFormat.setInputPaths(job2, new Path(args[1]));
FileOutputFormat.setOutputPath(job2, new Path(args[2]));
job2.waitForCompletion(true);
}
```
以上代码中,我们假设输入文件的路径为args[0],第一次输出文件的路径为args[1],第二次输出文件的路径为args[2]。在第一次作业中,我们使用MapReduce计算出每种工作经验要求出现的次数;在第二次作业中,我们使用MapReduce计算出每种工作经验要求出现的百分比,并将总记录数传递给Mapper通过setup()方法。最后,我们可以在输出文件中查看工作经验要求的分布情况及其百分比。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)