power <- function(a,b) { c <- a^b # known function return(c) } power(1,3)
## 1
power(2,3)
## 8
power(3,4)
## 81
What if we don’t know what function to apply, but we have a lot of examples?
func(2)
## 2.895133
func(1)
## 1.666248
func(6)
## 6.399109
Machine learning is an application of artificial intelligence (AI) that provides systems the ability to automatically learn and improve from experience without being explicitly programmed.
## ## Attaching package: 'matrixStats'
## The following object is masked from 'package:plyr': ## ## count
calories | protein | fat | sodium | fiber | rating |
---|---|---|---|---|---|
70 | 4 | 1 | 130 | 10.0 | 68 |
120 | 3 | 5 | 15 | 2.0 | 34 |
70 | 4 | 1 | 260 | 9.0 | 59 |
50 | 4 | 0 | 140 | 14.0 | 94 |
110 | 2 | 2 | 180 | 1.5 | 30 |
calories | protein | fat | sodium | fiber | rating | pred_rating |
---|---|---|---|---|---|---|
120 | 3 | 5 | 15 | 2.0 | 34 | 31 |
70 | 4 | 1 | 260 | 9.0 | 59 | 70 |
110 | 2 | 2 | 180 | 1.5 | 30 | 34 |
90 | 2 | 1 | 200 | 4.0 | 49 | 47 |
120 | 1 | 2 | 220 | 0.0 | 18 | 22 |