[ADD] initial commit

This commit is contained in:
Eduardo Cueto Mendoza 2020-04-14 11:37:47 -06:00
parent d1c1f000c0
commit c3a9906f30
7 changed files with 3481 additions and 0 deletions

158
Manual-Neural-Network.ipynb Normal file
View File

@ -0,0 +1,158 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"class SimpleClass():\n",
" \n",
" def __init__(self,name):\n",
" print(\"Hello\"+ ' ' +name)\n",
" \n",
" def yell(self):\n",
" print(\"YELLING!!!\")"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"s = \"world\""
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"str"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(s)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello Ed\n"
]
}
],
"source": [
"x = SimpleClass('Ed')"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"YELLING!!!\n"
]
}
],
"source": [
"x.yell()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"class ExtendedClass(SimpleClass):\n",
" \n",
" def __init__(self):\n",
" super().__init__('Eddie')\n",
" print(\"EXTEND\")"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello Eddie\n",
"EXTEND\n"
]
}
],
"source": [
"y = ExtendedClass()"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"YELLING!!!\n"
]
}
],
"source": [
"y.yell()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

528
Numpy.ipynb Normal file
View File

@ -0,0 +1,528 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"my_list = [1,2,3]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(np.array(my_list))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"arr = np.array(my_list)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 2, 3])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.arange(0,10)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 2, 4, 6, 8, 10])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.arange(0,11,2)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0., 0., 0., 0., 0.])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.zeros(5)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0., 0., 0., 0., 0.],\n",
" [0., 0., 0., 0., 0.],\n",
" [0., 0., 0., 0., 0.]])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.zeros((3,5))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0. , 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 11. ])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.linspace(0,11,11)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[7, 3, 7],\n",
" [8, 3, 2],\n",
" [1, 9, 0]])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.random.randint(0,10,(3,3))"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([95, 11, 81, 70, 63, 87, 75, 9, 77, 40])"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.random.seed(101)\n",
"\n",
"np.random.randint(0,100,10)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 4, 63, 40, 60, 92, 64, 5, 12, 93, 40])"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.random.randint(0,100,10)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"np.random.seed(101)\n",
"\n",
"arr = np.random.randint(0,100,10)\n"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([95, 11, 81, 70, 63, 87, 75, 9, 77, 40])"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"95"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr.max()"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr.min()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr.argmax()"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[95, 11, 81, 70, 63],\n",
" [87, 75, 9, 77, 40]])"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr.reshape(2,5)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"mat = np.arange(0,100).reshape(10,10)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n",
" [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],\n",
" [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],\n",
" [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],\n",
" [40, 41, 42, 43, 44, 45, 46, 47, 48, 49],\n",
" [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],\n",
" [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],\n",
" [70, 71, 72, 73, 74, 75, 76, 77, 78, 79],\n",
" [80, 81, 82, 83, 84, 85, 86, 87, 88, 89],\n",
" [90, 91, 92, 93, 94, 95, 96, 97, 98, 99]])"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mat"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"43"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mat[4,3]"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90])"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mat[:,0]"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([50, 51, 52, 53, 54, 55, 56, 57, 58, 59])"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mat[5,:]"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 0, 1, 2],\n",
" [10, 11, 12],\n",
" [20, 21, 22]])"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mat[0:3,0:3]"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"my_filter = mat > 50"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,\n",
" 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,\n",
" 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99])"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mat[my_filter]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

397
Pandas.ipynb Normal file
View File

@ -0,0 +1,397 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/eddie/.pyenv/versions/3.7.3/envs/tensorflow-1.14/lib/python3.7/site-packages/pandas/compat/__init__.py:117: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.\n",
" warnings.warn(msg)\n"
]
}
],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/Users/eddie/Documents/Programming/Python/Neural_Networks_Stuff/Course'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pwd"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('./Tensorflow-Bootcamp-master/00-Crash-Course-Basics/salaries.csv')"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Salary</th>\n",
" <th>Age</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>John</td>\n",
" <td>50000</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Sally</td>\n",
" <td>120000</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Alyssa</td>\n",
" <td>80000</td>\n",
" <td>27</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Salary Age\n",
"0 John 50000 34\n",
"1 Sally 120000 45\n",
"2 Alyssa 80000 27"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 50000\n",
"1 120000\n",
"2 80000\n",
"Name: Salary, dtype: int64"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['Salary']"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Salary</th>\n",
" <th>Name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>50000</td>\n",
" <td>John</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>120000</td>\n",
" <td>Sally</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>80000</td>\n",
" <td>Alyssa</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Salary Name\n",
"0 50000 John\n",
"1 120000 Sally\n",
"2 80000 Alyssa"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[['Salary','Name']]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Salary</th>\n",
" <th>Age</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>3.000000</td>\n",
" <td>3.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>83333.333333</td>\n",
" <td>35.333333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>35118.845843</td>\n",
" <td>9.073772</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>50000.000000</td>\n",
" <td>27.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>65000.000000</td>\n",
" <td>30.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>80000.000000</td>\n",
" <td>34.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>100000.000000</td>\n",
" <td>39.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>120000.000000</td>\n",
" <td>45.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Salary Age\n",
"count 3.000000 3.000000\n",
"mean 83333.333333 35.333333\n",
"std 35118.845843 9.073772\n",
"min 50000.000000 27.000000\n",
"25% 65000.000000 30.500000\n",
"50% 80000.000000 34.000000\n",
"75% 100000.000000 39.500000\n",
"max 120000.000000 45.000000"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.describe()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Salary</th>\n",
" <th>Age</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Sally</td>\n",
" <td>120000</td>\n",
" <td>45</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Alyssa</td>\n",
" <td>80000</td>\n",
" <td>27</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Salary Age\n",
"1 Sally 120000 45\n",
"2 Alyssa 80000 27"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[df['Salary'] > 60000]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

70
Pytorch_1.ipynb Normal file
View File

@ -0,0 +1,70 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import torch"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import torchvision"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"torch.cuda.is_available()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

818
Scikit-Learn.ipynb Normal file
View File

@ -0,0 +1,818 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from sklearn.preprocessing import MinMaxScaler"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"data = np.random.randint(0,100,(10,2))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[53, 52],\n",
" [82, 96],\n",
" [60, 84],\n",
" [15, 90],\n",
" [78, 31],\n",
" [ 5, 12],\n",
" [32, 75],\n",
" [80, 39],\n",
" [31, 46],\n",
" [22, 29]])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"scaler_model = MinMaxScaler()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"sklearn.preprocessing._data.MinMaxScaler"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(scaler_model)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MinMaxScaler(copy=True, feature_range=(0, 1))"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scaler_model.fit(data)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.62337662, 0.47619048],\n",
" [1. , 1. ],\n",
" [0.71428571, 0.85714286],\n",
" [0.12987013, 0.92857143],\n",
" [0.94805195, 0.22619048],\n",
" [0. , 0. ],\n",
" [0.35064935, 0.75 ],\n",
" [0.97402597, 0.32142857],\n",
" [0.33766234, 0.4047619 ],\n",
" [0.22077922, 0.20238095]])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scaler_model.transform(data)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0.62337662, 0.47619048],\n",
" [1. , 1. ],\n",
" [0.71428571, 0.85714286],\n",
" [0.12987013, 0.92857143],\n",
" [0.94805195, 0.22619048],\n",
" [0. , 0. ],\n",
" [0.35064935, 0.75 ],\n",
" [0.97402597, 0.32142857],\n",
" [0.33766234, 0.4047619 ],\n",
" [0.22077922, 0.20238095]])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scaler_model.fit_transform(data)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/eddie/.pyenv/versions/3.7.3/envs/tensorflow-1.14/lib/python3.7/site-packages/pandas/compat/__init__.py:117: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.\n",
" warnings.warn(msg)\n"
]
}
],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"mydata = np.random.randint(0,101,(50,4))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 97, 70, 23, 81],\n",
" [ 60, 40, 73, 7],\n",
" [ 60, 88, 87, 67],\n",
" [ 42, 25, 81, 100],\n",
" [ 45, 30, 69, 72],\n",
" [ 16, 100, 70, 14],\n",
" [ 25, 76, 32, 70],\n",
" [ 2, 29, 46, 65],\n",
" [ 71, 33, 11, 79],\n",
" [ 98, 16, 76, 9],\n",
" [ 0, 78, 61, 34],\n",
" [ 78, 43, 45, 87],\n",
" [ 95, 78, 6, 34],\n",
" [ 14, 44, 95, 27],\n",
" [ 32, 31, 90, 58],\n",
" [ 72, 15, 16, 59],\n",
" [ 5, 72, 31, 36],\n",
" [ 72, 30, 94, 55],\n",
" [ 55, 19, 91, 74],\n",
" [ 9, 20, 10, 34],\n",
" [ 3, 6, 25, 49],\n",
" [ 63, 61, 86, 55],\n",
" [ 25, 21, 0, 85],\n",
" [ 80, 66, 73, 51],\n",
" [ 96, 46, 35, 58],\n",
" [ 7, 4, 89, 25],\n",
" [ 92, 11, 77, 59],\n",
" [ 38, 94, 19, 46],\n",
" [ 34, 24, 94, 70],\n",
" [100, 91, 46, 76],\n",
" [ 43, 10, 35, 78],\n",
" [ 15, 24, 57, 6],\n",
" [ 51, 47, 47, 55],\n",
" [ 83, 5, 84, 40],\n",
" [100, 22, 26, 72],\n",
" [ 60, 83, 80, 92],\n",
" [ 28, 39, 82, 17],\n",
" [ 56, 20, 94, 85],\n",
" [ 72, 56, 63, 54],\n",
" [ 15, 60, 30, 72],\n",
" [ 41, 21, 86, 54],\n",
" [ 85, 7, 50, 87],\n",
" [ 48, 13, 69, 93],\n",
" [ 75, 20, 98, 96],\n",
" [ 41, 18, 14, 31],\n",
" [ 84, 13, 62, 6],\n",
" [ 13, 40, 77, 60],\n",
" [ 70, 18, 84, 26],\n",
" [ 97, 22, 24, 34],\n",
" [ 56, 83, 9, 95]])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mydata"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(data=mydata, columns = ['f1','f2','f3','label'])"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>f1</th>\n",
" <th>f2</th>\n",
" <th>f3</th>\n",
" <th>label</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>97</td>\n",
" <td>70</td>\n",
" <td>23</td>\n",
" <td>81</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>60</td>\n",
" <td>40</td>\n",
" <td>73</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>60</td>\n",
" <td>88</td>\n",
" <td>87</td>\n",
" <td>67</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>42</td>\n",
" <td>25</td>\n",
" <td>81</td>\n",
" <td>100</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>45</td>\n",
" <td>30</td>\n",
" <td>69</td>\n",
" <td>72</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>16</td>\n",
" <td>100</td>\n",
" <td>70</td>\n",
" <td>14</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>25</td>\n",
" <td>76</td>\n",
" <td>32</td>\n",
" <td>70</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>2</td>\n",
" <td>29</td>\n",
" <td>46</td>\n",
" <td>65</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>71</td>\n",
" <td>33</td>\n",
" <td>11</td>\n",
" <td>79</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>98</td>\n",
" <td>16</td>\n",
" <td>76</td>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>0</td>\n",
" <td>78</td>\n",
" <td>61</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>78</td>\n",
" <td>43</td>\n",
" <td>45</td>\n",
" <td>87</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>95</td>\n",
" <td>78</td>\n",
" <td>6</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>14</td>\n",
" <td>44</td>\n",
" <td>95</td>\n",
" <td>27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>32</td>\n",
" <td>31</td>\n",
" <td>90</td>\n",
" <td>58</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>72</td>\n",
" <td>15</td>\n",
" <td>16</td>\n",
" <td>59</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>5</td>\n",
" <td>72</td>\n",
" <td>31</td>\n",
" <td>36</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>72</td>\n",
" <td>30</td>\n",
" <td>94</td>\n",
" <td>55</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>55</td>\n",
" <td>19</td>\n",
" <td>91</td>\n",
" <td>74</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>9</td>\n",
" <td>20</td>\n",
" <td>10</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>3</td>\n",
" <td>6</td>\n",
" <td>25</td>\n",
" <td>49</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>63</td>\n",
" <td>61</td>\n",
" <td>86</td>\n",
" <td>55</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>25</td>\n",
" <td>21</td>\n",
" <td>0</td>\n",
" <td>85</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>80</td>\n",
" <td>66</td>\n",
" <td>73</td>\n",
" <td>51</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>96</td>\n",
" <td>46</td>\n",
" <td>35</td>\n",
" <td>58</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>7</td>\n",
" <td>4</td>\n",
" <td>89</td>\n",
" <td>25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>92</td>\n",
" <td>11</td>\n",
" <td>77</td>\n",
" <td>59</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>38</td>\n",
" <td>94</td>\n",
" <td>19</td>\n",
" <td>46</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>34</td>\n",
" <td>24</td>\n",
" <td>94</td>\n",
" <td>70</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>100</td>\n",
" <td>91</td>\n",
" <td>46</td>\n",
" <td>76</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30</th>\n",
" <td>43</td>\n",
" <td>10</td>\n",
" <td>35</td>\n",
" <td>78</td>\n",
" </tr>\n",
" <tr>\n",
" <th>31</th>\n",
" <td>15</td>\n",
" <td>24</td>\n",
" <td>57</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>32</th>\n",
" <td>51</td>\n",
" <td>47</td>\n",
" <td>47</td>\n",
" <td>55</td>\n",
" </tr>\n",
" <tr>\n",
" <th>33</th>\n",
" <td>83</td>\n",
" <td>5</td>\n",
" <td>84</td>\n",
" <td>40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>34</th>\n",
" <td>100</td>\n",
" <td>22</td>\n",
" <td>26</td>\n",
" <td>72</td>\n",
" </tr>\n",
" <tr>\n",
" <th>35</th>\n",
" <td>60</td>\n",
" <td>83</td>\n",
" <td>80</td>\n",
" <td>92</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>28</td>\n",
" <td>39</td>\n",
" <td>82</td>\n",
" <td>17</td>\n",
" </tr>\n",
" <tr>\n",
" <th>37</th>\n",
" <td>56</td>\n",
" <td>20</td>\n",
" <td>94</td>\n",
" <td>85</td>\n",
" </tr>\n",
" <tr>\n",
" <th>38</th>\n",
" <td>72</td>\n",
" <td>56</td>\n",
" <td>63</td>\n",
" <td>54</td>\n",
" </tr>\n",
" <tr>\n",
" <th>39</th>\n",
" <td>15</td>\n",
" <td>60</td>\n",
" <td>30</td>\n",
" <td>72</td>\n",
" </tr>\n",
" <tr>\n",
" <th>40</th>\n",
" <td>41</td>\n",
" <td>21</td>\n",
" <td>86</td>\n",
" <td>54</td>\n",
" </tr>\n",
" <tr>\n",
" <th>41</th>\n",
" <td>85</td>\n",
" <td>7</td>\n",
" <td>50</td>\n",
" <td>87</td>\n",
" </tr>\n",
" <tr>\n",
" <th>42</th>\n",
" <td>48</td>\n",
" <td>13</td>\n",
" <td>69</td>\n",
" <td>93</td>\n",
" </tr>\n",
" <tr>\n",
" <th>43</th>\n",
" <td>75</td>\n",
" <td>20</td>\n",
" <td>98</td>\n",
" <td>96</td>\n",
" </tr>\n",
" <tr>\n",
" <th>44</th>\n",
" <td>41</td>\n",
" <td>18</td>\n",
" <td>14</td>\n",
" <td>31</td>\n",
" </tr>\n",
" <tr>\n",
" <th>45</th>\n",
" <td>84</td>\n",
" <td>13</td>\n",
" <td>62</td>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>46</th>\n",
" <td>13</td>\n",
" <td>40</td>\n",
" <td>77</td>\n",
" <td>60</td>\n",
" </tr>\n",
" <tr>\n",
" <th>47</th>\n",
" <td>70</td>\n",
" <td>18</td>\n",
" <td>84</td>\n",
" <td>26</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>97</td>\n",
" <td>22</td>\n",
" <td>24</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49</th>\n",
" <td>56</td>\n",
" <td>83</td>\n",
" <td>9</td>\n",
" <td>95</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" f1 f2 f3 label\n",
"0 97 70 23 81\n",
"1 60 40 73 7\n",
"2 60 88 87 67\n",
"3 42 25 81 100\n",
"4 45 30 69 72\n",
"5 16 100 70 14\n",
"6 25 76 32 70\n",
"7 2 29 46 65\n",
"8 71 33 11 79\n",
"9 98 16 76 9\n",
"10 0 78 61 34\n",
"11 78 43 45 87\n",
"12 95 78 6 34\n",
"13 14 44 95 27\n",
"14 32 31 90 58\n",
"15 72 15 16 59\n",
"16 5 72 31 36\n",
"17 72 30 94 55\n",
"18 55 19 91 74\n",
"19 9 20 10 34\n",
"20 3 6 25 49\n",
"21 63 61 86 55\n",
"22 25 21 0 85\n",
"23 80 66 73 51\n",
"24 96 46 35 58\n",
"25 7 4 89 25\n",
"26 92 11 77 59\n",
"27 38 94 19 46\n",
"28 34 24 94 70\n",
"29 100 91 46 76\n",
"30 43 10 35 78\n",
"31 15 24 57 6\n",
"32 51 47 47 55\n",
"33 83 5 84 40\n",
"34 100 22 26 72\n",
"35 60 83 80 92\n",
"36 28 39 82 17\n",
"37 56 20 94 85\n",
"38 72 56 63 54\n",
"39 15 60 30 72\n",
"40 41 21 86 54\n",
"41 85 7 50 87\n",
"42 48 13 69 93\n",
"43 75 20 98 96\n",
"44 41 18 14 31\n",
"45 84 13 62 6\n",
"46 13 40 77 60\n",
"47 70 18 84 26\n",
"48 97 22 24 34\n",
"49 56 83 9 95"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"X = df[['f1','f2','f3']]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"y = df['label']"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(33, 3)"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X_train.shape"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(17, 3)"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"X_test.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

1180
Tensors1D.ipynb Normal file

File diff suppressed because one or more lines are too long

330
Visualization.ipynb Normal file

File diff suppressed because one or more lines are too long