Clean Data by RFE Node for n8n
The Clean Data by RFE node for n8n allows you to clean your dataset by applying Recursive Feature Elimination (RFE) to select the most important features for predictive modeling. This node helps you reduce the number of features in your dataset, improving model performance and interpretability.
Description
The Clean Data by RFE node uses Recursive Feature Elimination (RFE) to automatically select the most relevant features in your dataset based on their importance in predicting a target column. After applying RFE, the node outputs the cleaned dataset with only the selected features.
Key Features:
- Feature Selection: Reduces the number of features by selecting the most relevant ones using RFE.
- Customizable Output: Choose between JSON or table format for the output.
- Data Cleaning: Automatically handles missing values by replacing them with the column mean.
Installation
To install this custom node, follow the steps below:
- Fork or clone this repository.
- Follow the official n8n custom node installation guide.
- Add the node to your n8n workflow.
Configuration
Node Settings
Once the Clean Data by RFE node is added to your workflow, you can configure the following parameters:
Target Column (string):
- Default:
target
- Description: The name of the target column for RFE (the column you are predicting).
- Default:
Number of Features to Keep (number):
- Default:
5
- Description: The number of features to keep after applying RFE. Features are ranked by importance, and the specified number of features are retained.
- Default:
Output Format (options):
- JSON: The output will be in JSON format, containing the selected features and the cleaned dataset.
- Table: Placeholder for future functionality (currently outputs JSON).
- Default:
json
- Description: Choose the output format for the result.
Example Workflow
Here’s an example configuration for cleaning data and selecting the top 5 features:
Input Data
{
"data": [
{"feature1": 1, "feature2": 2, "feature3": 3, "target": 0},
{"feature1": 4, "feature2": 5, "feature3": 6, "target": 1},
{"feature1": 7, "feature2": 8, "feature3": 9, "target": 1}
]
}
Node Configuration:
- Target Column: target
- Number of Features to Keep: 2
- Output Format: JSON
Output
Once the node has completed, it will return the following data:
{
"selected_features": ["feature1", "feature3"],
"output_file": "cleaned_data.csv"
}
- selected_features: A list of the selected features based on RFE.
- output_file: Path to the cleaned data file (
cleaned_data.csv
).
Benefits
- Feature Selection: Automatically select the most important features for your model, improving performance.
- Data Cleaning: Handles missing values and ensures your dataset is ready for analysis.
- Flexibility: Customize the number of features to retain and the format of the output.