From f97613af86b533f1c466b3da687bdf6961e30252 Mon Sep 17 00:00:00 2001 From: Susumu Sakamoto Date: Wed, 29 Sep 2021 00:59:43 +0900 Subject: [PATCH] finish lab --- .ipynb_checkpoints/Untitled-checkpoint.ipynb | 576 ++++++++++++++++++- Untitled.ipynb | 576 ++++++++++++++++++- 2 files changed, 1132 insertions(+), 20 deletions(-) diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb index 7b5f0b3..f0e25cd 100644 --- a/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -41,17 +41,53 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "f56d81a7", + "cell_type": "markdown", + "id": "f1948f30", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "#### 1. State the null hypothesis\n", + "\n", + "Changing the power of the plasma beam has **NO** significant effect on the etching rate by the machine." + ] + }, + { + "cell_type": "markdown", + "id": "baf5be91", + "metadata": {}, + "source": [ + "#### 2. State the alternate hypothesis\n", + "\n", + "At least one change of the plasma beam power **has significant effect** on the etching rate by the machine." + ] + }, + { + "cell_type": "markdown", + "id": "6c924dae", + "metadata": {}, + "source": [ + "#### 3. What is the significance level\n", + "\n", + "Significance level = 0.05" + ] + }, + { + "cell_type": "markdown", + "id": "8c4a2b63", + "metadata": {}, + "source": [ + "#### 4. What are the degrees of freedom of model, error terms, and total DoF\n", + "\n", + "Degree of freedom of the model = 4. (each watts has 5 data set, so 5 - 1)\n", + "\n", + "error terms = i don't really know how to get this\n", + "\n", + "total DoF = 14 (total data is 15)" + ] }, { "cell_type": "code", "execution_count": null, - "id": "a891a030", + "id": "f5b616c7", "metadata": {}, "outputs": [], "source": [] @@ -69,18 +105,538 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "id": "f182b9b4", "metadata": {}, "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import statsmodels.api as sm\n", + "from statsmodels.formula.api import ols" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "65cd134c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
PowerEtching Rate
0160 W5.43
1180 W6.24
2200 W8.79
3160 W5.71
4180 W6.71
5200 W9.20
6160 W6.22
7180 W5.98
8200 W7.90
9160 W6.01
10180 W5.66
11200 W8.15
12160 W5.59
13180 W6.60
14200 W7.55
\n", + "
" + ], + "text/plain": [ + " Power Etching Rate\n", + "0 160 W 5.43\n", + "1 180 W 6.24\n", + "2 200 W 8.79\n", + "3 160 W 5.71\n", + "4 180 W 6.71\n", + "5 200 W 9.20\n", + "6 160 W 6.22\n", + "7 180 W 5.98\n", + "8 200 W 7.90\n", + "9 160 W 6.01\n", + "10 180 W 5.66\n", + "11 200 W 8.15\n", + "12 160 W 5.59\n", + "13 180 W 6.60\n", + "14 200 W 7.55" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data = pd.read_excel('files_for_lab/anova_lab_data.xlsx')\n", + "data" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "d8a62b83", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Etching Rate
count15.000000
mean6.782667
std1.228643
min5.430000
25%5.845000
50%6.240000
75%7.725000
max9.200000
\n", + "
" + ], + "text/plain": [ + " Etching Rate\n", + "count 15.000000\n", + "mean 6.782667\n", + "std 1.228643\n", + "min 5.430000\n", + "25% 5.845000\n", + "50% 6.240000\n", + "75% 7.725000\n", + "max 9.200000" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "90e09d58", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['Power ', 'Etching Rate'], dtype='object')" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "29424a6b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "160 W 5\n", + "200 W 5\n", + "180 W 5\n", + "Name: Power , dtype: int64" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data['Power '].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "aaa54da8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Etching Rate
Power
160 W5.792
180 W6.238
200 W8.318
\n", + "
" + ], + "text/plain": [ + " Etching Rate\n", + "Power \n", + "160 W 5.792\n", + "180 W 6.238\n", + "200 W 8.318" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.groupby('Power ').agg(np.mean)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "2d6a459e", + "metadata": {}, + "outputs": [], + "source": [ + "new_col = []\n", + "for col in data.columns:\n", + " new_col.append(col.replace(' ','_'))" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "5b886155", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['Power_', 'Etching_Rate'], dtype='object')" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.columns = new_col\n", + "data.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "883b070f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
dfsum_sqmean_sqFPR(>F)
C(Power_)2.018.1766539.08832736.8789550.000008
Residual12.02.9572400.246437NaNNaN
\n", + "
" + ], + "text/plain": [ + " df sum_sq mean_sq F PR(>F)\n", + "C(Power_) 2.0 18.176653 9.088327 36.878955 0.000008\n", + "Residual 12.0 2.957240 0.246437 NaN NaN" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import statsmodels.api as sm\n", + "from statsmodels.formula.api import ols\n", + "\n", + "model = ols('Etching_Rate ~ C(Power_)',data=data).fit()\n", + "sm.stats.anova_lm(model)" + ] + }, + { + "cell_type": "markdown", + "id": "b2e8ecde", + "metadata": {}, + "source": [ + "p-value(0.000008) is less than significant level (0.05), so the null hypothesis is rejected.\n", + "\n", + "There is at least one significant difference between the powers." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "782e50ff", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0f07b069", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb4f3f52", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "88069bc5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "27e00963", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "03805c46", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4338ed14", + "metadata": {}, + "outputs": [], "source": [] } ], "metadata": { "kernelspec": { - "display_name": "ironhack", + "display_name": "Python 3", "language": "python", - "name": "ironhack" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -92,7 +648,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.8" } }, "nbformat": 4, diff --git a/Untitled.ipynb b/Untitled.ipynb index 7b5f0b3..f0e25cd 100644 --- a/Untitled.ipynb +++ b/Untitled.ipynb @@ -41,17 +41,53 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "f56d81a7", + "cell_type": "markdown", + "id": "f1948f30", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "#### 1. State the null hypothesis\n", + "\n", + "Changing the power of the plasma beam has **NO** significant effect on the etching rate by the machine." + ] + }, + { + "cell_type": "markdown", + "id": "baf5be91", + "metadata": {}, + "source": [ + "#### 2. State the alternate hypothesis\n", + "\n", + "At least one change of the plasma beam power **has significant effect** on the etching rate by the machine." + ] + }, + { + "cell_type": "markdown", + "id": "6c924dae", + "metadata": {}, + "source": [ + "#### 3. What is the significance level\n", + "\n", + "Significance level = 0.05" + ] + }, + { + "cell_type": "markdown", + "id": "8c4a2b63", + "metadata": {}, + "source": [ + "#### 4. What are the degrees of freedom of model, error terms, and total DoF\n", + "\n", + "Degree of freedom of the model = 4. (each watts has 5 data set, so 5 - 1)\n", + "\n", + "error terms = i don't really know how to get this\n", + "\n", + "total DoF = 14 (total data is 15)" + ] }, { "cell_type": "code", "execution_count": null, - "id": "a891a030", + "id": "f5b616c7", "metadata": {}, "outputs": [], "source": [] @@ -69,18 +105,538 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "id": "f182b9b4", "metadata": {}, "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import statsmodels.api as sm\n", + "from statsmodels.formula.api import ols" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "65cd134c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
PowerEtching Rate
0160 W5.43
1180 W6.24
2200 W8.79
3160 W5.71
4180 W6.71
5200 W9.20
6160 W6.22
7180 W5.98
8200 W7.90
9160 W6.01
10180 W5.66
11200 W8.15
12160 W5.59
13180 W6.60
14200 W7.55
\n", + "
" + ], + "text/plain": [ + " Power Etching Rate\n", + "0 160 W 5.43\n", + "1 180 W 6.24\n", + "2 200 W 8.79\n", + "3 160 W 5.71\n", + "4 180 W 6.71\n", + "5 200 W 9.20\n", + "6 160 W 6.22\n", + "7 180 W 5.98\n", + "8 200 W 7.90\n", + "9 160 W 6.01\n", + "10 180 W 5.66\n", + "11 200 W 8.15\n", + "12 160 W 5.59\n", + "13 180 W 6.60\n", + "14 200 W 7.55" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data = pd.read_excel('files_for_lab/anova_lab_data.xlsx')\n", + "data" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "d8a62b83", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Etching Rate
count15.000000
mean6.782667
std1.228643
min5.430000
25%5.845000
50%6.240000
75%7.725000
max9.200000
\n", + "
" + ], + "text/plain": [ + " Etching Rate\n", + "count 15.000000\n", + "mean 6.782667\n", + "std 1.228643\n", + "min 5.430000\n", + "25% 5.845000\n", + "50% 6.240000\n", + "75% 7.725000\n", + "max 9.200000" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.describe()" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "90e09d58", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['Power ', 'Etching Rate'], dtype='object')" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "29424a6b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "160 W 5\n", + "200 W 5\n", + "180 W 5\n", + "Name: Power , dtype: int64" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data['Power '].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "id": "aaa54da8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Etching Rate
Power
160 W5.792
180 W6.238
200 W8.318
\n", + "
" + ], + "text/plain": [ + " Etching Rate\n", + "Power \n", + "160 W 5.792\n", + "180 W 6.238\n", + "200 W 8.318" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.groupby('Power ').agg(np.mean)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "2d6a459e", + "metadata": {}, + "outputs": [], + "source": [ + "new_col = []\n", + "for col in data.columns:\n", + " new_col.append(col.replace(' ','_'))" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "5b886155", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['Power_', 'Etching_Rate'], dtype='object')" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data.columns = new_col\n", + "data.columns" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "883b070f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
dfsum_sqmean_sqFPR(>F)
C(Power_)2.018.1766539.08832736.8789550.000008
Residual12.02.9572400.246437NaNNaN
\n", + "
" + ], + "text/plain": [ + " df sum_sq mean_sq F PR(>F)\n", + "C(Power_) 2.0 18.176653 9.088327 36.878955 0.000008\n", + "Residual 12.0 2.957240 0.246437 NaN NaN" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import statsmodels.api as sm\n", + "from statsmodels.formula.api import ols\n", + "\n", + "model = ols('Etching_Rate ~ C(Power_)',data=data).fit()\n", + "sm.stats.anova_lm(model)" + ] + }, + { + "cell_type": "markdown", + "id": "b2e8ecde", + "metadata": {}, + "source": [ + "p-value(0.000008) is less than significant level (0.05), so the null hypothesis is rejected.\n", + "\n", + "There is at least one significant difference between the powers." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "782e50ff", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0f07b069", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb4f3f52", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "88069bc5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "27e00963", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "03805c46", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4338ed14", + "metadata": {}, + "outputs": [], "source": [] } ], "metadata": { "kernelspec": { - "display_name": "ironhack", + "display_name": "Python 3", "language": "python", - "name": "ironhack" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -92,7 +648,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.8" } }, "nbformat": 4,