Set-Up Cloud Environment and Model Training:
1.Set Up AWS Account:
- Sign in to your AWS account or create a new one.
- Ensure you have the necessary permissions to launch EC2 instances and work with S3 buckets if needed for data storage.
2.Launch EC2 Instances for Training:
- Navigate to the EC2 dashboard and launch four instances.
- Choose an Ubuntu Server image.
- Select instance types suitable for parallel processing.
- Configure instance details to launch all instances within the same VPC and, preferably, in the same Availability Zone to minimize network latency.
- Add necessary storage and tags as required.
- Configure the security group to allow traffic on required ports, particularly for Spark communication and SSH.
- Review and launch instances, making sure to select or create a new key pair for SSH access.
3.Set Up Apache Spark:
- SSH into each EC2 instance using the key pair.
- Install Java, as it's required for Spark.
- Download and install Apache Spark on all instances.
- Configure one instance to act as the master and the others as workers.
- Start the Spark cluster by running the start-master.sh script on the master node and start-slave.sh on each worker node, pointing to the master.
4.Data Preparation:
- Upload the TrainingDataset.csv, ValidationDataset.csv, Dockerfile and training.py to a location accessible by all EC2 instances, such as an S3 bucket or distributed file system supported by Spark.
5.Model Training:
- Write a Spark application in Java for training your ML model using MLlib.
- Utilize the Spark context to distribute the job across the cluster.
- Train the model with TrainingDataset.csv and validate with ValidationDataset.csv to optimize the model's parameters.
- Save the trained model to a persistent storage location.
Application Prediction:
1.Single EC2 Instance for Prediction:
- Launch a separate EC2 instance using the same previous steps but only a single instance is needed.
- Deploy the Spark application for prediction on this instance.
- Ensure your model and the TestDataset.csv (or ValidationDataset.csv for testing purposes) are accessible by this instance.
2.Prediction Without Docker:
- Run the Spark application directly on the instance, making sure Spark submits the job with the trained model and test dataset.
- The application should output the prediction performance, specifically the F1 score.
3.Prediction With Docker:
- Install Docker on the EC2 instance if not already present.
- Create a Dockerfile for your prediction application.
- Build the Docker image and push it to Docker Hub.
- Pull the Docker image from Docker Hub onto your EC2 instance.
- Run the Docker container with necessary volume mounts to access the model and test data.
- The Docker container should run the Spark application and output the F1 score.
4.Github Account:
- Create or Login to the github account.
- Now create the new repository in github account.
- And push all the codes to the github accout.