public void createTrainingSet(String ratingFile, String opFolder) throws IOException {
		BufferedReader 	br;
		String         	line;
		Iterator<String>iterator;
		String 			vector = null;
		File			outputFile = null;
		
		int i = 0;
		String currentUserId = "-1"; /* Set current user to -1 for starting */
		String[] values;
		String mvclass = "negative";
		Writer writer = null;
		movieFeature mf;
		
		/* Check if the movie features have been extracted or not */
		if(movieMap.size() < 1) return;
		
		S3Object object = s3.getObject(new GetObjectRequest(bucketName, ratingFile));
		System.out.println("[" + new Timestamp(date.getTime()) + "] Reading user rating file completed.");     
		br = new BufferedReader(new InputStreamReader(object.getObjectContent()));

		/* Retrive the feature names from the movie map to include in the beginning of the final feature set */
		mf = movieMap.get("id"); /* Search with 'id' since it his the value of the id of that row */
		String attribute = "id, movie_id, " + mf.rtAllCriticsRating + ", " + mf.rtAllCriticsNumReviews + ", " + mf.rtAllCriticsNumFresh + ", " + mf.rtAllCriticsNumRotten
					 + ", " + mf.rtAllCriticsScore + ", " + mf.rtTopCriticsRating + ", " + mf.rtTopCriticsNumReviews + ", " + mf.rtTopCriticsNumFresh
					 + ", " + mf.rtTopCriticsNumRotten + ", " + mf.rtTopCriticsScore + ", " + mf.rtAudienceRating + ", " + mf.rtAudienceNumRatings + ", " + mf.rtAudienceScore
					 + ", " + mf.Directors + ", ";
		
		/* Iterate through the set to print the name of the genres in the first row of the final list. */
		iterator = gen.iterator(); 
		while (iterator.hasNext()){
			attribute += iterator.next() + ", ";  
		}
		
		attribute += "SentimentAnalysisScore ,";
		
		/* Add the feature name 'Class' in the end of the first row */
		attribute += "Class";
		
		//int stopCounter = 50;
		/* Read each line in the user rating file to retrieve user's liked and disliked movies */
		while ((line = br.readLine()) != null) {
			values = line.split(",");
			
			/* If the current user is not same as the previous then start a new file */
			if(!currentUserId.equals(values[0])) { 
				if(!currentUserId.equals("-1")) {
					writer.close();
					s3.putObject(new PutObjectRequest(bucketName, opFolder + "/cloudflixuser_"+currentUserId+".csv", outputFile));
					System.out.println("[" + new Timestamp(date.getTime()) + "] Uploading training set for user#"+currentUserId+" completed.");
					//stopCounter--;
					//if(stopCounter < 1) break;
				}
				currentUserId = values[0]; /* Create new file with the user id */
				
				outputFile = File.createTempFile("cloudflixuser_"+currentUserId, ".csv");
				outputFile.deleteOnExit();
				writer = new OutputStreamWriter(new FileOutputStream(outputFile));
				writer.write(attribute);
				writer.write("\n");
				i = 1;
			}
			
			/* Adding Movie feature vector to the final list */
			if(movieMap.containsKey(values[1])){
				mf = movieMap.get(values[1]); /* Retrieving feature vector of the specified movie */
				/* Creating the feature vector */
				vector = i++ + ", " + mf.mId + ", " + mf.rtAllCriticsRating + ", " + mf.rtAllCriticsNumReviews + ", " + mf.rtAllCriticsNumFresh + ", " + mf.rtAllCriticsNumRotten
						 + ", " + mf.rtAllCriticsScore + ", " + mf.rtTopCriticsRating + ", " + mf.rtTopCriticsNumReviews + ", " + mf.rtTopCriticsNumFresh
						 + ", " + mf.rtTopCriticsNumRotten + ", " + mf.rtTopCriticsScore + ", " + mf.rtAudienceRating + ", " + mf.rtAudienceNumRatings + ", " + mf.rtAudienceScore + ", " + mf.Directors;
			}
			
			/* Adding Movie genre in bag of word format in the final list */
			iterator = gen.iterator(); 
			/* Check for genres which belong to the specified movie */
			while (iterator.hasNext()){
				int checkGenre = nd.isGenre(values[1], iterator.next()) ? 1 : 0; /* Set 1 if the movie belong to that genre or set 0 */
				vector += ", "+ checkGenre;  
			}
			
			vector += ", "+ sScore.posPercentage(values[1]); 
			
			/* Adding movie class in the final list */
			float rating = Float.parseFloat(values[2]);
			
			/* If rating is greater than 3 then consider as positive, or else negative */
			if(rating > 3) {
				mvclass = "positive";
			} else {
				mvclass = "negative";
			}
			vector += ", " + mvclass;
			
			writer.write(vector);
			writer.write("\n");
			writer.flush();
		}
	
		writer.close();
		s3.putObject(new PutObjectRequest(bucketName, opFolder + "/cloudflixuser_"+currentUserId+".csv", outputFile));
		
		System.out.println("[" + new Timestamp(date.getTime()) + "] Uploading training set for user#"+currentUserId+" completed.");

		br.close();
		System.out.println("[" + new Timestamp(date.getTime()) + "] Training set compilation completed...");
		return;
	}