Friday, December 19, 2014

MATLAB Script: Best MBA Course

Upon the completion of my MBA at BU, I wanted to figure out what my top 5 courses (out of 18) were.

So I wrote a brute-force, unsexy MATLAB script that did a round-robin style side-by-side comparison.

It worked out fairly well. I even put in a very rudimentary tiebreaker loop wherein the user is asked to break the tie. Basically a "head to head" comparison, which, upon further review, should be pre-determined, since the user had already done a head-to-head comparison of the two courses before. Room for improvement.

Here it is:



% Determines the ranking of best MBA courses taken
% The user picks the best course by choosing between all combinations
clc
clear
num_courses = 18;
% Create the list of courses
% Course 1: "OB 712: Managing Organizations"
course_names{1} = 'OB 712: Managing Organizations';
% Course 2: "AC 711: Accounting"
course_names{2} = 'AC 711: Accounting';
% Course 3: "MK 724: Marketing Management"
course_names{3} = 'MK 724: Marketing Management';
% Course 4: "QM 717: Statistics"
course_names{4} = 'QM 717: Statistics';
% Course 5: "FE 730: Economics"
course_names{5} = 'FE 730: Economics';
% Course 6: "IS 711: IT Strategies"
course_names{6} = 'IS 711: IT Strategies';
% Course 7: "OM 726: Operations"
course_names{7} = 'OM 726: Operations';
% Course 8: "SI 751: Strategy"
course_names{8} = 'SI 751: Strategy';
% Course 9: "PL 700: Law and Ethics"
course_names{9} = 'PL 700: Law and Ethics';
% Course 10: "ES 700: Executive Presentation"
course_names{10} = 'ES 700: Executive Presentation';
% Course 11: "OB 853: Negotiations"
course_names{11} = 'OB 853: Negotiations';
% Course 12: "OM 880: Product Design"
course_names{12} = 'OM 880: Product Design';
% Course 13: "MK 864: Pricing"
course_names{13} = 'MK 864: Pricing';
% Course 14: "MK 862: High-Tech Marketing"
course_names{14} = 'MK 862: High-Tech Marketing';
% Course 15: "IS 827: Platforms"
course_names{15} = 'IS 827: Platforms';
% Course 16: "OB 848: Leadership"
course_names{16} = 'OB 848: Leadership';
% Course 17: "MK 852: Marketing Analytics"
course_names{17} = 'MK 852: Marketing Analytics';
% Course 18: "SI 845: Technology Strategy"
course_names{18} = 'SI 845: Technology Strategy';
% ES 700 and FE 722 were not considered for ranking
% Create a 2x18 matrix of randomly determined combinations
rand_course_combs = rand_combs(num_courses);
%rand_course_combs = rand_combs2(num_courses); %Alternative algorithm that doesn't use Statistics Toolbox
len_rand_course_combs = length(rand_course_combs);
points_array = zeros(1,num_courses);
better_course = 0;
for i=1:1:len_rand_course_combs
    course_1_name = char(course_names(rand_course_combs(i,1)));
    course_2_name = char(course_names(rand_course_combs(i,2)));
    prompt_str = [course_1_name, ' (1) vs. ',course_2_name, ' (2): '];
    clc
    pct_cmplt = 100*((i-1)/len_rand_course_combs);
    pct_cmplt_str = [num2str(pct_cmplt), '% complete'];
    disp(pct_cmplt_str)
    disp('Which one was better?');
    better_course = input(prompt_str);
       if better_course == 1
           points_array(rand_course_combs(i,1)) = points_array(rand_course_combs(i,1)) + 1;
       elseif better_course == 2
           points_array(rand_course_combs(i,2)) = points_array(rand_course_combs(i,2)) + 1;
       end
end
% Sort, rank, and display
sorted_points_array = sort(points_array,'descend');
len_points_array = length(points_array);
rank_array = zeros(1,len_points_array);
i=1;
while i <= len_points_array
   rank_array_temp = find(points_array == sorted_points_array(i));
   if length(rank_array_temp) > 1
       % Assumes only two values will be "tied". Should probably make this
       % more robust.
       % Break the tie by prompting user to pick the better option
       disp('Found a tie!')
       disp('Need to break it!')
       disp('Which one was better?')
       course_1_name = course_names{rank_array_temp(1)};
       course_2_name = course_names{rank_array_temp(2)};
       prompt_str = [course_1_name, ' (1) vs. ',course_2_name, ' (2): '];
       tiebreaker_choice = input(prompt_str);
       if tiebreaker_choice == 1
      rank_array(i) = rank_array_temp(1);
      rank_array(i+1) = rank_array_temp(2);
       else
        rank_array(i) = rank_array_temp(2);
        rank_array(i+1) = rank_array_temp(1);
       end
       i=i+2;
   else
   rank_array(i) = find(points_array == sorted_points_array(i));
   i=i+1;
   end
end
len_rank_array = length(rank_array);
for j = 1:1:len_rank_array
    clc
   disp_str = [num2str(j), ': ',course_names{rank_array(j)}, ' : ',num2str(sorted_points_array(j)), ' points.']; 
    disp(disp_str)
end



Here were the results:

1: OM 880: Product Design : 17 points.
2: IS 827: Platforms : 16 points.
3: OB 853: Negotiations : 15 points.
4: MK 862: High-Tech Marketing : 14 points.
5: MK 852: Marketing Analytics : 13 points.
6: MK 724: Marketing Management : 12 points.
7: SI 751: Strategy : 11 points.
8: FE 730: Economics : 10 points.
9: AC 711: Accounting : 9 points.
10: SI 845: Technology Strategy : 8 points.
11: OB 712: Managing Organizations : 7 points.
12: MK 864: Pricing : 6 points.
13: ES 700: Executive Presentation : 4 points.
14: OM 726: Operations : 4 points.
15: OB 848: Leadership : 3 points.
16: IS 711: IT Strategies : 2 points.
17: QM 717: Statistics : 2 points.
18: PL 700: Law and Ethics : 0 points.

No comments: