I have 3 codes that I am running on hadoop
Driver code
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class DecisionTreeDriver {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        
        // Set the filesystem implementation classes
        conf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
        conf.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
        
        // Increase the memory allocation for map tasks
        conf.set("mapreduce.map.java.opts", "-Xmx2048m");
        
        // Increase the number of map tasks
        conf.setInt("mapreduce.job.maps", 10);
        
        // Set the maximum number of attempts for map tasks
        conf.setInt("mapreduce.map.maxattempts", 5);
        
        // Set the input file path
        conf.set("input.file.path", args[0]);

        Job job = Job.getInstance(conf, "Decision Tree");
        job.setJarByClass(DecisionTreeDriver.class);
        job.setMapperClass(DecisionTreeMapper.class);
        job.setReducerClass(DecisionTreeReducer.class);
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(Text.class);
        job.setNumReduceTasks(1);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

Mapper Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class DecisionTreeMapper extends Mapper<LongWritable, Text, IntWritable, Text> {
    private static final IntWritable ONE = new IntWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        Configuration conf = context.getConfiguration();
        String inputFilePath = conf.get("input.file.path");

        try (FileSystem fs = FileSystem.get(conf);
             FSDataInputStream inputStream = fs.open(new Path(inputFilePath));
             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {

            String line;
            while ((line = reader.readLine()) != null) {
                context.write(ONE, new Text(line));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Reducer code
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class DecisionTreeReducer extends Reducer<IntWritable, Text, IntWritable, Text> {
    @Override
    protected void reduce(IntWritable key, Iterable<Text> values, Context context)
        throws IOException, InterruptedException {
        List<String> data = new ArrayList<>();
        for (Text value : values) {
            data.add(value.toString());
        }

        // Simple decision tree logic without using Weka
        Map<String, Integer> classCountMap = new HashMap<>();
        for (String line : data) {
            String[] parts = line.split(",");
            String className = parts[parts.length - 1];
            classCountMap.put(className, classCountMap.getOrDefault(className, 0) + 1);
        }

        String majorityClass = "";
        int maxCount = 0;
        for (Map.Entry<String, Integer> entry : classCountMap.entrySet()) {
            if (entry.getValue() > maxCount) {
                majorityClass = entry.getKey();
                maxCount = entry.getValue();
            }
        }

        String decisionTree = "If (true) then class = " + majorityClass;
        context.write(key, new Text(decisionTree));
    }
}