Skip to content

Instantly share code, notes, and snippets.

@mikesparr
Last active January 5, 2021 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikesparr/356d0128ed7341c548e7e161e94a7bfa to your computer and use it in GitHub Desktop.
Save mikesparr/356d0128ed7341c548e7e161e94a7bfa to your computer and use it in GitHub Desktop.
AI Demo (manual function)
// creating a function by hand (traditional)
// feature engineering (now text has numeric index)
const colors = ["pink","purple","brown","red","green"]
const foodTypes = ["protein","fruit","vegetable","dairy","grain"]
// function is a model and parameters are features
function foodTaste(type, smell, spicy, temp, sweetness, color) {
if (type == 2) {
return "bad" // no sense going any further; foodTypes[2] is veg
}
if (color == 4) {
return "bad" // no sense going any further; colors[4] is green
}
if (spicy > 2) {
return "bad" // no sense going any further
}
if (temp > 150) {
return "bad" // no sense going any further
}
if (sweetness < 50) {
return "bad" // not cocoa puffs
}
if (smell > 25) {
return "bad" // forgot clothes pin to plug their nose
}
return "good"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment