0% found this document useful (0 votes)
5 views9 pages

attributes

The document provides an overview of attributes and data types in data analysis, detailing qualitative and quantitative attributes, as well as various data types such as numerical, categorical, text, boolean, structured, unstructured, and semi-structured data. It also explains the Naive Bayes classifier in R, including its implementation steps and advantages and limitations. Lastly, it contrasts Machine Learning and Deep Learning, highlighting their differences, types, applications, and requirements.

Uploaded by

saradatvlcsconf
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

attributes

The document provides an overview of attributes and data types in data analysis, detailing qualitative and quantitative attributes, as well as various data types such as numerical, categorical, text, boolean, structured, unstructured, and semi-structured data. It also explains the Naive Bayes classifier in R, including its implementation steps and advantages and limitations. Lastly, it contrasts Machine Learning and Deep Learning, highlighting their differences, types, applications, and requirements.

Uploaded by

saradatvlcsconf
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

ATTRIBUTES AND DATA TYPES


Attributes
• Attributes are qualities or characteristics that describe an object, individual, or
phenomenon. Attributes can be categorical, representing distinct categories or classes,
such as color, types, or labels. Some attributes are quantitative, taking on numerical
values that can be measured or counted, such as height, weight or temperature.
• Categorical attributes can be further classified as nominal (no inherent order) or ordinal
(possessing a meaningful order). In data analysis, attributes serve as the variables of
interest, and understanding their nature is crucial for selecting appropriate statistical
methods and drawing meaningful conclusions from the data.

Types of Attributes
Qualitative Attributes
These attributes represent categories and do not have a meaningful numeric
interpretation. Examples include gender, color, or product type.
The types of Qualitative attributes are nominal, ordinal or binary attributes.
Nominal Attributes
• Nominal means "relating to names" . The utilities of a nominal attribute are sign or
title of objects . Each value represents some kind of category, code or state, and so
nominal attributes are also referred to as categorical.
• Example : Suppose that skin color and education status are two attributes of
expressing person objects. In our implementation, possible values for skin color are
dark, white, brown. The attributes for education status can contain the values-
undergraduate, postgraduate, matriculate.
Binary Attributes
• A binary attribute is a category of nominal attributes that contains only two classes: 0
or 1, where 0 often tells that the attribute is not present, and 1 tells that it is existing.
Binary attributes are mentioned as Boolean if the two conditions agree to true and
false.
• Example - Given the attribute drinker narrate a patient item, 1 specify that the drinker
drinks, while 0 specify that the patient does not. Similarly, suppose the patient
undergoes a medical test that has two practicable outcomes.
Ordinal Attributes
• Ordinal data is a type of categorical data that possesses a meaningful order or ranking
among its categories, yet the intervals between consecutive values are not consistently
measurable or well-defined.
• Example -In the context of sports, an ordinal data example would be medal rankings
in a competition, such as gold, silver, and bronze.
Quantitative Attributes
A numeric attribute is calculable, that is, it is a quantifiable amount that constitutes
integer or real values. Numeric attributes can be of two types as follows: Interval- scaled, and
Ratio - scaled.
Interval - Scaled Attributes
• Interval - scaled attributes are calculated on a lamella of uniform- size units. The
values of interval-scaled attributes have order and can be positive, 0, or negative.
Thus, in addition to providing a ranking of values, such attributes allow us to compare
and quantify the difference between values.
• Example - A temperature attribute is an interval - scaled. We have different
temperature values for every new day, where each day is an entity. By sequencing the
values, we obtain an arrangement of entities with reference to temperature. In
addition, we can quantify the difference in the value between values, for example, a
temperature of 20 degrees C is five degrees higher than a temperature of 15 degrees
C.
Ratio - Scaled Attributes :
• A ratio - scaled attribute is a category of a numeric attribute with imminent or fix zero
points. In inclusion, the entities are structured, and we can also compute the difference
between values, as well as the mean, median, and mode.
• Example - The Kelvin (K) temperature scale has what is contemplated as a true zero
point. It is the point at which the tiny bits that consist of matter has zero kinetic
energy.

Data Types
Numerical Data
Numerical data represents measurable quantities and is further divided into:
• Integer (int)
Whole numbers without fractions. It Used in counting, indexing, IDs, and discrete
values. Examples: 0, 1, -10, 205
Use cases:
▪ Counting occurrences (frequency counts)
▪ Loop iterations and indexing in data structures
▪ Discrete variables in machine learning (like number of purchases)
• Float (float)
Numbers with decimal points. It Can represent continuous values. Examples: 3.14,
-0.001, 2.71828
Use cases:
▪ Statistical analysis (mean, variance, standard deviation)
▪ Continuous features in regression models
▪ Sensor readings, stock prices, probabilities
• Complex Numbers
Numbers with real and imaginary parts. Examples: 2 + 3j, -1 + 0.5j
Use cases:
▪ Fourier transforms
▪ Scientific computations in engineering datasets
Categorical (Qualitative) Data
Categorical data represents labels, groups, or types. It cannot be directly used in
mathematical operations without encoding.
• Nominal Data
Categories without any natural order. Examples: Colors: Red, Green, Blue,Fruit types:
Apple, Banana, Orange and Country names: USA, India, Brazil.
Use cases:
▪ One-hot encoding for machine learning models
▪ Counting frequencies, pie charts
• Ordinal Data
Categories with a meaningful order but unequal intervals. Examples: Education level:
High School < Bachelor < Master < PhD,Ratings: Poor < Average < Good < Excellent and
Customer satisfaction: 1-5 stars.
Use cases:
▪ Label encoding for ML models
▪ Ranking analysis and correlation studies
Text (String) Data
Strings represent textual data or sequences of characters.
Examples:
"New York", "Data Science", "ID_12345"
Use cases:
▪ Natural Language Processing (NLP) tasks: sentiment analysis, text classification
▪ Cleaning and preprocessing data: removing punctuation, lowercasing, tokenization
▪ Feature extraction: word counts, TF-IDF
Boolean (Logical) Data
Boolean data has two possible values: True or False.
Examples:
True, False, 1 (True), 0 (False)
Use cases:
▪ Filtering datasets (e.g., df[df['Age'] > 18])
▪ Binary classification problems
▪ Logical operations in conditional statements
Structured Data
Data with rows and columns, typically stored in databases or spreadsheets.
Examples:
▪ SQL tables, Excel spreadsheets, CSV files
▪ Columns: Name, Age, Salary
Use cases:
▪ Tabular data analysis with Pandas or SQL
▪ Machine learning with structured features
▪ Aggregation, pivot tables, and group-by operations
Unstructured Data
Data without a predefined schema, often large and heterogeneous.
Examples:
▪ Text documents, PDFs, emails
▪ Images, videos, audio files
▪ Social media posts
Use cases:
▪ NLP: sentiment analysis, document classification
▪ Computer vision: image recognition, object detection
▪ Speech recognition and audio processing
Semi-Structured Data
Data that has some organization but not strictly tabular.
Examples:
▪ JSON, XML, HTML, log files
▪ Key-value stores
Use cases:
▪ Data from APIs or web scraping
▪ Big data processing in NoSQL databases
▪ Flexible ingestion into data pipelines

[Link] BAYES IN R
Naive Bayes Classifier is a machine learning algorithm used to classify data into
categories. It uses Bayes' Theorem to calculate the probability of each class based on the
input features. It assumes that all features are independent of each other.

Bayes’ Theorem Formula


Naive Bayes algorithm is based on Bayes theorem. Bayes theorem gives the
conditional probability of an event A given another event B has occurred.
P(A∣B)=P(B∣A)⋅P(A)P(B)P(A∣B)=P(B)P(B∣A)⋅P(A)

Where:
• P(A|B) = Conditional probability of A given B.
• P(B|A) = Conditional probability of B given A.
• P(A) = Probability of event A.
• P(B) = Probability of event B.
For many predictors, we can formulate the posterior probability as follows:
P(A∣B)=P(B1∣A)⋅P(B2∣A)⋅P(B3∣A)⋅P(B4∣A)⋯P(A∣B)=P(B1∣A)⋅P(B2∣A)⋅P(B3∣A)⋅P(B4∣A)⋯

Implementation of Naive Bayes Classifier


These steps to build and evaluate a Naive Bayes model using the Iris dataset.
1. Installing and Load Required Packages
We install the necessary packages and load them.
• e1071: Contains Naive Bayes classifier (naiveBayes()) and other useful machine
learning functions.
• caTools: Provides utilities for data splitting (for training and test sets).
• caret: Simplifies machine learning tasks like training models, evaluating them and
creating confusion matrices.
• library(): This function loads the installed packages into the R environment, allowing
their functions to be used.

[Link]("e1071")
[Link]("caTools")
[Link]("caret")
library(e1071)
library(caTools)
library(caret)

2. Loading the Dataset


Loading the dataset and checking its structure.
• data(): Loads a dataset into R. For example, the iris dataset which contains information
about Iris flower species (sepal and petal length and width).
• head(): Displays the first few rows (default is 6) of the dataset for a quick overview.

data(iris)
head(iris)

3. Splitting the Dataset


The data training and testing sets using a 70:30 ratio.
• [Link](): Ensures reproducibility by setting the seed for the random number generator.
• [Link](): From the caTools package, it splits the data. The SplitRatio argument
defines the proportion for training data (e.g., 70%). It returns a logical vector indicating
rows in the training set.
• subset(): Creates subsets of the iris dataset, used to generate the train_cl and test_cl
based on the split.

[Link](123)
split <- [Link](iris, SplitRatio = 0.7)
train_cl <- subset(iris, split == TRUE)
test_cl <- subset(iris, split == FALSE)

4. Scaling the Features


We scale the numerical features to normalize the data.
• scale(): Standardizes the dataset by transforming the numeric columns (1 to 4,
corresponding to the features of the iris dataset) so that each feature has a mean of 0 and
a standard deviation of 1.

train_scale <- scale(train_cl[, 1:4])


test_scale <- scale(test_cl[, 1:4])
5. Training the Naive Bayes Model
We train the Naive Bayes classifier using the training set.
• naiveBayes(): From the e1071 package, this function trains the Naive Bayes classifier.
The Species ~ . formula indicates that we are predicting Species based on all other
variables in the dataset (the dot represents all other columns).
• The trained model is stored in the classifier_cl variable.

classifier_cl <- naiveBayes(Species ~ ., data = train_cl)


classifier_cl

6. Making Predictions
We use the trained model to predict species on the test data.
• predict(): Uses the trained classifier to predict the target variable (Species) for the test
data (test_cl). The predicted values are stored in the y_pred variable.

y_pred <- predict(classifier_cl, newdata = test_cl)

7. Evaluating the Model


We create a confusion matrix and evaluate the model performance.
• table(): Creates a confusion matrix by comparing the true class labels (test_cl$Species)
with the predicted class labels (y_pred).
• confusionMatrix(): From the caret package, this function calculates metrics like
accuracy, precision, recall and F1-score from the confusion matrix.

cm <- table(test_cl$Species, y_pred)


confusionMatrix(cm)

Advantages of Naive Bayes


• Simple and Fast: Easy to implement and computationally efficient, especially for large
datasets.
• Good for Text Classification: Often used in spam filtering, sentiment analysis, and document
categorization.
• Handles High-Dimensional Data: Can perform well even with a large number of features.
• Requires Less Training Data: Compared to some other complex algorithms, it can achieve
reasonable performance with relatively smaller training sets.
Limitations of Naive Bayes
• Strong Independence Assumption: The "naive" assumption of feature independence can lead
to reduced accuracy if features are highly correlated.
• Zero-Frequency Problem: If a category in the test data was not present in the training data,
the model might assign a zero probability, which can be addressed using techniques like
Laplace smoothing.
3. MACHINE LEARNING AND DEEP LEARNING

Machine Learning (ML) and Deep Learning (DL) are two core branches of Artificial
Intelligence (AI) that focus on enabling computers to learn from data. While both are used
to make predictions and automate decision-making, they differ in how they process data
and the complexity of models they use.

Machine Learning
Machine Learning is a branch of Artificial Intelligence that enables computer systems to
learn patterns from data and make predictions or decisions without being explicitly
programmed by humans.
• Works with smaller datasets.
• Requires manual feature extraction.
• Easier to interpret and implement.
• Best for structured data like tables or CSV files.

Types of Machine Learning Algorithms


Different types of ML Algorithms:
1. Supervised Learning: Here model learns from labelled datasets, where the input and
output are clearly defined.
2. Unsupervised Learning: Here the model identifies patterns or relationships in data
without any predefined labels.
3. Reinforcement Learning: Here the system learns by interacting with an environment
and receiving rewards or penalties based on its actions.

Applications:
1. Spam Emails: Detecting spam emails or fraudulent transactions.
2. Recommendation Systems: Building recommendation systems for movies, products or
content.
3. Analytics: Predictive analytics in finance, healthcare and marketing.

Deep Learning
Deep Learning uses artificial neural networks with multiple hidden layers that can
automatically learn complex patterns from raw data like images, sound, and text. It’s used
in applications such as image recognition, natural language processing, and speech
recognition.
• Learns features automatically from data.
• Performs better with large datasets.
• Needs GPUs or TPUs for training.
• Best for unstructured data such as images, audio or text.
• Used in complex applications like self-driving cars or chatbots.
Types of Deep Learning
Deep learning encompasses various architectures, each suited to different types of tasks:
1. Convolutional Neural Networks: Used for image processing tasks, CNNs are designed
to adaptively learn spatial hierarchies of features through convolutional layers.
2. Recurrent Neural Networks: Ideal for sequential data. RNNs have loops that allow
information to persist, effective for tasks like speech recognition and language
modeling.
3. Long Short-Term Memory Networks: A type of RNN that addresses the vanishing
gradient problem. They are used for complex sequences including text and speech.
4. Generative Adversarial Networks: GANs consist of two neural networks that are
generator and discriminator that compete against each other, creates synthetic data such
as images.
5. Transformers: Handles long-range dependencies in data. They are the backbone of
models like GPT and BERT, used in natural language processing.

Applications
1. Object Detection: Recognizing objects and faces in images or videos.
2. Natural Language Processing: Converting spoken language into text and understanding
speech commands.
3. Autonomous Vehicle: Enabling autonomous vehicles to perceive and navigate their
environment.

Difference Between Machine Learning and Deep Learning

Basis Machine Learning (ML) Deep Learning (DL)

Algorithms that learn from data and Subset of ML using multi-


Definition improve with experience. layered neural networks.

Data Works well with small to medium Requires large datasets for
Requirement datasets. effective learning.

Feature Manual – features must be selected Automatic – learns features


Extraction by experts. directly from data.

Slower and needs more


Faster and less resource-intensive.
Training Time computation power.

Depends on feature quality and Usually higher with enough


Accuracy algorithm. data.
Basis Machine Learning (ML) Deep Learning (DL)

Hardware Needs Can run on CPUs. Often requires GPUs or TPUs.

Difficult to interpret (“black


Easy to interpret.
Interpretability box”).

Spam detection, stock prediction, Image classification, speech


Examples recommendation systems. recognition, NLP.

You might also like