MOHAMMAD AZAR commited on
Commit ·
bb51481
1
Parent(s): 1b79125
Upload student_model1.ipynb (#2)
Browse files- Upload student_model1.ipynb (16b9b229920a6dd3242a4c536fa95cadbd09592c)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "94fb3237", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "id": "5f713cf6", "metadata": {}, "outputs": [], "source": [ "std_data=pd.read_csv(\"StudentsPerformance.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "a76812e9", "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>gender</th>\n", " <th>race/ethnicity</th>\n", " <th>parental level of education</th>\n", " <th>lunch</th>\n", " <th>test preparation course</th>\n", " <th>math score</th>\n", " <th>reading score</th>\n", " <th>writing score</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>female</td>\n", " <td>group B</td>\n", " <td>bachelor's degree</td>\n", " <td>standard</td>\n", " <td>none</td>\n", " <td>72</td>\n", " <td>72</td>\n", " <td>74</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>female</td>\n", " <td>group C</td>\n", " <td>some college</td>\n", " <td>standard</td>\n", " <td>completed</td>\n", " <td>69</td>\n", " <td>90</td>\n", " <td>88</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>female</td>\n", " <td>group B</td>\n", " <td>master's degree</td>\n", " <td>standard</td>\n", " <td>none</td>\n", " <td>90</td>\n", " <td>95</td>\n", " <td>93</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>male</td>\n", " <td>group A</td>\n", " <td>associate's degree</td>\n", " <td>free/reduced</td>\n", " <td>none</td>\n", " <td>47</td>\n", " <td>57</td>\n", " <td>44</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>male</td>\n", " <td>group C</td>\n", " <td>some college</td>\n", " <td>standard</td>\n", " <td>none</td>\n", " <td>76</td>\n", " <td>78</td>\n", " <td>75</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " gender race/ethnicity parental level of education lunch \\\n", "0 female group B bachelor's degree standard \n", "1 female group C some college standard \n", "2 female group B master's degree standard \n", "3 male group A associate's degree free/reduced \n", "4 male group C some college standard \n", "\n", " test preparation course math score reading score writing score \n", "0 none 72 72 74 \n", "1 completed 69 90 88 \n", "2 none 90 95 93 \n", "3 none 47 57 44 \n", "4 none 76 78 75 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "std_data.head()" ] }, { "cell_type": "code", "execution_count": 22, "id": "88fdf384", "metadata": {}, "outputs": [], "source": [ "std_features=['math score','reading_score','writing score']" ] }, { "cell_type": "code", "execution_count": 23, "id": "5a98b351", "metadata": {}, "outputs": [], "source": [ "X=std_data[std_features]" ] }, { "cell_type": "code", "execution_count": 24, "id": "68cb5c93", "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>math score</th>\n", " <th>reading_score</th>\n", " <th>writing score</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>72</td>\n", " <td>72</td>\n", " <td>74</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>69</td>\n", " <td>90</td>\n", " <td>88</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>90</td>\n", " <td>95</td>\n", " <td>93</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>47</td>\n", " <td>57</td>\n", " <td>44</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>76</td>\n", " <td>78</td>\n", " <td>75</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>995</th>\n", " <td>88</td>\n", " <td>99</td>\n", " <td>95</td>\n", " </tr>\n", " <tr>\n", " <th>996</th>\n", " <td>62</td>\n", " <td>55</td>\n", " <td>55</td>\n", " </tr>\n", " <tr>\n", " <th>997</th>\n", " <td>59</td>\n", " <td>71</td>\n", " <td>65</td>\n", " </tr>\n", " <tr>\n", " <th>998</th>\n", " <td>68</td>\n", " <td>78</td>\n", " <td>77</td>\n", " </tr>\n", " <tr>\n", " <th>999</th>\n", " <td>77</td>\n", " <td>86</td>\n", " <td>86</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>1000 rows × 3 columns</p>\n", "</div>" ], "text/plain": [ " math score reading_score writing score\n", "0 72 72 74\n", "1 69 90 88\n", "2 90 95 93\n", "3 47 57 44\n", "4 76 78 75\n", ".. ... ... ...\n", "995 88 99 95\n", "996 62 55 55\n", "997 59 71 65\n", "998 68 78 77\n", "999 77 86 86\n", "\n", "[1000 rows x 3 columns]" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X" ] }, { "cell_type": "code", "execution_count": 19, "id": "962e6183", "metadata": {}, "outputs": [], "source": [ "std_data.rename(columns = {'reading score':'reading_score'}, inplace = True)" ] }, { "cell_type": "code", "execution_count": 27, "id": "5da7ae54", "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>math score</th>\n", " <th>reading_score</th>\n", " <th>writing score</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>count</th>\n", " <td>1000.00000</td>\n", " <td>1000.000000</td>\n", " <td>1000.000000</td>\n", " </tr>\n", " <tr>\n", " <th>mean</th>\n", " <td>66.08900</td>\n", " <td>69.169000</td>\n", " <td>68.054000</td>\n", " </tr>\n", " <tr>\n", " <th>std</th>\n", " <td>15.16308</td>\n", " <td>14.600192</td>\n", " <td>15.195657</td>\n", " </tr>\n", " <tr>\n", " <th>min</th>\n", " <td>0.00000</td>\n", " <td>17.000000</td>\n", " <td>10.000000</td>\n", " </tr>\n", " <tr>\n", " <th>25%</th>\n", " <td>57.00000</td>\n", " <td>59.000000</td>\n", " <td>57.750000</td>\n", " </tr>\n", " <tr>\n", " <th>50%</th>\n", " <td>66.00000</td>\n", " <td>70.000000</td>\n", " <td>69.000000</td>\n", " </tr>\n", " <tr>\n", " <th>75%</th>\n", " <td>77.00000</td>\n", " <td>79.000000</td>\n", " <td>79.000000</td>\n", " </tr>\n", " <tr>\n", " <th>max</th>\n", " <td>100.00000</td>\n", " <td>100.000000</td>\n", " <td>100.000000</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " math score reading_score writing score\n", "count 1000.00000 1000.000000 1000.000000\n", "mean 66.08900 69.169000 68.054000\n", "std 15.16308 14.600192 15.195657\n", "min 0.00000 17.000000 10.000000\n", "25% 57.00000 59.000000 57.750000\n", "50% 66.00000 70.000000 69.000000\n", "75% 77.00000 79.000000 79.000000\n", "max 100.00000 100.000000 100.000000" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X.describe()" ] }, { "cell_type": "code", "execution_count": 25, "id": "7f074fee", "metadata": {}, "outputs": [], "source": [ "y=std_data.reading_score" ] }, { "cell_type": "code", "execution_count": 28, "id": "cc65b7cb", "metadata": {}, "outputs": [], "source": [ "from sklearn.tree import DecisionTreeRegressor" ] }, { "cell_type": "code", "execution_count": 30, "id": "80b78ccb", "metadata": {}, "outputs": [], "source": [ "std_model=DecisionTreeRegressor(random_state=1)" ] }, { "cell_type": "code", "execution_count": 31, "id": "b7a5fe43", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "DecisionTreeRegressor(random_state=1)" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "std_model" ] }, { "cell_type": "code", "execution_count": 32, "id": "10e72f85", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "DecisionTreeRegressor(random_state=1)" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "std_model.fit(X,y)" ] }, { "cell_type": "code", "execution_count": 35, "id": "33d20c6d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " math score reading_score writing score\n", "0 72 72 74\n", "1 69 90 88\n", "2 90 95 93\n", "3 47 57 44\n", "4 76 78 75\n", ".. ... ... ...\n", "995 88 99 95\n", "996 62 55 55\n", "997 59 71 65\n", "998 68 78 77\n", "999 77 86 86\n", "\n", "[1000 rows x 3 columns]\n" ] } ], "source": [ "print(X)" ] }, { "cell_type": "code", "execution_count": 37, "id": "e9f47dd4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[72. 90. 95. 57. 78.]\n" ] } ], "source": [ "print(std_model.predict(X.head()))" ] }, { "cell_type": "code", "execution_count": 39, "id": "297049c0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#model validating:\n", "from sklearn.metrics import mean_absolute_error\n", "\n", "reading_score = std_model.predict(X)\n", "mean_absolute_error(y,reading_score )" ] }, { "cell_type": "code", "execution_count": 41, "id": "ba83aa92", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "array([ 72., 90., 95., 57., 78., 83., 95., 43., 64., 60., 54.,\n", " 52., 81., 72., 53., 75., 89., 32., 42., 58., 69., 75.,\n", " 54., 73., 71., 74., 54., 69., 70., 70., 74., 65., 72.,\n", " 42., 87., 81., 81., 64., 90., 56., 61., 73., 58., 65.,\n", " 56., 54., 65., 71., 74., 84., 55., 69., 44., 78., 84.,\n", " 41., 85., 55., 59., 17., 74., 39., 61., 80., 58., 64.,\n", " 37., 72., 58., 64., 63., 55., 51., 57., 49., 41., 26.,\n", " 78., 74., 68., 49., 45., 47., 64., 39., 80., 83., 71.,\n", " 70., 86., 72., 34., 79., 45., 86., 81., 66., 72., 67.,\n", " 67., 67., 74., 91., 44., 86., 67., 100., 63., 76., 64.,\n", " 89., 55., 53., 58., 100., 77., 85., 82., 63., 69., 92.,\n", " 89., 93., 57., 80., 95., 68., 77., 82., 49., 84., 37.,\n", " 74., 81., 79., 55., 54., 55., 66., 61., 72., 62., 55.,\n", " 43., 73., 39., 84., 68., 75., 100., 67., 67., 70., 49.,\n", " 67., 89., 74., 60., 86., 62., 78., 88., 53., 53., 92.,\n", " 100., 51., 76., 83., 75., 73., 88., 86., 67., 51., 91.,\n", " 54., 77., 70., 100., 68., 64., 50., 69., 52., 67., 76.,\n", " 66., 52., 88., 65., 83., 64., 62., 84., 55., 69., 56.,\n", " 53., 79., 84., 81., 77., 69., 41., 71., 62., 80., 81.,\n", " 61., 79., 28., 62., 51., 91., 83., 86., 42., 77., 56.,\n", " 68., 85., 65., 80., 66., 56., 72., 50., 72., 95., 64.,\n", " 43., 86., 87., 82., 75., 66., 60., 52., 80., 68., 83.,\n", " 52., 51., 74., 76., 76., 70., 64., 60., 49., 83., 70.,\n", " 80., 52., 73., 73., 77., 75., 81., 79., 79., 50., 93.,\n", " 73., 42., 75., 72., 92., 76., 63., 49., 53., 70., 85.,\n", " 78., 92., 63., 86., 56., 52., 48., 79., 78., 46., 82.,\n", " 82., 89., 75., 76., 70., 73., 60., 73., 77., 62., 41.,\n", " 74., 46., 87., 78., 54., 84., 76., 75., 67., 87., 52.,\n", " 71., 57., 76., 60., 61., 67., 64., 66., 82., 72., 71.,\n", " 65., 79., 86., 81., 53., 46., 90., 61., 23., 75., 55.,\n", " 60., 37., 56., 78., 93., 68., 70., 51., 38., 55., 61.,\n", " 73., 76., 72., 73., 80., 61., 94., 74., 74., 65., 57.,\n", " 78., 58., 71., 72., 61., 66., 62., 90., 62., 84., 58.,\n", " 34., 60., 58., 58., 66., 64., 84., 77., 73., 74., 97.,\n", " 70., 43., 90., 95., 83., 64., 86., 100., 81., 49., 43.,\n", " 76., 73., 78., 64., 70., 67., 68., 67., 54., 74., 45.,\n", " 67., 89., 63., 59., 54., 43., 65., 99., 59., 73., 65.,\n", " 80., 57., 84., 71., 83., 66., 67., 72., 73., 74., 73.,\n", " 59., 56., 93., 58., 58., 85., 39., 67., 83., 71., 59.,\n", " 63., 66., 72., 56., 59., 66., 48., 68., 66., 56., 88.,\n", " 81., 81., 73., 83., 82., 74., 66., 81., 46., 73., 85.,\n", " 92., 77., 58., 61., 56., 89., 54., 100., 65., 58., 54.,\n", " 70., 90., 58., 87., 31., 67., 88., 74., 85., 69., 86.,\n", " 67., 90., 76., 62., 68., 64., 71., 71., 59., 68., 52.,\n", " 52., 74., 47., 75., 53., 82., 85., 64., 83., 88., 64.,\n", " 64., 48., 78., 69., 71., 79., 87., 61., 89., 59., 82.,\n", " 70., 59., 78., 92., 71., 50., 49., 61., 97., 87., 89.,\n", " 74., 78., 78., 49., 86., 58., 59., 52., 60., 61., 53.,\n", " 41., 74., 67., 54., 61., 88., 69., 83., 60., 66., 66.,\n", " 92., 69., 82., 77., 95., 63., 83., 100., 67., 67., 72.,\n", " 76., 90., 48., 62., 45., 39., 72., 67., 70., 66., 75.,\n", " 74., 90., 80., 51., 43., 100., 71., 48., 68., 75., 96.,\n", " 62., 66., 81., 55., 51., 91., 56., 61., 97., 79., 73.,\n", " 75., 77., 76., 73., 63., 64., 66., 57., 62., 68., 76.,\n", " 100., 79., 24., 54., 77., 82., 60., 29., 78., 57., 89.,\n", " 72., 84., 58., 64., 63., 60., 59., 90., 77., 93., 68.,\n", " 45., 78., 81., 73., 61., 63., 51., 96., 58., 97., 70.,\n", " 48., 57., 51., 64., 60., 74., 88., 84., 74., 80., 92.,\n", " 76., 74., 52., 88., 81., 79., 65., 81., 70., 62., 53.,\n", " 79., 56., 80., 86., 70., 79., 67., 67., 66., 60., 87.,\n", " 77., 66., 71., 69., 63., 60., 73., 85., 74., 72., 76.,\n", " 57., 78., 84., 77., 64., 78., 82., 75., 61., 72., 68.,\n", " 55., 40., 66., 99., 75., 78., 58., 90., 53., 76., 74.,\n", " 77., 63., 89., 82., 72., 78., 66., 81., 67., 84., 64.,\n", " 63., 72., 34., 59., 87., 61., 84., 85., 100., 81., 70.,\n", " 94., 78., 96., 76., 73., 72., 59., 90., 48., 43., 74.,\n", " 75., 51., 92., 39., 77., 46., 89., 47., 58., 57., 79.,\n", " 66., 71., 60., 73., 57., 84., 73., 55., 79., 75., 64.,\n", " 60., 84., 69., 72., 77., 90., 55., 95., 58., 68., 59.,\n", " 77., 72., 58., 81., 62., 63., 72., 75., 62., 71., 60.,\n", " 48., 73., 67., 78., 65., 58., 72., 44., 79., 85., 56.,\n", " 90., 85., 59., 81., 51., 79., 38., 65., 65., 62., 66.,\n", " 74., 84., 52., 68., 70., 84., 60., 55., 73., 80., 94.,\n", " 85., 76., 81., 74., 45., 75., 54., 31., 47., 64., 84.,\n", " 80., 86., 59., 70., 72., 91., 90., 90., 52., 87., 58.,\n", " 67., 68., 69., 86., 54., 60., 86., 60., 82., 50., 64.,\n", " 64., 82., 57., 77., 52., 58., 44., 77., 65., 85., 85.,\n", " 54., 72., 75., 67., 68., 85., 67., 64., 97., 68., 79.,\n", " 49., 73., 62., 86., 42., 71., 93., 82., 53., 42., 74.,\n", " 51., 58., 72., 84., 90., 62., 64., 82., 61., 72., 76.,\n", " 64., 70., 73., 46., 51., 76., 100., 72., 65., 51., 85.,\n", " 92., 67., 74., 62., 34., 29., 78., 54., 78., 84., 78.,\n", " 48., 100., 84., 77., 48., 84., 75., 64., 42., 84., 61.,\n", " 62., 61., 70., 100., 61., 77., 96., 70., 53., 66., 65.,\n", " 70., 64., 56., 61., 43., 56., 74., 57., 71., 75., 87.,\n", " 63., 57., 58., 81., 68., 66., 91., 66., 62., 68., 61.,\n", " 82., 58., 50., 75., 73., 77., 74., 52., 69., 57., 87.,\n", " 100., 63., 81., 58., 54., 100., 76., 57., 70., 68., 63.,\n", " 76., 84., 100., 72., 50., 65., 63., 82., 62., 65., 41.,\n", " 95., 24., 78., 85., 87., 75., 51., 59., 75., 45., 86.,\n", " 81., 82., 76., 72., 63., 99., 55., 71., 78., 86.])" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "reading_score" ] }, { "cell_type": "code", "execution_count": 40, "id": "240817a8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.04\n" ] } ], "source": [ "from sklearn.model_selection import train_test_split\n", "\n", "# split data into training and validation data, for both features and target\n", "# The split is based on a random number generator. Supplying a numeric value to\n", "# the random_state argument guarantees we get the same split every time we\n", "# run this script.\n", "train_X, val_X, train_y, val_y = train_test_split(X, y, random_state = 0)\n", "# Define model\n", "std_model = DecisionTreeRegressor()\n", "# Fit model\n", "std_model.fit(train_X, train_y)\n", "\n", "# get predicted prices on validation data\n", "read_score_predict = std_model.predict(val_X)\n", "print(mean_absolute_error(val_y, read_score_predict))" ] }, { "cell_type": "code", "execution_count": null, "id": "3dcd5b64", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "48b7e2de", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 42, "id": "0b193859", "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>math score</th>\n", " <th>reading_score</th>\n", " <th>writing score</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>253</th>\n", " <td>80</td>\n", " <td>80</td>\n", " <td>72</td>\n", " </tr>\n", " <tr>\n", " <th>667</th>\n", " <td>77</td>\n", " <td>85</td>\n", " <td>87</td>\n", " </tr>\n", " <tr>\n", " <th>85</th>\n", " <td>73</td>\n", " <td>80</td>\n", " <td>82</td>\n", " </tr>\n", " <tr>\n", " <th>969</th>\n", " <td>75</td>\n", " <td>84</td>\n", " <td>80</td>\n", " </tr>\n", " <tr>\n", " <th>75</th>\n", " <td>44</td>\n", " <td>41</td>\n", " <td>38</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>835</th>\n", " <td>60</td>\n", " <td>64</td>\n", " <td>74</td>\n", " </tr>\n", " <tr>\n", " <th>192</th>\n", " <td>62</td>\n", " <td>64</td>\n", " <td>66</td>\n", " </tr>\n", " <tr>\n", " <th>629</th>\n", " <td>44</td>\n", " <td>51</td>\n", " <td>55</td>\n", " </tr>\n", " <tr>\n", " <th>559</th>\n", " <td>73</td>\n", " <td>66</td>\n", " <td>62</td>\n", " </tr>\n", " <tr>\n", " <th>684</th>\n", " <td>62</td>\n", " <td>66</td>\n", " <td>68</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>750 rows × 3 columns</p>\n", "</div>" ], "text/plain": [ " math score reading_score writing score\n", "253 80 80 72\n", "667 77 85 87\n", "85 73 80 82\n", "969 75 84 80\n", "75 44 41 38\n", ".. ... ... ...\n", "835 60 64 74\n", "192 62 64 66\n", "629 44 51 55\n", "559 73 66 62\n", "684 62 66 68\n", "\n", "[750 rows x 3 columns]" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_X" ] }, { "cell_type": "code", "execution_count": 44, "id": "4358a31f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(750,)" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_y.shape" ] }, { "cell_type": "code", "execution_count": 45, "id": "67406471", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "253 80\n", "667 85\n", "85 80\n", "969 84\n", "75 41\n", " ..\n", "835 64\n", "192 64\n", "629 51\n", "559 66\n", "684 66\n", "Name: reading_score, Length: 750, dtype: int64" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "train_y" ] }, { "cell_type": "code", "execution_count": 47, "id": "26bb9459", "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>math score</th>\n", " <th>reading_score</th>\n", " <th>writing score</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>993</th>\n", " <td>62</td>\n", " <td>72</td>\n", " <td>74</td>\n", " </tr>\n", " <tr>\n", " <th>859</th>\n", " <td>87</td>\n", " <td>73</td>\n", " <td>72</td>\n", " </tr>\n", " <tr>\n", " <th>298</th>\n", " <td>40</td>\n", " <td>46</td>\n", " <td>50</td>\n", " </tr>\n", " <tr>\n", " <th>553</th>\n", " <td>77</td>\n", " <td>62</td>\n", " <td>64</td>\n", " </tr>\n", " <tr>\n", " <th>672</th>\n", " <td>69</td>\n", " <td>78</td>\n", " <td>76</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>462</th>\n", " <td>71</td>\n", " <td>70</td>\n", " <td>76</td>\n", " </tr>\n", " <tr>\n", " <th>356</th>\n", " <td>63</td>\n", " <td>61</td>\n", " <td>61</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>90</td>\n", " <td>95</td>\n", " <td>93</td>\n", " </tr>\n", " <tr>\n", " <th>478</th>\n", " <td>55</td>\n", " <td>64</td>\n", " <td>70</td>\n", " </tr>\n", " <tr>\n", " <th>695</th>\n", " <td>79</td>\n", " <td>89</td>\n", " <td>86</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>250 rows × 3 columns</p>\n", "</div>" ], "text/plain": [ " math score reading_score writing score\n", "993 62 72 74\n", "859 87 73 72\n", "298 40 46 50\n", "553 77 62 64\n", "672 69 78 76\n", ".. ... ... ...\n", "462 71 70 76\n", "356 63 61 61\n", "2 90 95 93\n", "478 55 64 70\n", "695 79 89 86\n", "\n", "[250 rows x 3 columns]" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val_X" ] }, { "cell_type": "code", "execution_count": 48, "id": "6262a739", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "993 72\n", "859 73\n", "298 46\n", "553 62\n", "672 78\n", " ..\n", "462 70\n", "356 61\n", "2 95\n", "478 64\n", "695 89\n", "Name: reading_score, Length: 250, dtype: int64" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val_y" ] }, { "cell_type": "code", "execution_count": 49, "id": "8328fdc3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(250,)" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val_y.shape" ] }, { "cell_type": "code", "execution_count": 50, "id": "c6663f05", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(250, 3)" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "val_X.shape" ] }, { "cell_type": "code", "execution_count": null, "id": "b52c954d", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.12" } }, "nbformat": 4, "nbformat_minor": 5}student_model1.ipynbAdded+1135