Skip to content

educapel/docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I developed a comprehensive web-based loan default prediction system using a variety of modern technologies and methodologies. My goal was to create an application that could accurately predict whether a loan would default based on various input features. The system comprises several key components, each playing a vital role in its functionality.

Backend Development with FastAPI

  1. FastAPI Framework: I chose FastAPI for the backend development due to its high performance and ease of use. It allowed me to create robust API endpoints efficiently.
  2. Data Model with Pydantic: I used the Pydantic library to define a LoanPredictionInput class, ensuring that the input data for the prediction model was structured and type-safe.
  3. Predictive Model Integration: The core of the backend is a machine learning model, which I integrated into the FastAPI application. This model is invoked when the /predict_loan_default endpoint is hit.

Frontend Interface

  1. HTML and JavaScript: For the frontend, I crafted an HTML page complemented by JavaScript. This interface provides users with a form to input the required data for the loan default prediction.
  2. CSS for Styling: I ensured the form was not only functional but also user-friendly and visually appealing using CSS. Particular attention was paid to making the design responsive for different device screens.

Deployment with Docker

Containerization: To simplify deployment and ensure consistency, I containerized the application with Docker. Dockerfile Creation: Base Image: I started with python:3.8 base image Environment Setup: The Dockerfile detailed the environment setup, including system dependencies and a non-root user for enhanced security. Dependencies Installation: Using the COPY and pip install commands, I ensured all Python dependencies were installed. Application Code: The application code, including FastAPI files, frontend assets, and the ML model, were copied into the container. Port and Command: I defined the application's port with EXPOSE and used CMD to set the command for starting the FastAPI server.

Additional Project Components

  1. Requirements File: I maintained a requirements.txt file to keep track of all Python dependencies, ensuring reproducibility and ease of setup in different environments.
  2. Model and Data Management: The machine learning model, stored as default.pkl, was a pivotal component. It was trained on historical loan data to make accurate predictions.

Project Workflow

• Data Handling: When a user submits the form on the frontend, the data is sent to the FastAPI backend, where it's processed and fed into the machine learning model. • Response and Interaction: The model predicts whether a loan is likely to default, and this prediction is sent back to the user interface, displaying the result to the user.

Testing and Deployment

• Testing the Docker Container: Before deploying, I rigorously tested the Docker container to ensure everything functioned correctly. • Deployment to Production: Once satisfied with the testing, I deployed the Docker container to a production server, making the application live and accessible.

Creating a Repository on Docker Hub

Account Registration: I signed up for Docker Hub and logged into my account. Repository Creation: Navigating to the repositories tab, I created a new repository for the application. Docker Image Creation: I built a Docker image from the Dockerfile and prepared it for pushing to the repository.

Pushing Docker Image to Docker Hub

Image Upload: The Docker image was successfully pushed to Docker Hub, making it available for widespread use.

GitHub Actions for Continuous Integration and Continuous Deployment (CI/CD)

To enhance the development process, I implemented GitHub Actions:

Automated Testing: The workflow automatically runs tests on every push and pull request, ensuring code quality and functionality. Linting: Code is linted with flake8 for style and error checks. Python Environment Setup: The workflow sets up the specified Python environment for consistent testing. Dependency Management: All project dependencies are installed as part of the workflow. Pytest Integration: The workflow includes pytest to run all unit tests, verifying the application's stability with each change.

Conclusion

This project exemplified my capabilities in integrating various technologies - machine learning, backend and frontend development, Docker containerization, and CI/CD practices with GitHub Actions. The result was a functional, reliable, and user-friendly loan default prediction system that stands as a testament to the potential of full-stack AI solutions in the financial sector

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published