SlideShare ist ein Scribd-Unternehmen logo
1 von 38
BY :
RAGINI RATRE
EEE 7TH SEMESTER
Introduction Of ML
Different sub topics of AI
Types of Machine Learning
Different Languages use in ML
Advantages of R over other Languages
R Programming
Project on HEART DISEASE ANALYSIS WITH R
Content:
 In computer science machine learning refers to a type of data analysis
that uses algorithms that learn from data. It is a type of artificial
intelligence (AI) that provides systems with the ability to learn without
being explicitly programmed.
What is ML ??
Different sub topics of AI
• Neural Network
• Planning
• Robotics
• ML
• Natural Language processing
• Perception
• Knowledge
• Cognitive system
Types of Machine Learning
• Supervised
• Unsupervised
• Reinforcement
 R programming
 Python
 Java-Family / C-Family
 Matlab
 Mathematica
 Stata etc
Different Languages use in ML
Why We Used R in ML..???
why
why
why
why
why
why
why
why
why
• Reduced Coad length
• Availability(4000+ functions are available)
• Simple and easy to learn
• Free an Open source
ADVANTAGES OF R OVER OTHER LANGUAGES
R Programming
 myString <- "Hello, World!"
 > print ( myString)
 [1] "Hello, World!"
Basic Syntax
Data Type
• Logical v <- TRUE print(class(v))
• Numeric v <- 23.5 print(class(v))
• Integer v <- 2L print(class(v))
• Complex v <- 2+5i print(class(v))
• Character v <- "TRUE" print(class(v))
• Raw v <- charToRaw("Hello") print(class(v))
OPERATORS
• Add v <- c( 2,5.5,6)
• Sub t <- c(8, 3, 4)
• Mul print(v+t)
• Div etc print(v-t)
• print(v*t)
Accessing Vector Elements
R Programming
# Accessing vector elements using position.
t <- c("Sun","Mon","Tue","Wed","Thurs","Fri","Sat")
u <- t[c(2,3,6)];print(u)
OUTPUT: [1] "Mon" "Tue" "Fri"
# Accessing vector elements using logical indexing.
v <- t[c(TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE)]
print(v)
[1] "Sun" "Fri"
# Accessing vector elements using negative indexing. x <-
t[c(-2,-5)] print(x)
[1] "Sun" "Tue" "Wed" "Fri" "Sat"
R Programming
# Create the predictor and response variable.
x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131)
y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48)
relation <- lm(y~x)
# Give the chart file a name.
png(file = "linearregression.png")
# Plot the chart.
plot(y,x,col = "blue",main = "Height & Weight Regression",
abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Weight in Kg",ylab = "Height in cm")
# Save the file.
dev.off()
Regression
R Programming
# Load the party package. It will automatically load other # dependent packages.
library(party)
# Create the input data frame.
input.dat <- readingSkills[c(1:105),]
# Give the chart file a name.
png(file = "decision_tree.png")
# Create the tree.
output.tree <- ctree( nativeSpeaker ~ age + shoeSize + score, data = input.dat)
# Plot the tree.
plot(output.tree)
# Save the file.
dev.off()
DECSION TREE
R Programming
OUTPUT
null device 1
Loading required package: methods
Loading required package: grid
Loading required package: mvtnorm
Loading required package: modeltools
Loading required package: stats4
Loading required package: strucchange
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date,as.Date.numeric
Loading required package: sandwich
R Programming
Graphs and Plots
# Create data for the graph.
x <- c(21, 62, 10, 53)
labels <- c("London", "New York", "Singapore", "Mumbai")
# Give the chart file a name.
png(file = "city.jpg")
# Plot the chart. pie(x,labels)
# Save the file.
dev.off()
Pi CHART
R Programming
Graphs and Plots
# Give the chart file a name.
png(file = "boxplot.png")
# Plot the chart.
boxplot(mpg ~ cyl, data = mtcars, xlab =
"Number of Cylinders", ylab = "Miles Per
Gallon", main = "Mileage Data")
# Save the file. dev.off()
BOX PLOT
R Programming
Graphs and Plots
# Create the data for the chart
H <- c(7,12,28,3,41)
# Give the chart file a name
png(file = "barchart.png")
# Plot the bar chart
barplot(H)
# Save the file
dev.off()
BAR PLOTS
R Programming
Graphs and Plots
# Create the data for the chart.
v <- c(7,12,28,3,41)
# Give the chart file a name.
png(file = "line_chart.jpg")
# Plot the bar chart. plot(v,type = "o")
# Save the file.
dev.off()
LINE GRAPHS
 Image Recognition
 Speech Recognition
 Medical Diagnosis
 Statistical Arbitrage
 Prediction
APPLICATIONs OF ML
FEW STEPS TO HANDLE THE DATA
• Data Selection
Consider what data is available, what data is missing and what data can be
removed.
• Data Preprocessing
Organize your selected data by formatting, cleaning and sampling from it.
• Data Transformation
Transform preprocessed data ready for machine learning by engineering
features using scaling, attribute decomposition and attribute aggregation.
 Identify and handle missing values
 Data FORMATTING
 DATA NORMALIZATION (CENTERING/SCALING)
 DATA BINNING
PRE-PROCESSING DATA IN R
 Missing value occur when no data value is stored for a variable(feature) in an
observation
 Could be represented as “?” , “N/A” , 0 or Just blank cell
Drop the missing value:
 Drop the variable
 Drop the data entry
Replace the missing value:
 Replace it with an average of similar datapoint
 Replace it by frequency
 Replace it based on other function
Identify and handle missing values
 Applying calculation to an entire column
 Like conversion of data like from meter to kilometer
Data FORMATTING
 My making the range consistent between variables , normalization
enables a fairer comparison between features
 Few methods:
1. Simple Feature Scaling x(new)=x(old)/x(max)
2. Min-Max x(new) = (x(old)-x(min))/(x(max)-x(min))
DATA NORMALIZATION (CENTERING/SCALING)
 Binning Grouping of values into “bins”
 Converts numeric into categorical variables
 Grouping a set of numerical values into subset “bins”
DATA BINNING
Data preparation / transformation is a large subject that can involve a lot of
iterations, exploration and analysis. Getting good at data preparation will
make you a master at machine learning.
DATA TRANSFORMATION
PROJECT ON Heart disease
• First we need .csv file here csv stands for comma separated values
>>> getwd()
>>> setwd("C:UsersVinitDesktopMachineLearning")
>>> table1<-read.table("heart_disease_male.csv",header=T,sep=",")
• We can also use read.csv() function in place of read.table() as it is a csv file
Output:
age chest_pain rest_bpress blood_sugar rest_electro max_heart_rate exercice_angina disease
1 43 asympt 140 f normal 135 yes 1
2 39 atyp_angina 120 f normal 160 yes 0
3 39 non_anginal 160 t normal 160 no 0
4 42 non_anginal 160 f normal 146 no 0
5 49 asympt 140 f normal 130 no
0
6 50 asympt 140 f normal 135 no 0
>>>head(table1)
table(is.na(table1$AGE))
table(is.na(table1$CHEST_PAIN))
table(is.na(table1$REST_BPRESS))
table(is.na(table1$BLOOD_SUGAR))
table(is.na(table1$REST_ELECTRO))
table(is.na(table1$MAX_HEART_RATE))
table(is.na(table1$EXERCICE_ANGINA))
table(is.na(table1$DISEASE))
HANDLE MISSING DATA
OUTPUT:
FALSE
209
So, there is no need to
handle data as there is no
missing values
DATA visualization
>>>library(ggplot2)
>>> x<-ggplot(table1)
>>> x+geom_bar(aes(x=age))
>>> x+geom_bar(aes(x=blood_sugar))
>>> x+geom_density(aes(max_heart_rate))
Output:
>>>x<-ggplot(table1,aes(y=max_heart_rate,x=disease))
>>>x+geom_violin()+geom_jitter()
Output:
 model1<- glm(disease~.,family="binomial") #take all the columns in the model
summary(model1)
Prediction
 model2=glm(disease~chest_pain+exercise_angina+max_heart_rate,
training,family=”binomial”)
 summary(model2)
 In conclusion, Machine learning is an incredible breakthrough in the field
of artificial intelligence. While it does have some frightening implications
when you think about it, these Machine Learning Applications are several
of the many ways this technology can improve our lives.
Conclusion
PPT ON MACHINE LEARNING by Ragini Ratre

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Grouping & Summarizing Data in R
Grouping & Summarizing Data in RGrouping & Summarizing Data in R
Grouping & Summarizing Data in R
 
R programming language
R programming languageR programming language
R programming language
 
Is there a perfect data-parallel programming language? (Experiments with More...
Is there a perfect data-parallel programming language? (Experiments with More...Is there a perfect data-parallel programming language? (Experiments with More...
Is there a perfect data-parallel programming language? (Experiments with More...
 
Move your data (Hans Rosling style) with googleVis + 1 line of R code
Move your data (Hans Rosling style) with googleVis + 1 line of R codeMove your data (Hans Rosling style) with googleVis + 1 line of R code
Move your data (Hans Rosling style) with googleVis + 1 line of R code
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]
 
R-programming-training-in-mumbai
R-programming-training-in-mumbaiR-programming-training-in-mumbai
R-programming-training-in-mumbai
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
3 R Tutorial Data Structure
3 R Tutorial Data Structure3 R Tutorial Data Structure
3 R Tutorial Data Structure
 
Python for R Users
Python for R UsersPython for R Users
Python for R Users
 
5 R Tutorial Data Visualization
5 R Tutorial Data Visualization5 R Tutorial Data Visualization
5 R Tutorial Data Visualization
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
 
Machine Learning in R
Machine Learning in RMachine Learning in R
Machine Learning in R
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyr
 
Modeling with Hadoop kdd2011
Modeling with Hadoop kdd2011Modeling with Hadoop kdd2011
Modeling with Hadoop kdd2011
 
Data profiling with Apache Calcite
Data profiling with Apache CalciteData profiling with Apache Calcite
Data profiling with Apache Calcite
 
Map/Reduce intro
Map/Reduce introMap/Reduce intro
Map/Reduce intro
 
Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06Introduction to r studio on aws 2020 05_06
Introduction to r studio on aws 2020 05_06
 
Big Data Mining in Indian Economic Survey 2017
Big Data Mining in Indian Economic Survey 2017Big Data Mining in Indian Economic Survey 2017
Big Data Mining in Indian Economic Survey 2017
 
R reference card
R reference cardR reference card
R reference card
 

Ähnlich wie PPT ON MACHINE LEARNING by Ragini Ratre

Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
SonaCharles2
 

Ähnlich wie PPT ON MACHINE LEARNING by Ragini Ratre (20)

R Introduction
R IntroductionR Introduction
R Introduction
 
R workshop
R workshopR workshop
R workshop
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdf
 
Hands on Mahout!
Hands on Mahout!Hands on Mahout!
Hands on Mahout!
 
Data Analytics with R and SQL Server
Data Analytics with R and SQL ServerData Analytics with R and SQL Server
Data Analytics with R and SQL Server
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
The Very ^ 2 Basics of R
The Very ^ 2 Basics of RThe Very ^ 2 Basics of R
The Very ^ 2 Basics of R
 
e_lumley.pdf
e_lumley.pdfe_lumley.pdf
e_lumley.pdf
 
CuRious about R in Power BI? End to end R in Power BI for beginners
CuRious about R in Power BI? End to end R in Power BI for beginners CuRious about R in Power BI? End to end R in Power BI for beginners
CuRious about R in Power BI? End to end R in Power BI for beginners
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Data analysis in R
Data analysis in RData analysis in R
Data analysis in R
 
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptxfINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
fINAL Lesson_5_Data_Manipulation_using_R_v1.pptx
 
Aggregate.pptx
Aggregate.pptxAggregate.pptx
Aggregate.pptx
 
Unit 2 - Data Manipulation with R.pptx
Unit 2 - Data Manipulation with R.pptxUnit 2 - Data Manipulation with R.pptx
Unit 2 - Data Manipulation with R.pptx
 
R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011
 
R programmingmilano
R programmingmilanoR programmingmilano
R programmingmilano
 
Unit 4_Working with Graphs _python (2).pptx
Unit 4_Working with Graphs _python (2).pptxUnit 4_Working with Graphs _python (2).pptx
Unit 4_Working with Graphs _python (2).pptx
 

Kürzlich hochgeladen

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

PPT ON MACHINE LEARNING by Ragini Ratre

  • 1. BY : RAGINI RATRE EEE 7TH SEMESTER
  • 2. Introduction Of ML Different sub topics of AI Types of Machine Learning Different Languages use in ML Advantages of R over other Languages R Programming Project on HEART DISEASE ANALYSIS WITH R Content:
  • 3.  In computer science machine learning refers to a type of data analysis that uses algorithms that learn from data. It is a type of artificial intelligence (AI) that provides systems with the ability to learn without being explicitly programmed. What is ML ??
  • 4. Different sub topics of AI • Neural Network • Planning • Robotics • ML • Natural Language processing • Perception • Knowledge • Cognitive system
  • 5.
  • 6. Types of Machine Learning • Supervised • Unsupervised • Reinforcement
  • 7.  R programming  Python  Java-Family / C-Family  Matlab  Mathematica  Stata etc Different Languages use in ML
  • 8. Why We Used R in ML..??? why why why why why why why why why
  • 9. • Reduced Coad length • Availability(4000+ functions are available) • Simple and easy to learn • Free an Open source ADVANTAGES OF R OVER OTHER LANGUAGES
  • 10. R Programming  myString <- "Hello, World!"  > print ( myString)  [1] "Hello, World!" Basic Syntax Data Type • Logical v <- TRUE print(class(v)) • Numeric v <- 23.5 print(class(v)) • Integer v <- 2L print(class(v)) • Complex v <- 2+5i print(class(v)) • Character v <- "TRUE" print(class(v)) • Raw v <- charToRaw("Hello") print(class(v)) OPERATORS • Add v <- c( 2,5.5,6) • Sub t <- c(8, 3, 4) • Mul print(v+t) • Div etc print(v-t) • print(v*t)
  • 11. Accessing Vector Elements R Programming # Accessing vector elements using position. t <- c("Sun","Mon","Tue","Wed","Thurs","Fri","Sat") u <- t[c(2,3,6)];print(u) OUTPUT: [1] "Mon" "Tue" "Fri" # Accessing vector elements using logical indexing. v <- t[c(TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE)] print(v) [1] "Sun" "Fri" # Accessing vector elements using negative indexing. x <- t[c(-2,-5)] print(x) [1] "Sun" "Tue" "Wed" "Fri" "Sat"
  • 12. R Programming # Create the predictor and response variable. x <- c(151, 174, 138, 186, 128, 136, 179, 163, 152, 131) y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) relation <- lm(y~x) # Give the chart file a name. png(file = "linearregression.png") # Plot the chart. plot(y,x,col = "blue",main = "Height & Weight Regression", abline(lm(x~y)),cex = 1.3,pch = 16,xlab = "Weight in Kg",ylab = "Height in cm") # Save the file. dev.off() Regression
  • 13. R Programming # Load the party package. It will automatically load other # dependent packages. library(party) # Create the input data frame. input.dat <- readingSkills[c(1:105),] # Give the chart file a name. png(file = "decision_tree.png") # Create the tree. output.tree <- ctree( nativeSpeaker ~ age + shoeSize + score, data = input.dat) # Plot the tree. plot(output.tree) # Save the file. dev.off() DECSION TREE
  • 14. R Programming OUTPUT null device 1 Loading required package: methods Loading required package: grid Loading required package: mvtnorm Loading required package: modeltools Loading required package: stats4 Loading required package: strucchange Loading required package: zoo Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date,as.Date.numeric Loading required package: sandwich
  • 15. R Programming Graphs and Plots # Create data for the graph. x <- c(21, 62, 10, 53) labels <- c("London", "New York", "Singapore", "Mumbai") # Give the chart file a name. png(file = "city.jpg") # Plot the chart. pie(x,labels) # Save the file. dev.off() Pi CHART
  • 16. R Programming Graphs and Plots # Give the chart file a name. png(file = "boxplot.png") # Plot the chart. boxplot(mpg ~ cyl, data = mtcars, xlab = "Number of Cylinders", ylab = "Miles Per Gallon", main = "Mileage Data") # Save the file. dev.off() BOX PLOT
  • 17. R Programming Graphs and Plots # Create the data for the chart H <- c(7,12,28,3,41) # Give the chart file a name png(file = "barchart.png") # Plot the bar chart barplot(H) # Save the file dev.off() BAR PLOTS
  • 18. R Programming Graphs and Plots # Create the data for the chart. v <- c(7,12,28,3,41) # Give the chart file a name. png(file = "line_chart.jpg") # Plot the bar chart. plot(v,type = "o") # Save the file. dev.off() LINE GRAPHS
  • 19.  Image Recognition  Speech Recognition  Medical Diagnosis  Statistical Arbitrage  Prediction APPLICATIONs OF ML
  • 20. FEW STEPS TO HANDLE THE DATA • Data Selection Consider what data is available, what data is missing and what data can be removed. • Data Preprocessing Organize your selected data by formatting, cleaning and sampling from it. • Data Transformation Transform preprocessed data ready for machine learning by engineering features using scaling, attribute decomposition and attribute aggregation.
  • 21.  Identify and handle missing values  Data FORMATTING  DATA NORMALIZATION (CENTERING/SCALING)  DATA BINNING PRE-PROCESSING DATA IN R
  • 22.  Missing value occur when no data value is stored for a variable(feature) in an observation  Could be represented as “?” , “N/A” , 0 or Just blank cell Drop the missing value:  Drop the variable  Drop the data entry Replace the missing value:  Replace it with an average of similar datapoint  Replace it by frequency  Replace it based on other function Identify and handle missing values
  • 23.  Applying calculation to an entire column  Like conversion of data like from meter to kilometer Data FORMATTING
  • 24.  My making the range consistent between variables , normalization enables a fairer comparison between features  Few methods: 1. Simple Feature Scaling x(new)=x(old)/x(max) 2. Min-Max x(new) = (x(old)-x(min))/(x(max)-x(min)) DATA NORMALIZATION (CENTERING/SCALING)
  • 25.  Binning Grouping of values into “bins”  Converts numeric into categorical variables  Grouping a set of numerical values into subset “bins” DATA BINNING
  • 26. Data preparation / transformation is a large subject that can involve a lot of iterations, exploration and analysis. Getting good at data preparation will make you a master at machine learning. DATA TRANSFORMATION
  • 27. PROJECT ON Heart disease • First we need .csv file here csv stands for comma separated values >>> getwd() >>> setwd("C:UsersVinitDesktopMachineLearning") >>> table1<-read.table("heart_disease_male.csv",header=T,sep=",") • We can also use read.csv() function in place of read.table() as it is a csv file
  • 28. Output: age chest_pain rest_bpress blood_sugar rest_electro max_heart_rate exercice_angina disease 1 43 asympt 140 f normal 135 yes 1 2 39 atyp_angina 120 f normal 160 yes 0 3 39 non_anginal 160 t normal 160 no 0 4 42 non_anginal 160 f normal 146 no 0 5 49 asympt 140 f normal 130 no 0 6 50 asympt 140 f normal 135 no 0 >>>head(table1)
  • 30. DATA visualization >>>library(ggplot2) >>> x<-ggplot(table1) >>> x+geom_bar(aes(x=age)) >>> x+geom_bar(aes(x=blood_sugar)) >>> x+geom_density(aes(max_heart_rate))
  • 32.
  • 35.  model1<- glm(disease~.,family="binomial") #take all the columns in the model summary(model1) Prediction
  • 37.  In conclusion, Machine learning is an incredible breakthrough in the field of artificial intelligence. While it does have some frightening implications when you think about it, these Machine Learning Applications are several of the many ways this technology can improve our lives. Conclusion