Travel Documetation/ Teaching
Machine Learning and Data Science through a travel guide
Purpose
Machine learning isn’t just for predicting stock prices or diagnosing diseases—it can also help plan your next vacation! In this project, we created a Travel Destination Recommender using a decision tree model. Based on your preferences (like favorite season, activity type, budget, and continent), the model suggests a unique travel destination tailored to you.
It’s a fun way to see how machine learning can turn personal data into actionable insights—even for something as exciting as vacation planning!
Data Collection
The dataset used here is a custom dataset with 35+ unique travel examples. Each entry includes:
- Season (e.g., summer, winter)
- Activity (e.g., hiking, skiing, museums)
- Budget (low, medium, high)
- Continent (e.g., Asia, Europe)
- Destination (e.g., Bali, Switzerland)
data = {
['summer', 'beach', 'low', 'asia', 'bali'],
['winter', 'skiing', 'high', 'europe', 'switzerland'],
['autumn', 'hiking', 'medium', 'north america', 'colorado'],
['spring', 'museums', 'medium', 'europe', 'paris'],
['summer', 'safari', 'high', 'africa', 'kenya'],
['winter', 'northern lights', 'high', 'europe', 'iceland'],
...
}
Processing
To make the model understand these categories, we first encode each feature into numbers using LabelEncoder. For example:
- “summer” becomes 2
- “skiing” becomes 4
- “europe” becomes 1
We train a Decision Tree Classifier on the encoded dataset. This algorithm creates a tree of decision rules that can match input preferences to the most likely destination.
We also included an activity category mapper that lets users input broader categories like “adventure” or “relaxation”. The system will randomly choose a real-world activity (e.g., hiking, safari) that fits the category and use that for prediction.
Modeling & Training
This part is done in the backend model:
self.model = DecisionTreeClassifier()
self.model.fit(X_encoded, y_encoded)
It uses the season, activity, budget, and continent as inputs, and predicts the final destination.
Here’s how we test it:
sample_input = {
"season": "summer",
"activity": "adventure",
"budget": "medium",
"continent": "africa"
}
prediction = model.predict(sample_input)
print(prediction)
sample output:
{
"destination": "Tanzania",
"activitySuggestion": "Hiking in Tanzania"
}
API Endpoint
We created a simple REST API using Flask. There’s one main endpoint:
POST /api/destination/recommend
Here’s how it works:
# In api/destination.py
class _Recommend(Resource):
def post(self):
data = request.get_json()
model = Destination.get_instance()
recommendation = model.predict(data)
return jsonify(recommendation)
Just send a JSON with your preferences, and get a travel suggestion back.
Frontend Logic (Example)
You can connect your frontend to this API and update the UI dynamically based on the recommendation:
fetch('/api/destination/recommend', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userPreferences)
})
.then(response => response.json())
.then(data => {
const resultDiv = document.getElementById("result");
let imageSrc = "";
let message = `🌍 ${data.activitySuggestion}!`;
// Change image based on destination continent
if (data.destination.includes("Switzerland")) {
imageSrc = "/images/snowy.png";
} else if (data.destination.includes("Bali")) {
imageSrc = "/images/beach.png";
} else {
imageSrc = "/images/default.png";
}
resultDiv.innerHTML = `
<h3>Recommended Destination: ${data.destination}</h3>
<p>${message}</p>
<img src="${imageSrc}" alt="travel image">
`;
});
Next Steps
- Add filters for travel duration or visa-free travel
- Use real-world travel data from tourism APIs (like TripAdvisor, Amadeus, or Skyscanner)
- Include images, sounds, or videos for immersive feedback
- Support multiple suggestions (e.g., top 3 destinations)
Conclusion
This project shows how even a simple machine learning model like a decision tree can personalize travel recommendations. By combining a trained model with a user-friendly interface, you can create an engaging and useful experience.
Whether you’re planning a beach vacation or a hiking adventure, data science can help guide the way!