Skip to content

Instantly share code, notes, and snippets.

@aicentral
Created January 1, 2023 13:57
Show Gist options
  • Save aicentral/24d6e41e82c6af87ffb7c8c2f640e86f to your computer and use it in GitHub Desktop.
Save aicentral/24d6e41e82c6af87ffb7c8c2f640e86f to your computer and use it in GitHub Desktop.
ML_simplified.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyMBiN2CXc9kZvRondGY1drE",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/aicentral/24d6e41e82c6af87ffb7c8c2f640e86f/ml_simplified.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "vtWXmu9y3FJW",
"outputId": "2d54c26e-c0c2-41c5-b37b-a544e897e5c0"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"The variance of each of the three features is:\n",
"[2.31875e+01 2.18750e-02 4.25000e+00]\n",
"The feature with the least variance is:\n",
"Width\n"
]
}
],
"source": [
"'''\n",
"Fining the feature witht he least variance.\n",
"'''\n",
"import numpy as np\n",
"feature_names = ['Length', 'Width', 'Hieght']\n",
"measurements = [[25, 5, 10],\n",
" [24, 4.9, 9],\n",
" [35, 4.8, 13],\n",
" [33, 5.2, 14]]\n",
"\n",
"feature_variance = np.var(measurements,axis=0)\n",
"print('The variance of each of the three features is:')\n",
"print(feature_variance)\n",
"# Now, locate the feature with the least variance\n",
"least_var_feature_idx = np.argmin(feature_variance)\n",
"# Find the name of that feature\n",
"least_var_feature_name = feature_names[least_var_feature_idx]\n",
"print('The feature with the least variance is:')\n",
"print(least_var_feature_name)"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment