diff --git a/main.py b/main.py index 1e0507b2af5f19e8d919dcc45abcafdf8180271b..458566767cdb977a718a060811516abfc729175d 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,8 @@ def main(): calc_part_1() calc_part_2() + calc_part_3() + calc_part_4() def test(): @@ -29,6 +31,19 @@ def test(): Also this assignment is due soon and I've spent the past week straight relearning statistics, so I just don't have time to make proper unittests. Rip. """ + # Test z-score normalization against https://youtu.be/5S-Zfa-vOXs + struct = [ + {'x': 2}, + {'x': 2}, + {'x': 3}, + {'x': 2}, + {'x': 5}, + {'x': 1}, + {'x': 6}, + ] + result = Normalizations.z_score(struct, 'x') + logger.info('{0}'.format(result)) + # Test covariance against https://youtu.be/0nZT9fqr2MU struct = [ {'x': 2.1, 'y': 8}, @@ -97,6 +112,9 @@ def calc_part_1(): def calc_part_2(): + """ + Logic for "part 2" of assignment. + """ student_array = [] # Open file. @@ -142,6 +160,47 @@ def calc_part_2(): logger.info(' {0}: {1}'.format(key, item)) logger.info('') + # Id 223 has both a midterm of 90 and final of 90. + # Id 841 has lowest midterm of 35 and lowest final of 37. + # Id 117 has highest midterm of 100 and highest final of 100. + logger.info('') + logger.info('Orig vs Normalization:') + logger.info('') + logger.info('Midterm/Final of 90:') + logger.info(' Orig: {0}'.format(student_array[223])) + logger.info(' Normalized: {0}'.format(norm_student_array[223])) + logger.info('') + logger.info('Lowest Midterm/Final:') + logger.info(' Orig: {0}'.format(student_array[841])) + logger.info(' Normalized: {0}'.format(norm_student_array[841])) + logger.info('') + logger.info('Highest Midterm/Final:') + logger.info(' Orig: {0}'.format(student_array[117])) + logger.info(' Normalized: {0}'.format(norm_student_array[117])) + logger.info('') + + # Pearson's Correlation Coefficient. + pearson_coeff = RelationalAnalysis.pearsons_correlation_coefficient(student_array, 'midterm', 'final') + logger.info('Person\'s Correlation Coeficient: {0}'.format(pearson_coeff)) + logger.info('') + + # Covariance. + covariance = RelationalAnalysis.covariance(student_array, 'midterm', 'final') + logger.info('Covariance: {0}'.format(covariance)) + logger.info('') + + +def calc_part_3(): + """ + Logic for "part 3" of assignment. + """ + + +def calc_part_4(): + """ + Logic for "part 4" of assignment. + """ + if __name__ == '__main__': logger.info('Starting program.')