RMSE.ipynb (1292B)
1 { 2 "cells": [ 3 { 4 "cell_type": "code", 5 "execution_count": 1, 6 "metadata": {}, 7 "outputs": [], 8 "source": [ 9 "import math\n", 10 "\n", 11 "# Often you would use ordered pairs for expected and inference.\n", 12 "expected = [10, 10, 4, 3, 2, 4, 5, 5]\n", 13 "inference = [9 , 7, 3, 2, 1, 3, 2, 5]" 14 ] 15 }, 16 { 17 "cell_type": "code", 18 "execution_count": 12, 19 "metadata": {}, 20 "outputs": [ 21 { 22 "name": "stdout", 23 "output_type": "stream", 24 "text": [ 25 "1.695582495781317\n" 26 ] 27 } 28 ], 29 "source": [ 30 "count = 0\n", 31 "total = 0\n", 32 "while count < len(expected):\n", 33 " exp = expected[count]\n", 34 " inf = inference[count]\n", 35 " total += (exp - inf) ** 2\n", 36 " count += 1\n", 37 "\n", 38 "total = total / count\n", 39 "total = math.sqrt(total)\n", 40 "print(total)" 41 ] 42 } 43 ], 44 "metadata": { 45 "kernelspec": { 46 "display_name": "notebook", 47 "language": "python", 48 "name": "notebook" 49 }, 50 "language_info": { 51 "codemirror_mode": { 52 "name": "ipython", 53 "version": 3 54 }, 55 "file_extension": ".py", 56 "mimetype": "text/x-python", 57 "name": "python", 58 "nbconvert_exporter": "python", 59 "pygments_lexer": "ipython3", 60 "version": "3.11.2" 61 } 62 }, 63 "nbformat": 4, 64 "nbformat_minor": 2 65 }