Another idea as part of my “A year with data” exploration.
Anyone who has worked in a Scrum/Agile environment understands the pain involved with task estimation. Some of the methods include shirt sizes (S, M, L), the Fibonacci sequence (1, 2, 3, 5, 8.), powers of 2 (1, 2, 4, 8) and even poker. Then there is the process of dealing with disparate estimates. One person gives an estimate of 2 and another suggests its 13 . After some discussion its agreed that the task is a 8. At the end of the sprint maybe it turns out that the task really was a 5. It would be useful,and interesting, to determine how well people do in their estimation. Is person A always under estimating? Person B is mostly spot on,….
This seems like a good candidate for Machine Learning, supervised learning to be more specific. I am not sure how many teams capture information from the estimation process but they should.
Basic information such as:
- The original estimates for each team member
- The final agreed upon estimates
- The actual size of the task once completed
The data might look like this:
The ‘training’ data consists of ten tasks, the estimates from each of the nine team members and actual value the task turned out to be. I choose the Fibonacci sequence as a method for estimates. Another piece of information that could be useful is the estimate the team agreed upon. That could be compared to the actual value as well. I decided not to do since it hides the interesting information of each team members estimate. By using each team members input we could determine which ones are contributing more or which ones are further off in their estimates.
I am not going to try and explain Gradient Decent as there are others much better qualified to do the that. I found the Stanford Machine learning course to be the most useful. The downside is that the course used Octave and I want to use Python. There is a bit of a learning curve trying to make the change. Hopefully I have this figured out.
The significant equations are below.
The cost function J(θ) represents how well theta can predict the outcome.
Where xj(i) represents each team member’s estimate for all of the task.
x(i) represents the estimate(feature) vector of the training set.
θT is the transpose of the theta; vector
hθ(x(i)) is the predicted value.
The math looks like this.
For this I am using the following python packages
Note: In order to use seaborn residplot I had to install ‘patsy’ and ‘statsmodel’
pip install statsmodels
Set up pandas to display correctly
The first step is to read the data.
training_set = pd.read_csv('estimate data.txt')
Next, we need to separate the estimates from the actual values
tm_estimates = training_set[['tm1','tm2','tm3','tm4','tm5','tm6','tm7','tm8','tm9']] print(tm_estimates) tm1 tm2 tm3 tm4 tm5 tm6 tm7 tm8 tm9 1 8 1 13 5 8 2 5 13 3 8 5 8 8 5 3 1 8 2 5 5 5 5 2 1 8 1 8 5 6 3 1 2 2 13 5 3 5 5 8 8 8 8 13 13 1 3 5 1 1 1 1 2 5 1 3 5 1 1 5 8 5 3 5 3 5 3 2 1 1 3 2 8 8 6 5 8 8 13 3 5 2 5 5 8 8 8 8 8 8 actuals = training_set['est']
One thing to consider is the Normalization of the data. This is important when data values vary greatly. In this case the data is not all that different but its worth the effort to add this step.
mean = tm_estimates.mean() std = tm_estimates.std() tm_estimates_norm = (tm_estimates - mean) / std print(tm_estimates_norm)
To satisfy the equation we need to add an extra column for theta0. For that we add x0 and set all of the values to 1
# the number of data points m = len(tm_estimates_norm) #add the x0 column and set all values to one. tm_estimates_norm['x0'] = pd.Series(np.ones(m))
Next we define the learning rate alpha to be 0.15. The number of iterations is 150. Setting these two values will control how well the cost function converges.
alpha = 0.15 iterations = 150
Set the initial values of theta to zero. Then convert the data into numpy arrays instead of python strutures.
# Initialize theta values to zero thetas = np.zeros(len(tm_estimates_norm.columns)) tm_estimates_norm = np.array(tm_estimates_norm) estimations = np.array(actuals) print(estimations) cost_history = 
Now do something!
First calculate the prediction. Theta . estimates.
Next perform the the J(0) calculation
Calculate the cost and record the cost. This last step will tell us if the process is decreasing or not.
for i in range(iterations): # Calculate the predicted values predicted = np.dot(tm_estimates_norm, thetas) # Calculate the theta thetas -= (alpha / m) * np.dot((predicted - estimations), tm_estimates_norm) # Calculate cost sum_of_square_errors = np.square(predicted - estimations).sum() cost = sum_of_square_errors / (2 * m) # Append cost to history cost_history.append(cost)
I tried different combinations of alpha and iterations just to see how this works.
7.923283-0.076717 5.4614750.461475/td> 3.4814650.481465 4.404572-0.595428 14.2873011.287301 1.225380–0.774620 2.7378480.737848 /td> .467125.0207895.020789- 0.020789 10.990762-2.009238
This graph shows the linear fit between the predicted and actual values
This graph shows the difference between the predicted and actual values
The data set is far too small to declare anything. The cases where the actual was high there is less data and the error is greater. In order to get more data I’ll have to make it up. Having worked in development for years( many) I know that people tend to follow a pattern when giving estimates. Also the type of task will dictate estimates. A UI task may seem simple to someone familiar with UI development. While a server/backend person may find a UI task daunting. In deciding how to create sample data I devised a scheme to give each team member a strength in skills, UI, database, and server. Also each member has a estimation rating. This defines how they tend to rates tasks, low, high, mix or random. Once I get this working I start over and see how this new data performs.