An AI-based roommate suggestion system that uses machine learning to find compatible roommates based on various factors like lifestyle preferences, habits, and personality traits.
- Matches users based on multiple compatibility factors:
- Cleanliness level
- Noise tolerance
- Sleep schedule
- Smoking preferences
- Pet preferences
- Rent budget
- Personality type
- Hobbies and interests
- Uses cosine similarity for initial matching
- Applies weighted compatibility scoring for fine-tuning matches
- Visualizes compatibility results
- Clone this repository
- Install the required packages:
pip install -r requirements.txtTo see the system in action with sample data:
python roommate_matcher_demo.pyThis will:
- Generate 100 sample user profiles
- Train the roommate matching model
- Find compatible roommates for a test user
- Display the top 5 matches with detailed compatibility information
- Generate a visualization of the top 10 matches
from roommate_model import RoommateMatchingModel
import pandas as pd
# Load your user data
users_data = pd.read_csv('your_users_data.csv')
# Train the model
model = RoommateMatchingModel()
model.fit(users_data)
# Define a user looking for roommates
user = {
'age': 25,
'gender': 'male',
'cleanliness_level': 4,
'noise_tolerance': 3,
'sleep_schedule': 'night_owl',
'smoking': False,
'pets': True,
'rent_budget': 1000,
'personality_type': 'introvert'
}
# Convert to DataFrame
user_df = pd.DataFrame([user])
# Find matches
matches = model.calculate_compatibility(user_df, users_data)
print(matches.head(10)) # Top 10 matchesThe roommate matching system uses two main components:
-
Base Model: Uses scikit-learn's preprocessing pipeline with StandardScaler for numerical features and OneHotEncoder for categorical features, followed by cosine similarity calculation.
-
Weighted Compatibility: A rule-based system that applies domain-specific logic to weigh different factors based on their importance for roommate compatibility.
You can customize the model by:
- Adjusting the feature weights in the
weighted_compatibilityfunction - Adding more features to the user profiles
- Implementing different similarity metrics
- Customizing the preprocessing pipeline
The model expects user data with the following fields:
- age: numeric
- gender: categorical (e.g., 'male', 'female', 'non-binary')
- cleanliness_level: numeric (1-5)
- noise_tolerance: numeric (1-5)
- sleep_schedule: categorical ('early_bird', 'night_owl', 'flexible')
- smoking: boolean
- pets: boolean
- rent_budget: numeric
- personality_type: categorical ('introvert', 'extrovert', 'ambivert')
- hobbies: list of strings
MIT