> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Types in AI Models

> Overview of AI data types, preprocessing techniques, model selection, and AWS tooling for handling numerical, categorical, text, image, audio, and time series data

Welcome — this is Michael Forrester. In this lesson we cover a foundational topic for AI practitioners: the data types used in AI models and how those types determine preprocessing, feature extraction, and model selection.

These concepts can be technical. If you’re unfamiliar with math or data science basics, take notes and review the examples. Key distinctions—such as structured vs. unstructured data and labeled vs. unlabeled data—are important for practical projects and for certification exams.

A "data type" here refers to the representation and structure of input data fed to AI systems. Common categories include numerical, categorical, text, image, audio, and time-series data. Each requires different preprocessing and modeling strategies; handling them correctly is crucial for accurate results and reliable production systems.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/data-types-ai-models-intro-icons.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=c98d1265b5a64f003b7cd8ec5b698885" alt="A dark-blue presentation slide titled &#x22;Data Types in AI Models – Introduction&#x22; showing four colorful icons and labels on the left for Numerical, Categorical, Text, and Images. The rest of the slide is mostly empty space." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/data-types-ai-models-intro-icons.jpg" />
</Frame>

Callouts: data preprocessing matters

<Callout icon="lightbulb" color="#1CB2FE">
  Preprocessing choices directly influence how models learn. Use the right scaling, encoding, and augmentation strategies for each data type — and validate changes with cross-validation and holdout sets.
</Callout>

Practical note on AWS tooling
AWS provides services that streamline preprocessing and data management at scale:

* AWS Glue and Amazon EMR for large-scale ETL and data processing.
* Amazon SageMaker (Data Wrangler, Processing Jobs, Ground Truth) for data preparation, labeling, and model training.
* Domain-specific services like Amazon Rekognition (vision), Amazon Transcribe (speech-to-text), and Amazon Comprehend (NLP).

Numerical data
Numerical data are quantitative measurements (integers, floats) used in regression, forecasting, and many ML algorithms. They can also encode binary conditions (0/1 flags).

Common preprocessing steps:

* Scaling: standardization (zero mean, unit variance) or min-max normalization.
* Outlier handling: clipping or transformations (log, Box–Cox).
* Imputation: fill missing numbers with mean/median or model-based predictions.

Example: scale and impute with scikit-learn

```python theme={null}
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline

pipeline = Pipeline([
    ('imputer', SimpleImputer(strategy='median')),
    ('scaler', StandardScaler())
])
X_transformed = pipeline.fit_transform(X_numeric)
```

Numerical datasets commonly live in Amazon S3, Redshift, or managed databases and are integrated into SageMaker training workflows for forecasting or sensor analytics.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/numerical-data-ai-financial-sensor-slide.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=b48cc527070f0ed9383395d47fbaa6fe" alt="A dark-themed slide titled &#x22;Numerical Data&#x22; showing a small table of time, price and sensor temperature values on the left, an AI model brain icon in the center, and icons labeled &#x22;Financial forecasting&#x22; and &#x22;Sensor data analysis&#x22; on the right." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/numerical-data-ai-financial-sensor-slide.jpg" />
</Frame>

Categorical data
Categorical variables group observations into discrete buckets (e.g., product type, region, status). Most ML algorithms expect numeric inputs, so categorical data must be encoded.

Common encoding techniques:

* One-hot encoding: binary indicator columns for each category (suitable for nominal features).
* Label encoding: integer mapping (useful for ordinal features or some tree-based models).
* Target encoding or embeddings: handle high-cardinality categories or capture target-related information.

Example: one-hot encoding with pandas

```python theme={null}
import pandas as pd
X_onehot = pd.get_dummies(df[['product_type','region']], drop_first=False)
```

SageMaker Data Wrangler and preprocessing utilities simplify encoding pipelines and integration into model training.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/one-hot-encoding-categorical-data-diagram.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=3296f8f35f2b05c5e3f585497f802cda" alt="A diagram titled &#x22;Categorical Data&#x22; showing a table of product types (A, B) and regions (North, South) being transformed via a central &#x22;One-Hot Encoding&#x22; box into binary columns A, B, North, and South. Arrows illustrate the input-to-output encoding process." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/one-hot-encoding-categorical-data-diagram.jpg" />
</Frame>

Text data and natural language processing (NLP)
Text is unstructured and requires tokenization and transformation into numeric representations before modeling. Typical steps include tokenization, normalization, stop-word removal, stemming/lemmatization, and vectorization.

Common representations:

* Bag-of-words / TF-IDF for simple classification tasks.
* Word embeddings (Word2Vec, GloVe) for semantic information.
* Subword tokenizers and transformer token IDs for modern language models.

NLP workflow checklist:

* Tokenize and manage vocabulary.
* Clean or normalize text (lowercase, punctuation handling).
* Convert tokens to embeddings or indices.
* Apply modeling: classification, entity extraction, summarization, etc.

Example: TF-IDF with scikit-learn

```python theme={null}
from sklearn.feature_extraction.text import TfidfVectorizer
tfidf = TfidfVectorizer(max_features=10000, ngram_range=(1,2))
X_text = tfidf.fit_transform(corpus)
```

AWS tools: Amazon Comprehend for managed NLU tasks; SageMaker for custom NLP training and deployment.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/nlp-pipeline-preprocessing-tokenization-sentiment-classification.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=987d9a940252eba530b7d4e26b7d3f86" alt="A dark-themed diagram of an NLP pipeline: raw text data is preprocessed (tokenization, stop-word removal), fed into an NLP model, and yields outputs like sentiment analysis and text classification." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/nlp-pipeline-preprocessing-tokenization-sentiment-classification.jpg" />
</Frame>

Image data
Images are unstructured arrays of pixels. Preprocessing includes decoding, resizing, normalization, and augmentation to improve model robustness. Convolutional neural networks (CNNs) and transfer learning are widely used for vision tasks.

Typical image pipeline:

* Load and decode images.
* Resize and normalize pixel values (e.g., scale to \[0, 1] or standardize).
* Apply augmentation (rotation, flips, color jitter).
* Use CNNs or pretrained backbones for feature extraction and classification.

Example: simple torchvision transforms

```python theme={null}
from torchvision import transforms
transform = transforms.Compose([
    transforms.Resize((224,224)),
    transforms.RandomHorizontalFlip(),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485,0.456,0.406], std=[0.229,0.224,0.225])
])
```

AWS Rekognition supports common image and video analysis; SageMaker enables custom vision model training and deployment.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/image-classification-preprocessing-model-labels.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=4733ae8aea1e0908975f209f26849cbd" alt="A schematic pipeline showing an image classification workflow: a raw image goes through preprocessing steps (resizing, normalization, augmentation), is fed into an AI model, and outputs labels like “Cat” or “Dog.”" width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/image-classification-preprocessing-model-labels.jpg" />
</Frame>

Audio data and speech
Audio is time-series-style data and typically requires feature extraction (MFCCs, spectrograms) before modeling. Preprocessing often involves denoising, resampling, and normalization.

Common approaches:

* Extract spectrograms or MFCC features for classification.
* Use waveform-based neural networks or transformer-based audio models for end-to-end tasks.
* For speech-to-text, use services like Amazon Transcribe or build custom ASR models.

Example: compute a Mel spectrogram (high-level)

```python theme={null}
import librosa
y, sr = librosa.load('audio.wav', sr=16000)
mel_spec = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=64)
```

Challenges: background noise, accents, and variable volume — apply noise reduction and normalization before training.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/audio-mfcc-amazon-transcribe-hello.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=d522fd7eb1e2232b2e7dd5b1d53dd452" alt="A simple flow diagram showing audio data fed into Amazon Transcribe (with Mel-Frequency Cepstral Coefficients) that outputs the text &#x22;Hello Everyone!&#x22;." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/audio-mfcc-amazon-transcribe-hello.jpg" />
</Frame>

Structured vs. unstructured data
The structured vs. unstructured distinction guides algorithm choice and preprocessing complexity:

* Structured: tabular data with fixed schema (rows/columns). Easier to clean, encode, and feed into tree-based models or linear models.
* Unstructured: free-form text, images, audio, or video. Requires feature extraction, embeddings, or deep learning models.

Choosing algorithms:

* Structured: decision trees, gradient-boosted trees, and linear models.
* Unstructured: neural networks (CNNs for vision, transformers for language, and hybrid models for multimodal tasks).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/structured-vs-unstructured-data-ai-brain.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=bc3ef5a497b52a9bbe2cbfcb88119914" alt="An infographic titled &#x22;Structured vs Unstructured Data&#x22; showing a neat grid of document and square icons labeled Structured Data on the left and a jumbled cluster of document shapes labeled Unstructured Data on the right. A stylized AI brain icon sits centered between the two." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/structured-vs-unstructured-data-ai-brain.jpg" />
</Frame>

Data quality and preprocessing best practices
High-quality inputs are essential for high-quality models. Core preprocessing tasks include:

* Cleaning: remove duplicates and correct obvious errors.
* Encoding: convert categories to numeric representations.
* Scaling: normalize numeric ranges.
* Imputation: handle missing values robustly.
* Balancing and augmentation: address class imbalance or increase dataset diversity.

Practical checklist:

* Visualize distributions and correlations.
* Log-transform skewed variables when appropriate.
* Use cross-validation to measure preprocessing effects.
* Track preprocessing steps in reproducible pipelines (SageMaker Processing Jobs, Data Wrangler).

Labeled vs. unlabeled data

* Labeled data: inputs paired with target labels (used for supervised learning — classification, regression).
* Unlabeled data: no explicit targets; used in unsupervised learning (clustering, anomaly detection) or self-supervised methods.

<Callout icon="lightbulb" color="#1CB2FE">
  Exam tip: Labeled vs. unlabeled is often tested. Labeled data ⇒ supervised learning. Unlabeled data ⇒ unsupervised or self-supervised approaches (clustering, anomaly detection, representation learning).
</Callout>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/labeled-vs-unlabeled-data.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=e7c333d5804b10174f0ca6e2627e19b8" alt="A comparison diagram titled &#x22;Labeled vs Unlabeled Data&#x22; showing a left panel with cat and dog icons labeled as &#x22;Labeled Data&#x22; for supervised learning, and a right panel with the same icons unlabeled as &#x22;Unlabeled Data&#x22; for unsupervised learning." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/labeled-vs-unlabeled-data.jpg" />
</Frame>

Time-series data
Time-series data are sequences indexed by time; order matters. Forecasting and sequential prediction use historical patterns (trend, seasonality, cyclic behavior).

Common methods:

* Statistical: ARIMA, exponential smoothing.
* ML/DL: LSTM, GRU, temporal CNNs, transformer-based time-series models.
* Tools: Facebook Prophet for trend/seasonality, or SageMaker for custom deep learning models.

Key considerations:

* Capture seasonality and trend components.
* Handle temporal cross-validation (e.g., rolling-window validation).
* Beware of data leakage (do not use future information in training features).

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/time-series-line-chart-upward-spike.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=f40fbe0d412cd0d173722fc99a3dacc5" alt="A dark-blue slide titled &#x22;Time-Series Data&#x22; showing a grid chart with two colored line graphs (red/orange) and markers. The lines fluctuate with peaks and dips and trend upward to a final spike on the right." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/time-series-line-chart-upward-spike.jpg" />
</Frame>

Imbalanced data
Imbalance occurs when classes are unequally represented, biasing models toward the majority class. Select appropriate techniques and metrics.

Strategies:

* Oversample the minority class (simple duplication, SMOTE).
* Undersample the majority class.
* Use class weighting or focal loss to penalize minority errors more.
* Evaluate with precision/recall, F1-score, ROC-AUC, and PR-AUC rather than accuracy alone.

Example: class weighting in scikit-learn

```python theme={null}
from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(class_weight='balanced')
```

Frameworks like SageMaker support sampling, weighting, and distributed preprocessing to handle imbalance at scale.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/imbalanced-data-majority-class-bias.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=9cad97f5f67c170d11cd224472ac1c54" alt="A slide titled &#x22;Imbalanced Data.&#x22; It explains that imbalanced data occurs when one class has many more examples than others, which can lead to models that favor the dominant class." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/imbalanced-data-majority-class-bias.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/imbalanced-data-oversampling-undersampling-roc-auc.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=9a01b6659df66e9773ce6a2664a1af83" alt="A slide titled &#x22;Handling Imbalanced Data&#x22; showing a pie chart with a small highlighted slice and three colored icons labeled &#x22;Oversampling,&#x22; &#x22;Undersampling,&#x22; and &#x22;ROC–AUC.&#x22;" width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/imbalanced-data-oversampling-undersampling-roc-auc.jpg" />
</Frame>

Big data and scalable AI
Large, varied datasets improve model generalization but require scalable storage and processing:

* Storage: Amazon S3.
* Processing: AWS EMR, AWS Glue.
* Labeling at scale: SageMaker Ground Truth.
* Training: distributed training with SageMaker and multi-instance jobs.

Design pipelines that are reproducible, monitor dataset drift, and use sample-based experiments before full-scale training.

Missing data and imputation
Missing values can bias models. Choose an imputation strategy that matches the data generation process:

* Simple: mean/median/mode.
* Model-based: use a predictive model to fill missing values.
* Indicator flags: add a column indicating missingness (sometimes informative).

Always validate the impact of imputation with experiments and sensitivity analysis.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/imputing-missing-data-ai-infographic.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=24678a18dd9d73acd0c3ba0be0cd67a5" alt="An infographic titled &#x22;Handling Missing Data in AI Models&#x22; showing an upper table with missing age and salary entries for four people and a lower table where those missing values have been filled (e.g., ages for Bob/Diana set to 27.5 and some salaries set to 60,000). It illustrates imputing missing dataset values." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/imputing-missing-data-ai-infographic.jpg" />
</Frame>

Summary: match data type to model and preprocessing
Understanding data types drives your preprocessing pipeline and model choice:

* Structured/tabular data: decision trees, gradient-boosted trees, linear models (after encoding categoricals and scaling numericals).
* Images: convolutional neural networks and transfer learning.
* Text: transformer-based models or embeddings + downstream classifiers.
* Time-series: ARIMA, LSTM, temporal transformers, and specialized forecasting tools.
* Audio: spectrogram/MFCC extraction + CNN/RNN/transformer models.

Supervised models need labeled data; unsupervised approaches work on unlabeled data. Hybrid approaches (self-supervised, semi-supervised) are increasingly common.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/a-h7Me1-coNmnYfv/images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/ai-data-types-decision-cnn-rnn.jpg?fit=max&auto=format&n=a-h7Me1-coNmnYfv&q=85&s=3a61e5d326a56029af0f0a610dbf1936" alt="A presentation slide titled &#x22;Final Thoughts – Choosing the Right Data Type for AI Models&#x22; with three numbered cards. The cards recommend Decision Trees for structured/tabular data, CNNs for unstructured data (e.g., text/images), and RNNs for time-series data." width="1920" height="1080" data-path="images/AWS-Certified-AI-Practitioner/Fundamentals-of-AI-and-ML/Data-Types-in-AI-Models/ai-data-types-decision-cnn-rnn.jpg" />
</Frame>

Wrap-up
We covered:

* Numerical, categorical, text, image, audio, and time-series data.
* Structured vs. unstructured and labeled vs. unlabeled data.
* Key preprocessing steps: cleaning, encoding, scaling, imputation, augmentation.
* Handling imbalance, missing values, and big data at scale.
* How data type influences algorithm selection and real-world tooling.

For deeper learning, practice building pipelines for each data type, experiment with AWS tooling (SageMaker, Glue, EMR, Rekognition, Transcribe, Comprehend), and focus on supervised vs. unsupervised workflows.

Links and references

* Amazon SageMaker: [https://aws.amazon.com/sagemaker/](https://aws.amazon.com/sagemaker/)
* AWS Glue: [https://aws.amazon.com/glue/](https://aws.amazon.com/glue/)
* Amazon EMR: [https://aws.amazon.com/emr/](https://aws.amazon.com/emr/)
* Amazon Rekognition: [https://aws.amazon.com/rekognition/](https://aws.amazon.com/rekognition/)
* Amazon Transcribe: [https://aws.amazon.com/transcribe/](https://aws.amazon.com/transcribe/)
* Amazon Comprehend: [https://aws.amazon.com/comprehend/](https://aws.amazon.com/comprehend/)

Table — Quick reference: data types, preprocessing, and AWS tools

| Data type | Typical preprocessing | Common models | AWS services |
| - | - | - | - |
| Numerical | Scaling, imputation, outlier handling | Linear models, GBDT, neural nets | S3, SageMaker |
| Categorical | One-hot, label encode, embeddings | Trees, neural nets | SageMaker Data Wrangler |
| Text | Tokenization, TF-IDF/embeddings, cleaning | Transformers, RNNs, classifiers | Amazon Comprehend, SageMaker |
| Image | Resize, normalize, augment | CNNs, transfer learning | Amazon Rekognition, SageMaker |
| Audio | MFCC/spectrogram, denoise | CNN/RNN/transformers | Amazon Transcribe, SageMaker |
| Time-series | Resampling, detrend, windowing | ARIMA, LSTM, transformers | SageMaker, Prophet (external) |

Good luck — focus on practicing each pipeline end-to-end and validating preprocessing decisions with experiments.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/aws-certified-ai-practitioner/module/e79d4d90-43ff-4f6a-a5c0-fe2e960cb76d/lesson/b6321ca6-5cf9-488b-81e5-892a8f2e1f49" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.