Making Decisions with Cost Functions
by River Kanies
How do we make decisions?
To make decisions we:
- List options
- Weigh variables
- Score options (with weighted variables)
Example:
How to choose a sandwich
- List sandwiches to choose from
- Weigh variables such as taste + nutritional value
- Score sandwiches by summing weighted variables (you choose the sandwich with the best score)
Decision Matrix
Cost Function
C is the "cost" or score of the choice
Wa is weight for variable A
Wb is weight for variable B
What can we use cost functions for?
- Every day decisions (what link to click next)
- Design (best alternative)
- Machine Learning (linear regression + error minimization)
- Optimization of simulations
So, choosing from a small number of discrete options is simple...
But what if we have a continuous range of options?
(in multiple dimensions)
Typical Continuous Cost Function
Here the "optimal" choice for x is approximately 200
where C(x) is minimum
How do we calculate optimal value?
- Inspection (if approximate is good enough)
- Analytically: the derivative is 0 at min and max points
- Computational methods:
- Newton's method
- gradient descent
Optimization
Cost functions give us a method to choose the seemingly optimal choice in complex scenarios.
But assumptions must always be made. Models are never perfect.
Cost function vs. Model
- The model is the set of assumptions (variables and calculations) used to model the system
- The cost function is the method of evaluating the effectiveness of a particular set of input data (design decisions), using the model
- Optimize your model by minimizing cost function
- Cost function is commonly straight forward while model can be very complex
Simulation
- Develop cost function
- Track relevant data
- Model system
- Simulate stochastically
- Minimize cost function
It's a bit more complicated than before...
Specifically: Discrete Event Simulation (DES)
Simple medical office
- Wphys is the total physician wait time
- Wpat is the total patient wait time
- The 5 means physician time is 5 times as valuable as patient time
Model System
Simulate
- assume data distributions
- model:
- stochastic
- data --> wait times
- evaluate cost
Cost
FACTOR
(this represents scheduling time offset. Optimize this value to determine best scheduling times)
Simple Cost Function Plot
Linear regression and error minimization
(often, error = cost)
Multidimensional Cost Function
There are 2 independent variables in a simple line
above: theta values
left: b and a
Optimize Multidimensional Cost Functions with Gradient Descent
Uses partial derivatives
What if?!
Global vs. Local optimum
Guess and check
Good heuristics
Simulated annealing
So essentially...
Any decision can be made with cost function optimization
Even super complex ones...
Classification, Neural Nets
- Forward Propagation:
Input --> Weighted Nodes --> Output
Each output is a "class"
- Cost Calculation
Hypothesis - Example
- Back Propagation
Adjust weights
(similar to gradient descent)
2 layer cost function
X
Y
Z
Practical Neural Nets
Ex:
Question --> Redirect link
Natural Language Classifier:
- Instantiate classifier with training set
- make api calls to use
Making Decisions with Cost Functions
By River Kanies
Making Decisions with Cost Functions
- 305