Detailed Answers: Data Preprocessing
Q&A
1. What is Boolean mapping? Explain how it is used in preprocessing
binary attributes.
Boolean mapping is a technique where binary attributes (like Yes/No, True/False) are
converted into numerical values (usually 1 and 0).
How it's used:
- In preprocessing, most machine learning models require numerical inputs.
- Example: Convert "Yes" to 1 and "No" to 0.
Applications:
- Useful in classification models, such as predicting whether a customer will churn.
- Ensures compatibility with mathematical algorithms that do not handle strings.
2. What is stopword removal in NLP? Why is it important?
Stopword removal is the process of eliminating common, insignificant words from text data.
Examples of stopwords: "the", "is", "and", "in", "an"
Importance:
- Reduces noise in text data.
- Helps focus on meaningful words.
- Speeds up processing and improves model accuracy.
Applications:
- Sentiment analysis, chatbot development, document classification.
3. What are geospatial features? Mention any two examples.
Geospatial features are data points that have a location component (latitude, longitude)
attached.
Examples:
1. GPS coordinates of a delivery truck.
2. Location of hospitals on a city map.
Applications:
- Navigation, ride-sharing apps, urban planning.
4. Identify how you would remove redundancy in a given relational
schema with an example.
To remove redundancy, normalization is used.
Steps:
1. Identify repeating groups or redundant attributes.
2. Break the table into smaller related tables.
Example:
Unnormalized Table:
| StudentID | Name | Course1 | Course2 |
Normalized:
- Students Table: (StudentID, Name)
- Courses Table: (StudentID, Course)
Benefits:
- Reduces data duplication.
- Increases integrity and consistency.
5. What are the key steps in image preprocessing? Explain resizing,
grayscale conversion, and normalization.
Key Steps in Image Preprocessing:
1. Resizing: Standardizes image size. For example, resize all images to 224x224 for CNN
input.
2. Grayscale Conversion: Converts RGB image to grayscale to reduce complexity (especially
if color isn't important).
3. Normalization: Scales pixel values (e.g., from 0–255 to 0–1) to speed up learning and
reduce variation.
Applications:
- Face detection, OCR, medical image classification.
6. Given a raw sentence, apply tokenization, lowercasing, and stemming.
Raw Sentence: "The players are running faster than before!"
Steps:
1. Lowercasing: "the players are running faster than before!"
2. Tokenization: ["the", "players", "are", "running", "faster", "than", "before", "!"]
3. Stemming: ["the", "player", "are", "run", "faster", "than", "befor", "!"]
Applications:
- Sentiment analysis, chatbot training, text classification.
7. Take a color image and describe step-by-step how you would
preprocess it for a classification model (resize, normalize, augment).
Steps for preprocessing:
1. Resize: Resize image to a fixed size (e.g., 224x224 pixels).
2. Normalize: Convert pixel values to range [0, 1] or [-1, 1].
3. Augmentation:
- Flip horizontally/vertically.
- Rotate image slightly.
- Zoom in/out.
- Add slight noise.
Applications:
- Improves model robustness in tasks like object detection, animal classification.
8. Combine numerical and textual data from separate sources into one
dataset for analysis.
Steps:
1. Load both datasets (e.g., a CSV of user profiles and another of reviews).
2. Preprocess separately:
- Numerical: Handle missing values, scale data.
- Textual: Remove stopwords, tokenize, vectorize.
3. Merge: Join both datasets using a common key (like User ID).
4. Final dataset can now be used for tasks like churn prediction or recommendation
systems.
Applications:
- Customer profiling, fraud detection, sentiment-based predictions.
9. Describe the structure and components of graph data. Why is graph
preprocessing crucial?
Graph Data Structure:
- Nodes (vertices): Represent entities.
- Edges (links): Represent relationships between entities.
Components:
- Node attributes: E.g., user profile info.
- Edge attributes: E.g., relationship type or weight.
Why Graph Preprocessing is Crucial:
1. Removes noisy or irrelevant links.
2. Adds missing edges or corrects structure.
3. Converts graph to adjacency matrix or edge list.
Applications:
- Social network analysis, recommendation systems, biological networks.
10. Convert the column 'Employed' with values {Yes, No} to numerical
using Boolean mapping.
Step:
1. Use Boolean Mapping: Map "Yes" to 1 and "No" to 0.
2. Example:
| Person | Employed |
|--------|----------|
| John | Yes → 1
| Alice | No →0
Applications:
- Useful in logistic regression, decision trees, and other ML algorithms that need numerical
inputs.