- M124D4KX1516 – Kartika Deviani – Politeknik Harapan Bersama
- M232D4KY2952 – Patrick Ulysses – Universitas Katolik Parahyangan
- M232D4KX2774 – Sherrine Tania – Universitas Katolik Parahyangan
The issue of waste in Indonesia has become increasingly complex, with communities generating 17.6 million tons of waste annually, of which only 67.4% is effectively managed. This leaves 32.6% of waste unmanaged due to low awareness of waste management practices, resulting in environmental pollution, health issues, and economic losses. A significant challenge is the identification and proper management of various waste types, worsened by inadequate education on disposal and recycling. Our goal is to address these challenges with an innovative solution: an application that accurately identifies waste types, educates on recycling processes, and promotes sustainable waste management practices nationwide.
Build waste classification models using TensorFlow with DenseNet121 for 10 types of waste, and create a content-based recommendation system using TF-IDF and cosine similarity.
- Google Colab
- TensorFlow
- Matplotlib
- NumPy
- Scikit-learn
- PIL
We use Transfer Learning Model DenseNet121.
Modeling Code
The model achieved 96% validation accuracy and 0.14 validation loss.

We tested the H5 Model using a dataset of 1031 images.
- Google Colab
- Visual Studio Code
- Pandas
- re
- Scikit-learn (TfidfVectorizer and cosine_similarity)
🔍 Content-Based Filtering Recycle Recommendation Model
-
📄 Load Dataset: First, load the dataset (
dataset_recommendation.xlsx) using theload_dataset()function from the pandas library. This function reads the Excel file and stores it in a pandas DataFrame. -
🧹 Preprocessing Data: The
preprocessing_data()function is used to clean and preprocess text data from the dataset by converting text to lowercase, removing numbers, non-alphanumeric characters, underscores, and extra whitespaces. -
🔢 Vectorization with TF-IDF: The
get_recommendation(keyword)function utilizes TF-IDF vectorization to convert text data into numerical vectors:- Combines relevant text columns (
ingredientsandname) into a single string (combined_text) for each entry in the dataset. - Initializes a
TfidfVectorizerobject to apply the preprocessing function and transformcombined_textinto a TF-IDF matrix (recycling_matrix).
- Combines relevant text columns (
-
📏 Calculating Cosine Similarity: Calculates the cosine similarity between the TF-IDF vector of the
keywordinput and the TF-IDF matrix of the dataset usingcosine_similarity(). -
🔝 Generating Recommendations:
- Sorts the cosine similarity scores to find the most relevant recommendations.
- Retrieves the top 3 recommendations (
top_3_recycling) based on highest similarity scores. - Formats recommendations into a list of dictionaries (
recycling_cleaned) with details like name, ingredients, and cosine similarity.
We use the Flask framework to build an API for image classification and recycling recommendation system.
- POST /ID/predict : Submit a request to make a prediction using a machine learning model (Output: Indonesian).
- POST /EN/predict : Submit a request to make a prediction using a machine learning model (Output: English).
- ** 📥 Clone the Repository:**
git clone https://github.com/ReBin-Recyle-Your-Bin/ReBin-MachineLearning-ModelandAPI.git cd ReBin-MachineLearning-ModelandAPI - ⚙️ Set Up Environment:
- Create a virtual environment (optional but recommended):
python -m venv env
- Activate the virtual environment:
- On Windows:
.\env\Scripts\activate
- macOS and Linux:
source env/bin/activate
- On Windows:
- Create a virtual environment (optional but recommended):
- 📦 Install Dependencies:
pip install -r requirements.txt
▶️ Run the Flask Applicationpython main.py






