Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Hybrid Recommendation System for Model Selection #324

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def hybrid_recommendation_system(data, task_type):
# Step 1: Content-based recommendations based on dataset type
content_based_recommendations = recommend_based_on_data_type(data, task_type)

# Step 2: Collaborative filtering - rank based on user feedback
ranked_recommendations = sorted(content_based_recommendations,
key=lambda model: user_feedback.get(model, 0),
reverse=True)

return ranked_recommendations

# Example usage:
# final_recommendations = hybrid_recommendation_system('image', 'classification')
# print(f"Hybrid recommendation for image classification: {final_recommendations}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Simulate a database of user feedback on model recommendations
user_feedback = {
'CNN': 4.5,
'ResNet': 4.0,
'Logistic Regression': 3.5,
'Random Forest': 4.2
}

def get_user_feedback(model):
# Simulate fetching user feedback from a database
return user_feedback.get(model, 'No feedback available')

# Example usage:
for model in models:
feedback = get_user_feedback(model)
print(f"User feedback for {model}: {feedback}")
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pandas as pd

def recommend_based_on_data_type(data, task_type):
# Check the type of dataset
if isinstance(data, pd.DataFrame):
# Tabular data
if task_type == 'classification':
return ['Random Forest', 'Logistic Regression', 'XGBoost']
elif task_type == 'regression':
return ['Linear Regression', 'Random Forest Regressor', 'XGBoost']
elif 'image' in data.lower():
# Image data
return ['CNN', 'ResNet', 'EfficientNet']
elif 'text' in data.lower():
# Text data
if task_type == 'classification':
return ['RNN', 'LSTM', 'BERT']
elif task_type == 'generation':
return ['GPT-3', 'Transformer']
else:
return ['Please provide a supported data type (tabular, image, or text).']

# Example usage:
dataset_type = 'image'
task_type = 'classification'
models = recommend_based_on_data_type(dataset_type, task_type)
print(f"Recommended models for {dataset_type} and {task_type}: {models}")
104 changes: 104 additions & 0 deletions Recommendation Systems/Hybrid-recommendation-system/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Hybrid Recommendation System for Model Selection

Welcome to the **Hybrid Recommendation System** for ML-Nexus! This system helps users choose the most suitable machine learning models based on the type of dataset and task, leveraging content-based and collaborative filtering.

## Key Features

- **Content-Based Filtering:** Recommends machine learning models based on dataset type (e.g., tabular, images, text) and task type (e.g., classification, regression).
- **Collaborative Filtering:** Ranks model recommendations based on user feedback and historical performance, improving suggestions over time.
- **Hybrid System:** Combines both recommendation approaches to provide the most relevant machine learning models for users.
- **User-Friendly Interface (Optional):** An optional Flask-based web interface where users can input their data type and task to get recommendations quickly.

## How It Works

1. **Content-Based Filtering:**
- The system first analyzes the dataset (whether it is image, text, or tabular data) and the task (e.g., classification or regression). Based on this analysis, it recommends a set of appropriate models, such as:
- CNNs for image data
- LSTMs for text data
- Random Forest for tabular data (classification tasks)

2. **Collaborative Filtering:**
- After recommending models based on the dataset and task, the system ranks them by their performance scores and user feedback. This allows users to see models that are highly rated based on past experiences.

3. **Hybrid Recommendation System:**
- The final output is a hybrid recommendation where models are first selected based on content (data type and task), then ranked according to user feedback, creating a personalized and effective recommendation list.

## How This Enhances the User Experience

- **Saves Time:** Instead of manually testing various models, the system suggests the most suitable ones right away.
- **Improves Accuracy:** By learning from user feedback and historical performance, the system continually refines its recommendations to be more accurate.
- **Simplifies Model Selection:** It guides beginners and experts alike in choosing the right models, especially when working on unfamiliar datasets or tasks.
- **Interactive Web Interface:** An optional web interface makes it easy to get recommendations without diving into the code.

## Getting Started

### Prerequisites

- Python 3.7 or higher
- Flask (Optional for the web interface)

### Installation

1. **Clone the repository:**

```bash
git clone https://github.com/your-username/ml-nexus.git
cd ml-nexus
```

2. **Install required dependencies:**

```bash
pip install -r requirements.txt
```

### Running the Recommendation System

You can run the system directly in Python or through the Flask web interface:

#### 1. **Running in Python:**

You can use the `hybrid_recommendation_system()` function to get model recommendations based on your dataset type and task.

```python
from recommender import hybrid_recommendation_system

# Example usage
recommendations = hybrid_recommendation_system('image', 'classification')
print(f"Recommended models: {recommendations}")
```

#### 2. **Running the Flask Web Interface (Optional):**

If you prefer a web interface:

1. Start the Flask server:
```bash
python app.py
```

2. Open your browser and go to:
```
http://localhost:5000
```

From there, you can select your dataset type and task to get model recommendations in an easy-to-use interface.

## How to Contribute

We welcome contributions! If you have ideas to improve this recommendation system, here’s how you can contribute:

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-name`).
3. Make your changes.
4. Commit your changes (`git commit -m 'Add new feature'`).
5. Push to the branch (`git push origin feature-name`).
6. Open a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

Thank you for using the **Hybrid Recommendation System for Model Selection**! If you have any questions, feel free to reach out or open an issue on GitHub.
Loading