#vulnerable code 
                                private double calculateError(Dataframe trainingData, Map<Object, Double> thitas) {
        //The cost function as described on http://ufldl.stanford.edu/wiki/index.php/Softmax_Regression
        //It is optimized for speed to reduce the amount of loops
        double error=0.0;
        
        for(Map.Entry<Integer, Record> e : trainingData.entries()) {
            Integer rId = e.getKey();
            Record r = e.getValue();
            double yPredicted = hypothesisFunction(r.getX(), thitas);
            trainingData._unsafe_set(rId, new Record(r.getX(), r.getY(), yPredicted, r.getYPredictedProbabilities()));
            error+=Math.pow(TypeInference.toDouble(r.getY()) -yPredicted, 2);
        }
        
        return error;
    } 
                            #location 11 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                private double calculateError(Dataframe trainingData, Map<Object, Double> thitas) {
        //The cost function as described on http://ufldl.stanford.edu/wiki/index.php/Softmax_Regression
        //It is optimized for speed to reduce the amount of loops
        
        double error = StreamMethods.stream(trainingData.entries(), isParallelized()).mapToDouble(e -> { 
            Integer rId = e.getKey();
            Record r = e.getValue();
            double yPredicted = hypothesisFunction(r.getX(), thitas);
            trainingData._unsafe_set(rId, new Record(r.getX(), r.getY(), yPredicted, r.getYPredictedProbabilities()));
            return Math.pow(TypeInference.toDouble(r.getY()) -yPredicted, 2);
        }).sum();
        
        return error;
    }