1 ์ถ”๋ก  ํ†ต๊ณ„ ๋ถ„์„

  • ๋ชจ์ง‘๋‹จ์—์„œ ์ถ”์ถœํ•œ ํ‘œ๋ณธ์˜ ์ •๋ณด๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ชจ์ง‘๋‹จ์˜ ํŠน์„ฑ์„ ์ถ”๋ก ํ•˜๋Š” ์ถ”๋ก  ํ†ต๊ณ„ํ•™

1.1 ๋‚ ์”จ ๋ฐ์ดํ„ฐ์˜ ์ƒ๊ด€๊ด€๊ณ„ ๋ถ„์„

  • ๋ณ€์ˆ˜๋“ค์˜ ์ƒ๊ด€์„ฑ์„ ๋ฐ”ํƒ•์œผ๋กœ ๋ณ€์ˆ˜๋ฅผ ์ •์ œํ•˜๋Š” ์ƒ๊ด€๊ด€๊ณ„ ๋ถ„์„
 - ํšŒ๊ท€๋ถ„์„์—์„œ ๋ณ€์ˆ˜ ๊ฐ„์˜ ์ธ๊ณผ๊ด€๊ณ„๋ฅผ ๋ถ„์„ํ•˜๊ธฐ ์ „์— ๋ณ€์ˆ˜ ๊ฐ„์˜ ๊ด€๋ จ์„ฑ์„ ๋ถ„์„ํ•˜๋Š” ์„ ํ–‰์ž๋ฃŒ(๊ฐ€์„ค๊ฒ€์ • ์ „ ์ˆ˜ํ–‰)๋กœ ์ด
 - ๋ณ€์ˆ˜ ๊ฐ„์˜ ๊ด€๋ จ์„ฑ์€ ์ƒ๊ด€๊ณ„์ˆ˜์ธ ํ”ผ์–ด์Šจ(Pearson) R ๊ณ„์ˆ˜๋ฅผ ์ด์šฉํ•ด ๊ด€๋ จ์„ฑ์˜ ์œ ๋ฌด์™€ ์ •๋„๋ฅผ ํŒŒ์•…
 - ์ƒ๊ด€๊ด€๊ณ„ ๋ถ„์„์˜ ์ฒ™๋„์ธ ํ”ผ์–ด์Šจ ์ƒ๊ด€๊ณ„์ˆ˜(Pearson correlation coefficient : r) R๊ณผ ์ƒ๊ด€๊ด€๊ณ„์˜ ์ •๋„

ํ”ผ์–ด์Šจ ์ƒ๊ด€๊ณ„์ˆ˜ R 
+-0.9์ด์ƒ > ๋งค์šฐ ๋†’์€ ์ƒ๊ด€๊ด€๊ณ„
+-0.9 ~ +-0.7 > ๋†’์€ ์ƒ๊ด€๊ด€๊ณ„
+-0.7 ~ +-0.4 > ๋‹ค์†Œ ๋†’์€ ์ƒ๊ด€๊ด€๊ณ„
+-0.4 ~ +-0.2 > ๋‚ฎ์€ ์ƒ๊ด€๊ด€๊ณ„
+-0.2๋ฏธ๋งŒ > ์ƒ๊ด€๊ด€๊ณ„ ์—†์Œ

1.1.1 ๋ฐ์ดํ„ฐ ํ˜ธ์ถœ

  • ๋‚ ์”จ ๊ด€๋ จ ๋ณ€์ˆ˜์— ๋”ฐ๋ผ์„œ ๋น„๊ฐ€ ๋‚ด๋ฆด์ง€์˜ ์—ฌ๋ถ€๋ฅผ ๊ธฐ๋กํ•œ ๋ฐ์ดํ„ฐ
  • ์ด ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„์„ํ•˜์—ฌ ์–ด๋–ค ๋‚ ์”จ ์กฐ๊ฑด์— ๋น„๊ฐ€ ๋‚ด๋ฆด์ง€ ๋˜๋Š” ๋‚ด๋ฆฌ์ง€ ์•Š์„์ง€์— ๋Œ€ํ•œ ํŒ๋‹จ ๊ธฐ์ค€์„ ๋ถ„์„ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • Date(์ธก์ •๋‚ ์งœ), MinTemp(์ตœ์ €๊ธฐ์˜จ), MaxTemp(์ตœ๊ณ ๊ธฐ์˜จ), Rainfall(๊ฐ•์ˆ˜๋Ÿ‰), Sunshine(ํ–‡๋น›)
  • WindGustDir(๋Œํ’๋ฐฉํ–ฅ), WidGustSpeed(๋Œํ’ ์†๋„), WindDir(๋ฐ”๋žŒ ๋ฐฉํ–ฅ), WindSpeed(๋ฐ”๋žŒ ์†๋„)
  • Humidity(์Šต๋„), Pressure(๊ธฐ์••), Cloud(๊ตฌ๋ฆ„), Temp(์˜จ๋„), RainToday(๊ธˆ์ผ ๋น„ ์—ฌ๋ถ€), RainTomorrow(๋‚ด์ผ ๋น„ ์—ฌ๋ถ€)
weather = read.csv("../data/weather.csv", stringsAsFactors = F)
# ๋ฐ์ดํ„ฐ ํ™•์ธ
weather
##           Date MinTemp MaxTemp Rainfall Sunshine WindGustDir WindGustSpeed
## 1   2014-11-01     8.0    24.3      0.0      6.3          NW            30
## 2   2014-11-02    14.0    26.9      3.6      9.7         ENE            39
## 3   2014-11-03    13.7    23.4      3.6      3.3          NW            85
## 4   2014-11-04    13.3    15.5     39.8      9.1          NW            54
## 5   2014-11-05     7.6    16.1      2.8     10.6         SSE            50
## 6   2014-11-06     6.2    16.9      0.0      8.2          SE            44
## 7   2014-11-07     6.1    18.2      0.2      8.4          SE            43
## 8   2014-11-08     8.3    17.0      0.0      4.6           E            41
## 9   2014-11-09     8.8    19.5      0.0      4.1           S            48
## 10  2014-11-10     8.4    22.8     16.2      7.7           E            31
## 11  2014-11-11     9.1    25.2      0.0     11.9           N            30
## 12  2014-11-12     8.5    27.3      0.2     12.5           E            41
## 13  2014-11-13    10.1    27.9      0.0     13.0         WNW            30
## 14  2014-11-14    12.1    30.9      0.0     12.4          NW            44
## 15  2014-11-15    10.1    31.2      0.0     13.1          NW            41
## 16  2014-11-16    12.4    32.1      0.0     11.1           E            46
## 17  2014-11-17    13.8    31.2      0.0      8.4         ESE            44
## 18  2014-11-18    11.7    30.0      1.2     10.1           S            52
## 19  2014-11-19    12.4    32.3      0.6     13.0           E            39
## 20  2014-11-20    15.6    33.4      0.0     10.4          NE            33
## 21  2014-11-21    15.3    33.4      0.0      9.5         WNW            59
## 22  2014-11-22    16.4    19.4      0.4      0.0           E            26
## 23  2014-11-23    12.8    18.5     25.8      0.6         ESE            28
## 24  2014-11-24    12.0    24.3      0.4      7.5         NNE            26
## 25  2014-11-25    15.4    28.4      0.0      8.1         ENE            33
## 26  2014-11-26    15.6    26.9      0.0      8.9           E            41
## 27  2014-11-27    13.3    22.2      0.2      2.3         ENE            39
## 28  2014-11-28    12.9    28.0      0.0     10.7           S            52
## 29  2014-11-29    15.1    24.3      0.0      0.4          SE            39
## 30  2014-11-30    13.6    24.1      0.4      0.5         NNW            30
## 31  2014-12-01    15.1    20.4     22.6      0.2         SSE            41
## 32  2014-12-02    11.6    26.3      4.2     12.0         NNE            41
## 33  2014-12-03    16.6    24.2      0.2      4.7          NW            50
## 34  2014-12-04    13.3    26.5      6.6     11.8          NW            50
## 35  2014-12-05    14.5    21.8      0.0      9.8         ENE            43
## 36  2014-12-06    16.3    26.8      0.0      6.3         ENE            39
## 37  2014-12-07    17.2    25.8      0.0      8.8          SW            41
## 38  2014-12-08    16.5    28.2      4.0      8.8          NE            39
## 39  2014-12-09    15.0    29.4      0.0     11.1          NW            43
## 40  2014-12-10    14.9    24.8      0.0     10.0         NNW            35
## 41  2014-12-11    11.8    18.5      0.6      2.3         ENE            35
## 42  2014-12-12    11.7    21.5      0.0      7.3         ENE            41
## 43  2014-12-13     9.6    20.3      0.0      3.6          SE            39
## 44  2014-12-14     8.9    27.1      0.0     12.7           E            35
## 45  2014-12-15    10.1    29.9      0.0      8.8           E            41
## 46  2014-12-16    15.5    21.1      5.4      0.9           S            31
## 47  2014-12-17    10.8    21.7      1.4     10.6         ESE            48
## 48  2014-12-18     7.5    20.9      0.0      8.7         ENE            39
## 49  2014-12-19    12.8    21.0      0.0      0.8          NE            22
## 50  2014-12-20    12.6    23.1      3.4      2.3         NNW            30
## 51  2014-12-21    14.8    29.5      6.4      8.1           N            41
## 52  2014-12-22    19.9    22.0     11.0      5.9         NNW            76
## 53  2014-12-23     9.2    20.4     17.4     10.2         ENE            39
## 54  2014-12-24    12.4    24.4      0.0     12.1          NW            44
## 55  2014-12-25    11.3    21.7      3.4      5.6           E            41
## 56  2014-12-26     9.8    26.3      0.0     13.0         NNW            41
## 57  2014-12-27    14.3    26.7      0.0      7.1         NNW            65
## 58  2014-12-28    15.1    28.3     14.4     13.2         NNW            28
## 59  2014-12-29    14.4    31.6      0.0     13.6         NNW            30
## 60  2014-12-30    15.4    35.0      0.0     13.0           E            39
## 61  2014-12-31    13.8    33.5      0.0     13.6          NE            31
## 62  2015-01-01    13.6    34.2      0.0     12.8         NNE            35
## 63  2015-01-02    14.3    35.0      0.0     10.5         ESE            41
## 64  2015-01-03    15.9    23.4      0.0      2.2         ESE            50
## 65  2015-01-04    16.7    25.3      0.0     12.5         ESE            46
## 66  2015-01-05    12.1    27.5      0.0     11.7          NE            35
## 67  2015-01-06    14.3    34.1      0.0     10.5         ENE            39
## 68  2015-01-07    16.5    33.9      0.0     12.6         ENE            39
## 69  2015-01-08    16.5    30.3      0.0      8.1           E            46
## 70  2015-01-09    17.5    29.9      0.0      8.8           E            43
## 71  2015-01-10    14.7    34.2      0.0     12.8          NE            33
## 72  2015-01-11    17.5    35.8      0.0     13.3         SSE            57
## 73  2015-01-12    20.9    35.7      0.0      6.9          SW            50
## 74  2015-01-13    17.0    33.8      2.0     13.5         WNW            52
## 75  2015-01-14    16.0    22.8      0.0      6.0           E            50
## 76  2015-01-15    15.4    33.8      0.0     11.1           W            35
## 77  2015-01-16    17.9    33.2      0.0      8.4           N            59
## 78  2015-01-17    15.2    25.1      4.8     11.6           E            46
## 79  2015-01-18    15.1    20.4      0.0      0.1         ESE            39
## 80  2015-01-19    15.3    19.6     18.8      0.0          NE            33
## 81  2015-01-20    17.2    24.7     12.2      8.1          NW            50
## 82  2015-01-21    15.9    19.9      0.8      1.6           E            48
## 83  2015-01-22    10.0    22.5      0.0     11.6           E            33
## 84  2015-01-23     9.9    24.4      0.0     10.8          NE            28
## 85  2015-01-24    10.3    27.8      0.0      9.9         ENE            35
## 86  2015-01-25    15.4    25.7      0.0      8.2           E            41
## 87  2015-01-26    12.7    28.8      0.0      9.0         NNE            28
## 88  2015-01-27    13.2    31.3      0.0     11.6         WSW            46
## 89  2015-01-28    15.3    33.2      0.0     13.2         NNW            44
## 90  2015-01-29    17.9    33.9      0.0     11.8         ENE            46
## 91  2015-01-30    18.0    34.9      0.0      9.9          NW            69
## 92  2015-01-31    17.6    27.8      5.2      3.6         ESE            39
## 93  2015-02-01    16.0    23.8      2.2      6.2         SSE            30
## 94  2015-02-02    14.9    28.8      0.0      8.1         NNE            30
## 95  2015-02-03    17.1    29.6      0.0      9.2           E            48
## 96  2015-02-04    18.2    22.6      1.8      0.0         ENE            33
## 97  2015-02-05    16.8    22.8      9.0      0.3         ESE            30
## 98  2015-02-06    13.6    27.4      1.0      8.0           W            52
## 99  2015-02-07    14.5    24.2      0.0      5.9         SSW            61
## 100 2015-02-08    12.4    19.9     16.2      5.6         ENE            41
## 101 2015-02-09    10.4    20.9      0.0      8.9         SSE            33
## 102 2015-02-10     9.1    23.1      0.0      9.6         ENE            41
## 103 2015-02-11     8.9    26.0      0.0     10.7          NE            31
## 104 2015-02-12    14.5    24.2      4.4      5.9           W            48
## 105 2015-02-13    12.6    18.2     11.0      0.4         ENE            30
## 106 2015-02-14     8.6    24.2      0.2     12.7           E            33
## 107 2015-02-15    10.8    25.2      0.0     12.6         ENE            35
## 108 2015-02-16    11.2    26.1      0.0     12.6         ENE            39
## 109 2015-02-17    12.1    24.1      0.0     10.2         ENE            46
## 110 2015-02-18    10.8    25.8      0.0     11.7           E            31
## 111 2015-02-19    11.4    27.1      0.0     12.1          NE            33
## 112 2015-02-20    12.0    28.9      0.0      8.2         ESE            39
## 113 2015-02-21    16.3    24.8      1.8      3.8           S            50
## 114 2015-02-22    12.7    28.6      6.6      8.6           W            50
## 115 2015-02-23    12.7    25.1      0.0     12.4          NW            46
## 116 2015-02-24    12.0    23.8      0.0     12.4          NW            44
## 117 2015-02-25    11.5    25.9      0.0     10.2         ENE            44
## 118 2015-02-26    13.0    28.2      0.0     11.6          NW            44
## 119 2015-02-27    11.7    27.6      0.0      8.1           W            48
## 120 2015-02-28    14.8    17.3      0.0      0.8         SSE            48
## 121 2015-03-01     7.7    18.4     10.4     12.0           S            48
## 122 2015-03-02     4.4    21.8      0.0     12.1           S            35
## 123 2015-03-03     7.4    24.4      0.0     11.6           E            35
## 124 2015-03-04     8.3    27.3      0.0     10.1           E            35
## 125 2015-03-05    10.1    28.2      0.0      7.3         ESE            39
## 126 2015-03-06    12.0    27.6      0.0     11.0           E            46
## 127 2015-03-07    12.9    31.8      0.0     11.3         WSW            41
## 128 2015-03-08    10.8    29.2      0.0      7.5           E            50
## 129 2015-03-09     9.5    27.4      3.0     11.5         NNW            24
## 130 2015-03-10    12.1    27.8      0.0     11.5           E            41
## 131 2015-03-11    12.5    31.7      0.0     11.2         WNW            24
## 132 2015-03-12    13.9    34.7      0.0      8.5         SSW            46
## 133 2015-03-13    13.3    31.7      0.2     11.0         WNW            44
## 134 2015-03-14    13.2    33.1      0.0      9.7         ENE            39
## 135 2015-03-15    12.3    33.8      0.0     11.3           W            22
## 136 2015-03-16    13.8    35.2      0.0     11.2          SE            48
## 137 2015-03-17    11.3    32.3      0.0     11.4          NE            28
## 138 2015-03-18    11.7    30.2      0.0     11.2          NE            33
## 139 2015-03-19    12.5    29.9      0.0     10.7          NW            43
## 140 2015-03-20    15.1    26.2      0.0      9.8          NE            31
## 141 2015-03-21    11.5    29.3      0.0      8.0          NW            46
## 142 2015-03-22    13.0    14.8      0.0      0.0          SE            30
## 143 2015-03-23    11.6    19.6      0.0      1.6           E            33
## 144 2015-03-24    12.8    24.9      0.0      6.2         ENE            30
## 145 2015-03-25    15.5    22.4      0.6      1.9          NW            28
## 146 2015-03-26    13.1    17.4      6.4      0.0         NNW            43
## 147 2015-03-27    12.6    20.2     19.8      9.1           W            46
## 148 2015-03-28     4.4    18.3      0.0      9.6           N            33
## 149 2015-03-29     4.4    18.2      0.0     11.0           W            31
## 150 2015-03-30     7.1    18.5      0.0     10.0          NW            57
## 151 2015-03-31     4.2    18.9      0.0     10.8         WNW            50
## 152 2015-04-01     9.6    18.8      0.0     10.0         WNW            57
## 153 2015-04-02     3.5    21.8      0.0     10.3         NNW            22
## 154 2015-04-03     5.3    23.3      0.0      5.6         NNW            83
## 155 2015-04-04     7.0    14.3      2.6      9.7         WNW            63
## 156 2015-04-05     0.4    18.9      0.0      9.6           N            22
## 157 2015-04-06     3.2    21.4      0.0     10.6           E            26
## 158 2015-04-07     5.9    21.8      0.0      9.3           E            35
## 159 2015-04-08     8.1    20.5      0.0      7.8         ENE            31
## 160 2015-04-09     6.9    18.9      0.0      4.1         ESE            39
## 161 2015-04-10     5.6    19.5      0.0      6.8          SW            17
## 162 2015-04-11     7.2    22.9      0.0      9.5           E            26
## 163 2015-04-12     7.1    23.4      0.0     10.2         ESE            39
## 164 2015-04-13     6.1    24.1      0.0      6.1         WNW            35
## 165 2015-04-14     7.1    19.8      2.0      7.7           W            39
## 166 2015-04-15     5.6    18.0      5.2      9.3           S            31
## 167 2015-04-16     5.4    20.7      0.0     10.8         SSE            28
## 168 2015-04-17     6.3    19.3      0.0     10.6           S            31
## 169 2015-04-18     5.3    21.0      0.0      6.3         WNW            26
## 170 2015-04-19     7.9    19.7      0.0      8.3         ESE            48
## 171 2015-04-20     8.4    16.1      0.0      4.9          SE            35
## 172 2015-04-21     8.1    18.7      0.0      7.1         ESE            33
## 173 2015-04-22     2.4    20.6      0.0     10.1           E            30
## 174 2015-04-23     5.6    18.9      0.0      8.0          SE            33
## 175 2015-04-24     7.5    19.0      0.0      6.8         ENE            26
## 176 2015-04-25     2.5    21.2      0.0      7.9          NE            28
## 177 2015-04-26     5.0    20.9      0.0      8.9         WNW            22
## 178 2015-04-27     3.8    21.7      0.2      6.5          NW            44
## 179 2015-04-28     7.9    18.7      0.0      5.8          NW            59
## 180 2015-04-29     4.3    11.3      7.2      5.6           W            57
## 181 2015-04-30    -2.1    13.8      0.2      9.5         NNW            22
## 182 2015-05-01    -1.8    14.8      0.0      7.0           N            28
## 183 2015-05-02     3.8    13.8      0.0      0.8         WNW            31
## 184 2015-05-03     2.1    17.3      0.0      9.2           W            43
## 185 2015-05-04     0.5    17.1      0.0      9.4          NW            31
## 186 2015-05-05    -0.9    16.7      0.0      9.3         NNW            30
## 187 2015-05-06     0.4    19.0      0.0      8.3          NW            39
## 188 2015-05-07     7.5    16.8      0.0      3.0          NW            41
## 189 2015-05-08     8.3    17.6      0.0      9.4         WNW            43
## 190 2015-05-09    -0.2    18.1      0.0      9.4          NW            24
## 191 2015-05-10     0.1    21.0      0.0      9.2         NNW            17
## 192 2015-05-11     1.5    20.9      0.0      9.3          NW            20
## 193 2015-05-12     8.3    17.4      0.0      1.6           E            20
## 194 2015-05-13     9.4    19.2      0.0      7.7        <NA>            24
## 195 2015-05-14     1.3    19.0      0.0      9.4         NNW            30
## 196 2015-05-15     2.2    18.6      0.0      9.2         NNW            31
## 197 2015-05-16    -0.4    17.9      0.0      8.7          NW            33
## 198 2015-05-17     4.5    16.0      1.8      4.3          NW            35
## 199 2015-05-18     7.9    12.3      1.0      1.7          NW            52
## 200 2015-05-19     4.3    14.1      0.8      8.8          NW            41
## 201 2015-05-20    -2.7    18.1      0.0      9.3           W            52
## 202 2015-05-21     0.3    17.0      0.0      5.6         WNW            31
## 203 2015-05-22     3.8    17.4      0.0      7.3           E            24
## 204 2015-05-23     2.4    14.7      0.0      9.2         ESE            20
## 205 2015-05-24     1.2    14.8      0.0      6.7          SE            17
## 206 2015-05-25     1.2    14.5      0.0      8.9          SE            17
## 207 2015-05-26    -0.3    17.5      0.0      8.4           W            39
## 208 2015-05-27     4.7    18.5      3.8      5.1         ESE            22
## 209 2015-05-28     4.9    18.1      5.2      8.5         NNW            22
## 210 2015-05-29     1.4    16.8      0.0      8.2          NW            20
## 211 2015-05-30     2.2    17.5      0.2      8.5          NW            20
## 212 2015-05-31    -0.1    18.0      0.0      8.6        <NA>            NA
## 213 2015-06-01    -0.9    18.5      0.0      8.9           E            22
## 214 2015-06-02     0.6    14.0      0.0      2.7          NE            17
## 215 2015-06-03     4.6    15.7      0.0      0.6         NNE            15
## 216 2015-06-04     9.8    14.4      0.8      0.0         ESE            20
## 217 2015-06-05    10.6    15.1      3.8      2.6         SSE            41
## 218 2015-06-06     7.8    15.1      0.0      2.7           S            31
## 219 2015-06-07     4.4    16.7      0.0      9.0           S            22
## 220 2015-06-08    -0.2    15.5      0.0      9.0          NE            28
## 221 2015-06-09     4.3    14.5      0.0      3.0           E            30
## 222 2015-06-10     7.4    16.3      0.0       NA         NNE            30
## 223 2015-06-11     8.6    13.7      6.2      0.0          NW            31
## 224 2015-06-12    10.2    15.0      4.8      0.5          NW            46
## 225 2015-06-13     7.3    16.4      0.2      8.5          NW            43
## 226 2015-06-14     8.7    13.0      0.6      7.1         WNW            54
## 227 2015-06-15     1.0    11.8      0.0      7.2           S            48
## 228 2015-06-16     2.1    14.7      0.0      8.2           S            43
## 229 2015-06-17     6.4    16.9      0.0      5.9         SSW            26
## 230 2015-06-18     5.4    15.5      0.0      5.8         NNE            20
## 231 2015-06-19     0.4    15.5      0.0      4.7           N            13
## 232 2015-06-20     4.0    15.9      0.0      2.0         NNW            17
## 233 2015-06-21     8.4    11.7      4.8      0.0           W            26
## 234 2015-06-22     0.4    13.9      0.6      7.7         WNW            41
## 235 2015-06-23     4.2    14.0      0.0      7.6          NW            33
## 236 2015-06-24     0.9    12.9      0.0      6.8          NW            24
## 237 2015-06-25     0.8    13.0      0.0      4.1         WNW            41
## 238 2015-06-26     4.3    12.6      0.0      9.0          NW            46
## 239 2015-06-27     6.3    11.8      0.0      6.5         WNW            63
## 240 2015-06-28     3.5    14.3      0.0      8.9         NNW            35
## 241 2015-06-29    -1.5    14.8      0.0      8.0          NW            15
## 242 2015-06-30     1.2    16.0      0.0      6.1         NNW            31
## 243 2015-07-01     0.5    15.4      0.0      6.4           W            70
## 244 2015-07-02     5.3    11.7      2.0      5.6          NW            78
## 245 2015-07-03     6.6    13.1      0.2      8.2         WNW            61
## 246 2015-07-04    -1.6    11.5      0.0      8.9           N            31
## 247 2015-07-05    -3.1    12.0      0.0      3.9         ESE            35
## 248 2015-07-06    -0.1    14.2      0.0      7.0           W            13
## 249 2015-07-07    -0.6    14.0      0.0      7.1          NW            41
## 250 2015-07-08     3.0    11.1      0.8      0.2           W            35
## 251 2015-07-09     2.9     9.5     16.8      6.5          NW            35
## 252 2015-07-10    -1.3     8.8      0.0      2.8         WNW            39
## 253 2015-07-11     1.8     8.7      0.0      1.2          NW            65
## 254 2015-07-12     2.9     8.4      1.6      7.7          NW            59
## 255 2015-07-13    -2.6    11.1      0.2      6.5           N            20
## 256 2015-07-14     0.5    11.0      0.0      0.9         NNW            31
## 257 2015-07-15     2.7    16.5      0.0      8.9         NNW            41
## 258 2015-07-16    -1.7    13.6      0.0      5.2         NNW            28
## 259 2015-07-17    -0.9    12.8      0.2      1.9           N            17
## 260 2015-07-18    -1.8    11.5      0.0      4.7         NNW            41
## 261 2015-07-19     1.3    10.6      0.0      5.6          NW            46
## 262 2015-07-20     2.4    11.6      1.2      8.1          NW            35
## 263 2015-07-21    -1.1    11.0      0.2      0.0         WNW            41
## 264 2015-07-22     2.3    11.6     19.2      7.5         WNW            54
## 265 2015-07-23    -2.2    11.6      0.0      9.2           S            39
## 266 2015-07-24    -3.5    11.2      0.0      7.7         ESE            26
## 267 2015-07-25    -1.0    12.2      0.0      8.4         ESE            30
## 268 2015-07-26    -2.1    12.9      0.0      8.1           S            31
## 269 2015-07-27    -2.0    11.3      0.2      5.9         WNW            33
## 270 2015-07-28    -2.3     9.7      0.0      1.9         SSE            28
## 271 2015-07-29    -1.6    10.7      1.4      9.1           S            59
## 272 2015-07-30     0.8    12.2      0.0      8.6        <NA>            NA
## 273 2015-07-31    -2.8    12.2      0.0      8.7         NNW            31
## 274 2015-08-01    -2.8    14.1      0.0      6.8         WNW            48
## 275 2015-08-02     3.0     9.7      1.0      0.7           W            65
## 276 2015-08-03     4.4    11.5      6.6      9.3         WNW            57
## 277 2015-08-04     2.3    12.8      0.0      9.6         WNW            35
## 278 2015-08-05    -2.0    12.3      0.0      5.8           W            31
## 279 2015-08-06    -1.9    10.9      0.0      4.2           S            50
## 280 2015-08-07     4.8    14.1      4.0      8.3           S            48
## 281 2015-08-08    -0.6    11.1      0.0      5.0         NNW            41
## 282 2015-08-09     3.1    12.5      1.2      7.2           N            43
## 283 2015-08-10    -2.9     9.6      0.0      7.3          NW            43
## 284 2015-08-11    -3.5     7.6      0.4      4.7          NW            50
## 285 2015-08-12    -0.3     9.3      0.4      9.9           N            39
## 286 2015-08-13     0.1    10.4      0.0      7.9         WNW            59
## 287 2015-08-14     2.3    12.2      0.0      9.8         WNW            44
## 288 2015-08-15     2.1    10.7      0.0      9.4          NW            59
## 289 2015-08-16     4.6    14.7      0.0      8.4         WNW            52
## 290 2015-08-17     3.7    14.2      0.0     10.0         NNW            46
## 291 2015-08-18    -1.3    11.6      0.0     10.4           N            30
## 292 2015-08-19    -3.4    12.5      0.0      6.8         SSE            48
## 293 2015-08-20    -5.3    13.1      0.0      7.9          NW            33
## 294 2015-08-21     0.0    14.0      0.0      4.7         WNW            39
## 295 2015-08-22     2.4    14.1      0.0      1.8          NW            46
## 296 2015-08-23    -0.6    12.2      0.0      7.0           S            59
## 297 2015-08-24     2.3    11.6      0.0      9.5           S            54
## 298 2015-08-25    -3.7    14.4      0.0     10.4         NNW            22
## 299 2015-08-26    -0.9    14.2      0.0      7.8         WNW            31
## 300 2015-08-27    -1.5    17.3      0.0      9.0          NW            48
## 301 2015-08-28    -3.3    15.1      0.0       NA         SSW            30
## 302 2015-08-29    -0.1    14.7      0.0      9.9         ENE            30
## 303 2015-08-30    -0.2    16.2      0.0      5.9           E            28
## 304 2015-08-31     0.5    16.3      0.0      4.1         NNW            39
## 305 2015-09-01     6.1    17.2      4.0      2.4          NW            59
## 306 2015-09-02     4.1    14.8      7.4     10.8          NW            46
## 307 2015-09-03     0.1    16.7      0.0     10.2         WNW            28
## 308 2015-09-04     3.2    12.1      0.0      3.9         ESE            41
## 309 2015-09-05     5.4    11.3      0.2      0.6         ENE            35
## 310 2015-09-06     5.8    12.4      0.0      0.0          SE            26
## 311 2015-09-07     6.3    16.1      0.0      2.9           S            35
## 312 2015-09-08    -0.9    16.7      0.0      8.6          NW            35
## 313 2015-09-09     0.2    15.5      1.0      9.4          SE            31
## 314 2015-09-10    -3.7    14.7      0.0     10.9         SSE            43
## 315 2015-09-11    -2.7    15.2      0.0      9.7           N            30
## 316 2015-09-12    -2.5    16.6      0.0      9.9          NW            31
## 317 2015-09-13    -0.5    21.6      0.0      9.9          NW            48
## 318 2015-09-14     9.0    25.5      0.0     10.2          NW            50
## 319 2015-09-15    13.1    19.4      9.8      6.0         NNW            67
## 320 2015-09-16     8.7    19.7      1.6      8.0          NW            98
## 321 2015-09-17     3.9    13.2      3.4     11.0         WNW            65
## 322 2015-09-18     0.7    14.1      0.0      9.0         ENE            20
## 323 2015-09-19     1.1    18.0      0.0      8.6         NNW            39
## 324 2015-09-20     5.1    23.3      0.0     10.3          NW            44
## 325 2015-09-21     7.5    23.3      0.0     10.9         WNW            65
## 326 2015-09-22     4.7    19.5      0.0     11.0         NNW            46
## 327 2015-09-23     3.2    21.9      0.0      5.2          NW            80
## 328 2015-09-24     7.8    16.2     17.4      7.9          NW            50
## 329 2015-09-25     2.4    17.3      0.0     11.3           E            31
## 330 2015-09-26     3.2    18.7      0.0     11.1           N            31
## 331 2015-09-27     2.5    20.9      0.0     10.6         NNW            44
## 332 2015-09-28     6.5    25.7      0.0     10.5         NNW            50
## 333 2015-09-29    14.4    24.3      0.0     11.1         WNW            52
## 334 2015-09-30     4.9    18.9      0.0      9.4          NW            44
## 335 2015-10-01     2.3    16.8      0.0     11.4           N            41
## 336 2015-10-02     1.4    20.6      0.0     11.1           N            46
## 337 2015-10-03     5.6    27.6      0.0     11.0          NW            46
## 338 2015-10-04    16.8    28.9      0.0     10.8         NNW            70
## 339 2015-10-05    14.4    20.7      7.6      4.9         NNW            33
## 340 2015-10-06    10.3    21.3      3.0      6.7         NNW            43
## 341 2015-10-07    11.2    18.0      0.0      8.4           W            65
## 342 2015-10-08     0.3    16.0      8.2     11.8          NW            57
## 343 2015-10-09     0.5    17.9      0.0     11.5           N            44
## 344 2015-10-10     0.5    20.0      0.0     11.5         NNW            31
## 345 2015-10-11     4.6    22.0      0.0     11.0           N            41
## 346 2015-10-12     8.2    22.4      0.0     11.2          NW            31
## 347 2015-10-13     4.5    23.9      0.0     11.7          NW            30
## 348 2015-10-14     6.7    26.1      0.0      7.5         SSW            70
## 349 2015-10-15    11.9    21.1     13.2       NA          NW            41
## 350 2015-10-16     9.2    19.6      0.6     10.4         ENE            31
## 351 2015-10-17     4.4    21.0      0.0     12.2          NW            28
## 352 2015-10-18     5.0    24.1      0.0     12.0         NNW            52
## 353 2015-10-19     6.7    24.7      0.0      8.6          NW            43
## 354 2015-10-20     8.3    28.5      0.0      9.8          NW            46
## 355 2015-10-21    11.3    27.4      0.2     12.1          NW            52
## 356 2015-10-22     9.0    20.6      0.0      6.2         ENE            39
## 357 2015-10-23     3.4    15.0      0.8     11.7           S            70
## 358 2015-10-24     3.2    18.0      0.0     12.2         SSE            48
## 359 2015-10-25     0.9    20.7      0.0      8.4         NNW            39
## 360 2015-10-26     3.3    25.5      0.0     10.8           N            43
## 361 2015-10-27     7.9    26.1      0.0      3.5         NNW            43
## 362 2015-10-28     9.0    30.7      0.0     12.1         NNW            76
## 363 2015-10-29     7.1    28.4      0.0     12.7           N            48
## 364 2015-10-30    12.5    19.9      0.0      5.3         ESE            43
## 365 2015-10-31    12.5    26.9      0.0      7.1          NW            46
## 366 2015-11-01    12.3    30.2      0.0     12.6          NW            78
##     WindDir WindSpeed Humidity Pressure Cloud Temp RainToday RainTomorrow
## 1        NW        20       29   1015.0     7 23.6        No          Yes
## 2         W        17       36   1008.4     3 25.7       Yes          Yes
## 3       NNE         6       69   1007.2     7 20.2       Yes          Yes
## 4         W        24       56   1007.0     7 14.1       Yes          Yes
## 5       ESE        28       49   1018.5     7 15.4       Yes           No
## 6         E        24       57   1021.7     5 14.8        No           No
## 7       ESE        26       47   1022.2     6 17.3        No           No
## 8         E        24       57   1024.2     7 15.5        No           No
## 9       ENE        17       48   1022.7     7 18.9        No          Yes
## 10      ESE         6       32   1020.7     1 21.7       Yes           No
## 11       NW         9       34   1021.1     2 24.0        No           No
## 12       NW        15       35   1019.9     3 26.0        No           No
## 13       NW         7       29   1017.1     1 27.1        No           No
## 14        W        20       20   1013.1     4 30.7        No           No
## 15        W        20       16   1013.7     1 30.4        No           No
## 16      WSW         9       22   1012.8     3 30.7        No           No
## 17        W        19       23   1009.8     6 29.8        No          Yes
## 18       NE        11       26   1013.0     5 28.6       Yes           No
## 19        W        17       25   1013.3     3 31.2        No           No
## 20      NNW        13       27   1013.7     1 32.0        No           No
## 21       NW        31       26   1006.5     5 32.8        No           No
## 22        E        11       72   1008.9     8 18.3        No          Yes
## 23       SE        13       79   1014.9     8 16.8       Yes           No
## 24       NE         9       57   1019.2     5 22.8        No           No
## 25       NE        15       31   1018.6     2 27.3        No           No
## 26        E        22       48   1016.5     4 25.1        No           No
## 27        E        17       55   1018.6     7 21.2        No           No
## 28      NNE        11       31   1014.8     7 26.7        No           No
## 29       SE        17       80   1017.1     7 19.7        No           No
## 30        S         6       49   1013.3     7 23.2        No          Yes
## 31        S        20       90   1014.1     8 16.3       Yes          Yes
## 32       SW         9       46   1009.5     2 25.2       Yes           No
## 33       NW        35       60   1004.6     7 19.9        No          Yes
## 34      WNW        26       40   1006.3     2 25.1       Yes           No
## 35        E        30       63   1015.3     1 20.5        No           No
## 36      ESE         9       54   1016.1     7 24.5        No           No
## 37        N         6       74   1011.5     7 22.6        No          Yes
## 38        N        13       42   1011.4     1 26.3       Yes           No
## 39        W        24       24   1008.5     7 28.6        No           No
## 40      WNW         6       37   1010.4     7 22.9        No           No
## 41        E        15       63   1017.4     6 16.4        No           No
## 42        E        24       51   1019.6     5 19.4        No           No
## 43        E        20       49   1019.3     7 19.2        No           No
## 44        N        11       37   1012.5     2 25.0        No           No
## 45      WNW        13       36   1010.2     8 29.1        No          Yes
## 46       NE         7       86   1008.6     8 20.0       Yes          Yes
## 47      ESE        20       40   1016.8     4 20.8       Yes           No
## 48        E        20       43   1018.3     7 19.8        No           No
## 49      ENE         6       54   1015.6     8 20.0        No          Yes
## 50       NW        13       74   1014.1     7 20.4       Yes          Yes
## 51       NW        22       48   1008.3     7 28.2       Yes          Yes
## 52      WNW        30       62    996.8     3 19.6       Yes          Yes
## 53        N        20       49   1009.1     7 18.8       Yes           No
## 54      WNW        13       43   1009.7     4 22.5        No          Yes
## 55       NE        11       52   1019.1     3 21.0       Yes           No
## 56      NNW        19       35   1018.0     1 23.9        No           No
## 57      NNW        48       64   1014.3     7 19.0        No          Yes
## 58       NW        13       44   1013.4     5 27.4       Yes           No
## 59        N         7       30   1014.2     2 30.3        No           No
## 60      ESE        22       18   1015.0     1 34.3        No           No
## 61       NE         9       20   1015.6     1 32.2        No           No
## 62        W        11       20   1011.6     6 31.8        No           No
## 63      WSW         9       14   1008.7     1 33.6        No           No
## 64      ESE        24       55   1016.3     7 22.3        No           No
## 65      ESE        26       45   1013.0     7 23.9        No           No
## 66        E        15       40   1007.4     2 26.8        No           No
## 67      NNW        19       34   1003.3     1 31.9        No           No
## 68       NW        11       36   1009.5     1 31.3        No           No
## 69        N         9       44   1013.4     1 28.0        No           No
## 70      ENE        11       45   1015.9     1 27.9        No           No
## 71       NW        11       25   1013.3     1 32.2        No           No
## 72       NW        19       24   1006.5     1 34.5        No           No
## 73      WNW        17       28   1003.0     2 34.0        No          Yes
## 74        W        24       35   1001.8     3 31.8       Yes           No
## 75      ENE        19       57   1012.3     6 21.6        No           No
## 76       NW        15       26   1009.0     1 31.7        No           No
## 77      NNE        20       62   1006.1     7 23.5        No          Yes
## 78      ESE        28       42   1015.0     1 23.9       Yes           No
## 79      ESE        19       55   1015.8     8 19.4        No          Yes
## 80      NNE        13       88   1006.0     8 18.6       Yes          Yes
## 81      WNW        28       71   1004.0     8 21.9       Yes           No
## 82      ESE        22       58   1012.1     7 18.6        No           No
## 83        S         7       46   1016.8     2 22.2        No           No
## 84        E         7       38   1019.2     4 22.7        No           No
## 85       NE        11       29   1018.1     6 26.3        No           No
## 86       NE        17       32   1016.9     7 24.6        No           No
## 87      SSW         7       28   1012.4     5 28.3        No           No
## 88      WNW        26       28   1009.5     4 30.7        No           No
## 89       NW        24       18   1012.0     1 32.1        No           No
## 90        W        11       22   1014.6     1 32.3        No           No
## 91        W        13       29   1013.7     6 33.1        No          Yes
## 92      NNW        13       49   1012.8     8 26.3       Yes          Yes
## 93      ESE        11       49   1017.1     7 22.9       Yes           No
## 94      NNE        11       44   1014.5     2 27.0        No           No
## 95      ESE        17       38   1012.8     7 29.1        No          Yes
## 96      ENE        13       76   1011.5     8 22.1       Yes          Yes
## 97      SSE        11       71   1007.8     8 21.5       Yes           No
## 98      WNW        24       41    997.5     7 26.5        No           No
## 99      NNW        20       76    998.9     7 20.3        No          Yes
## 100     ESE        20       58   1005.0     7 18.7       Yes           No
## 101       S        17       51   1006.8     6 18.7        No           No
## 102       W        13       37   1011.4     7 21.4        No           No
## 103      NE        13       34   1011.7     5 24.2        No          Yes
## 104     WNW        17       60   1006.8     5 22.6       Yes          Yes
## 105     SSE        15       73   1011.0     8 16.8       Yes           No
## 106      SE         9       37   1015.1     1 22.0        No           No
## 107       E         7       32   1016.7     1 24.3        No           No
## 108       E        19       40   1020.0     1 24.7        No           No
## 109     NNE        13       46   1021.4     1 22.5        No           No
## 110     NNE        11       42   1017.4     4 24.1        No           No
## 111      SE        15       38   1012.8     2 26.1        No           No
## 112     WNW         9       31   1009.1     7 28.6        No          Yes
## 113       N         7       56   1008.4     7 24.0       Yes          Yes
## 114       W        28       42   1002.3     5 27.4       Yes           No
## 115     WNW        26       32   1005.4     1 24.5        No           No
## 116     WNW        30       34   1007.2     1 22.9        No           No
## 117     WSW         7       35   1014.3     2 24.3        No           No
## 118      NW        17       27   1014.4     6 27.0        No           No
## 119       W        30       25   1009.1     6 26.8        No           No
## 120      SE        13       78   1009.9     7 15.3        No          Yes
## 121       S        17       34   1014.5     1 16.8       Yes           No
## 122     SSE        15       31   1019.3     1 20.0        No           No
## 123     WNW        11       37   1023.2     2 22.1        No           No
## 124     WNW         9       28   1020.4     1 25.5        No           No
## 125     WNW         7       28   1018.2     7 27.0        No           No
## 126     WSW         6       35   1022.2     1 26.2        No           No
## 127     NNE         9       24   1019.3     3 30.0        No           No
## 128     ENE         9       34   1017.7     7 27.7        No          Yes
## 129     NNW         9       39   1020.7     7 24.9       Yes           No
## 130     NNE        11       33   1023.1     1 27.0        No           No
## 131       W         9       28   1020.4     1 30.1        No           No
## 132     ENE         7       18   1019.3     3 32.7        No           No
## 133     WSW        28       23   1017.6     5 30.7        No           No
## 134     NNW         7       18   1017.7     1 31.7        No           No
## 135       W        13       15   1019.1     1 32.7        No           No
## 136     ESE         4       15   1019.3     2 34.1        No           No
## 137     WNW         6       17   1020.7     2 30.5        No           No
## 138     NNW        13       22   1020.6     0 28.8        No           No
## 139     WNW        19       30   1018.8     1 29.2        No           No
## 140     NNE        15       48   1018.7     4 24.5        No           No
## 141     WSW        26       35   1009.4     7 27.6        No           No
## 142     ESE        17       62   1019.3     8 13.9        No           No
## 143     ESE        17       64   1021.8     8 17.9        No           No
## 144      SW         7       44   1019.3     6 24.2        No           No
## 145     WNW        19       68   1015.4     7 21.1        No          Yes
## 146       N        20       93   1006.5     8 16.6       Yes          Yes
## 147       W        20       50   1008.4     4 17.4       Yes           No
## 148       N        17       36   1012.6     2 17.4        No           No
## 149     WNW        19       35   1015.0     3 17.2        No           No
## 150      NW        22       30   1011.3     6 18.2        No           No
## 151     WNW        31       34   1009.3     2 18.1        No           No
## 152       W        26       42   1013.0     5 16.5        No           No
## 153     WNW        11       34   1021.2     1 21.2        No           No
## 154      NW        37       26   1010.5     8 22.5        No          Yes
## 155       W        33       40   1012.7     3 13.7       Yes           No
## 156     WSW         7       33   1019.1     1 17.6        No           No
## 157     NNW         7       27   1022.3     1 20.5        No           No
## 158     NNW        11       35   1024.1     5 20.8        No           No
## 159     ENE        11       48   1024.0     5 19.5        No           No
## 160      SE         9       45   1025.4     4 17.8        No           No
## 161     WNW         6       49   1021.8     4 18.6        No           No
## 162       N         6       28   1019.2     1 22.2        No           No
## 163     WSW         7       29   1016.9     1 22.4        No           No
## 164     WNW        11       32   1015.8     3 23.7        No          Yes
## 165      NW        15       56   1013.8     2 19.1       Yes          Yes
## 166     SSE        20       40   1019.6     1 17.9       Yes           No
## 167       S         9       36   1023.9     2 20.4        No           No
## 168      SE        13       39   1024.4     1 18.8        No           No
## 169      NW         7       44   1023.3     2 20.4        No           No
## 170     ENE        11       43   1024.1     6 19.1        No           No
## 171     ESE        22       51   1027.4     7 15.2        No           No
## 172     ESE        30       65   1024.2     7 15.6        No           No
## 173     SSE         7       34   1021.0     2 19.8        No           No
## 174       E        22       49   1023.5     6 17.7        No           No
## 175     ESE         7       43   1022.2     5 18.1        No           No
## 176      NE         9       55   1019.8     4 17.6        No           No
## 177      NW         7       42   1014.3     6 20.6        No           No
## 178     WNW        20       34   1006.7     7 20.2        No           No
## 179      NW        31       51    997.7     6 16.6        No          Yes
## 180     WNW        22       60   1008.1     6  8.8       Yes           No
## 181     NNW         9       40   1019.6     1 13.2        No           No
## 182       N        19       40   1020.5     7 13.9        No           No
## 183     NNW        26       54   1018.5     7 12.4        No           No
## 184     WNW        28       38   1017.3     2 15.9        No           No
## 185       W        13       42   1017.4     1 16.2        No           No
## 186     NNW        15       42   1018.5     2 15.4        No           No
## 187     WNW        19       41   1015.8     5 18.5        No           No
## 188      NW        26       53   1013.8     7 15.4        No           No
## 189     WNW        30       43   1013.5     1 16.5        No           No
## 190      NW         9       44   1018.9     1 16.9        No           No
## 191       N         9       36   1020.3     1 20.7        No           No
## 192     NNW         9       41   1020.0     1 20.9        No           No
## 193      NE        11       52   1021.5     7 17.2        No           No
## 194     NNW        15       47   1020.3     1 18.8        No           No
## 195      NW        15       34   1021.4     2 18.6        No           No
## 196     NNW        20       44   1021.0     3 17.8        No           No
## 197      NW        20       40   1018.7     2 17.7        No          Yes
## 198      NW        15       69   1013.7     7 15.2       Yes           No
## 199      NW        24       78   1005.9     7  7.3        No           No
## 200     WNW        26       53   1008.3     6 13.3        No           No
## 201     WNW        24       36   1014.3     1 16.7        No           No
## 202     WNW        24       52   1018.6     1 16.2        No           No
## 203       W         7       47   1022.9     2 16.6        No           No
## 204       E         6       43   1026.0     1 13.8        No           No
## 205     SSW         6       49   1024.8     1 14.5        No           No
## 206     SSW         6       43   1023.5     1 13.9        No           No
## 207     NNW        15       48   1021.8     5 17.2        No          Yes
## 208       W         6       50   1023.1     4 17.9       Yes          Yes
## 209      NW        13       55   1022.3     1 17.7       Yes           No
## 210      NW         6       50   1024.7     4 16.3        No           No
## 211     WNW         7       45   1029.6     1 17.3        No           No
## 212     NNW        15       46   1028.7     1 17.4        No           No
## 213       N         7       38   1027.4     3 18.2        No           No
## 214     ENE         7       67   1028.9     7 13.9        No           No
## 215     NNE         6       67   1027.1     7 15.5        No           No
## 216     ESE        11       86   1027.2     8 13.6        No          Yes
## 217      SE        20       65   1025.7     7 13.3       Yes           No
## 218       S        20       65   1023.4     7 14.8        No           No
## 219     NNE         4       42   1022.1     1 16.2        No           No
## 220     ESE        11       42   1027.0     1 14.5        No           No
## 221     ENE        13       70   1031.7     7 13.0        No           No
## 222      NE        19       65   1027.9     7 14.5        No          Yes
## 223    <NA>         0       94   1024.3     8 11.6       Yes          Yes
## 224      NW        17       65   1022.1     7 13.7       Yes           No
## 225     WNW        24       48   1019.7     1 14.7        No           No
## 226     WNW        28       58   1014.1     2 11.1        No           No
## 227       S        24       49   1025.6     1 11.0        No           No
## 228     SSW        26       57   1026.3     2 13.8        No           No
## 229     ESE         9       51   1024.8     2 16.0        No           No
## 230     NNE         7       58   1025.5     1 14.9        No           No
## 231     NNW         9       70   1023.5     7 15.0        No           No
## 232     SSE         7       63   1019.7     7 14.8        No          Yes
## 233     WNW         7       86   1019.2     7 11.3       Yes           No
## 234     WNW        19       59   1021.0     6 12.1        No           No
## 235      SE         9       44   1025.7     4 12.5        No           No
## 236       N        15       53   1022.1     7 12.3        No           No
## 237      NW        28       69   1024.2     6 11.7        No           No
## 238     WNW        28       54   1021.9     1 11.3        No           No
## 239     WNW        28       48   1020.4     1 11.5        No           No
## 240     NNW        24       51   1025.0     1 12.7        No           No
## 241      NW         9       41   1026.0     3 14.5        No           No
## 242       N        22       38   1020.9     6 14.6        No           No
## 243     NNW        28       68   1010.2     7 12.9        No          Yes
## 244       W        33       56   1012.3     1 11.1       Yes           No
## 245     WNW        30       53   1014.0     1 12.3        No           No
## 246     NNW        20       53   1021.9     1 11.1        No           No
## 247      NE        13       52   1030.0     6 10.2        No           No
## 248     WNW         2       55   1028.9     2 12.6        No           No
## 249     NNW        22       59   1026.3     5 13.6        No           No
## 250       N        13       96   1021.1     8  8.6        No          Yes
## 251      NW        15       72   1019.6     6  7.4       Yes           No
## 252      NW        15       68   1016.8     6  8.0        No           No
## 253      NW        35       85   1010.5     7  6.9        No          Yes
## 254     WNW        31       66   1018.2     3  7.1       Yes           No
## 255     NNW         7       54   1022.7     7  9.9        No           No
## 256      NW        15       69   1021.9     7 10.7        No           No
## 257     NNW        22       51   1019.0     1 15.9        No           No
## 258     NNW        17       46   1020.1     7 13.3        No           No
## 259     NNW         9       62   1020.8     7 12.1        No           No
## 260     NNW        24       55   1013.9     3 11.0        No           No
## 261     WNW        33       73   1009.4     5  8.2        No          Yes
## 262      NW        22       48   1014.9     3 10.7       Yes           No
## 263      NE         6       87   1009.0     8  8.7        No          Yes
## 264     WNW        31       56   1010.3     3 11.2       Yes           No
## 265     SSW        28       33   1025.8     1 11.0        No           No
## 266     ESE        11       48   1031.1     5 10.1        No           No
## 267       E        13       51   1027.4     5 10.8        No           No
## 268      SE        13       25   1020.9     1 12.3        No           No
## 269     WNW        19       50   1015.3     7 10.9        No           No
## 270     WSW        13       66   1010.0     7  7.8        No          Yes
## 271       S        37       56   1014.9     4  9.6       Yes           No
## 272       S        22       49   1016.8     1 11.2        No           No
## 273     NNW        15       48   1014.6     1 11.5        No           No
## 274     WNW        26       38   1012.9     7 12.8        No           No
## 275      NW        28       82   1001.3     7  8.6        No          Yes
## 276     WNW        31       56   1014.9     1 10.5       Yes           No
## 277     WNW        24       48   1018.1     1 11.6        No           No
## 278       W        19       60   1018.3     7  9.1        No           No
## 279     SSW        26       72   1019.2     8  7.2        No          Yes
## 280     SSE        22       48   1017.6     1 13.6       Yes           No
## 281       N        26       78   1015.9     7  5.7        No          Yes
## 282       N        30       62   1019.1     2 11.3       Yes           No
## 283      NW        24       70   1019.0     6  8.1        No           No
## 284      NW        24       68   1012.6     6  5.1        No           No
## 285       N        30       60   1016.6     1  8.3        No           No
## 286     WNW        24       63   1020.1     6  8.6        No           No
## 287      NW        30       41   1022.4     1 10.4        No           No
## 288     WNW        39       45   1018.2     1  9.5        No           No
## 289      NW        33       51   1012.4     3 12.0        No           No
## 290     WSW        28       27   1011.8     1 13.5        No           No
## 291     NNW        17       35   1022.0     1 10.8        No           No
## 292     WNW        30       30   1021.8     7 11.2        No           No
## 293     NNW        20       47   1025.6     6 12.2        No           No
## 294     WNW        24       36   1024.4     7 12.4        No           No
## 295      NW        30       27   1017.8     8 13.2        No           No
## 296       S        26       44   1016.8     5 10.7        No           No
## 297     ESE        17       38   1025.5     1 11.1        No           No
## 298     NNW        11       28   1028.0     0 14.0        No           No
## 299       N        19       34   1024.4     6 12.8        No           No
## 300     WNW        26       23   1020.3     7 15.8        No           No
## 301      SE        13       23   1025.5     1 14.4        No           No
## 302      NE        15       43   1025.9     5 12.3        No           No
## 303     ENE        20       45   1022.9     6 14.6        No           No
## 304     WSW         6       45   1017.5     8 15.4        No          Yes
## 305     WNW        15       85   1010.4     7 12.6       Yes          Yes
## 306       W        28       34   1021.7     1 14.3       Yes           No
## 307     NNE        13       44   1024.8     4 14.9        No           No
## 308      SE        20       51   1033.2     5 11.1        No           No
## 309     ESE        17       61   1031.9     7 10.2        No           No
## 310     ESE        13       73   1023.5     8 10.8        No           No
## 311       S        24       33   1016.2     7 15.7        No           No
## 312      NW        22       33   1013.9     7 15.5        No           No
## 313     WNW        11       37   1018.2     1 15.3        No           No
## 314       N        22       25   1020.9     0 13.4        No           No
## 315     WNW        20       35   1017.9     2 14.9        No           No
## 316       N        20       20   1013.9     1 16.3        No           No
## 317      NW        26       27   1010.9     5 21.5        No           No
## 318      NW        26       31   1011.4     1 25.1        No          Yes
## 319      NW        30       43   1006.0     1 18.2       Yes          Yes
## 320     NNW        52       33   1001.5     6 18.5       Yes          Yes
## 321     WNW        31       33   1017.6     1 12.2       Yes           No
## 322     NNW         7       43   1022.1     1 13.7        No           No
## 323     NNW        28       36   1015.6     1 17.8        No           No
## 324      NW        28       30   1011.7     1 22.4        No           No
## 325      NW        41       15   1010.9     0 21.3        No           No
## 326     NNW        33       25   1015.1     0 18.3        No           No
## 327      NW        20       50   1006.5     8 21.0        No          Yes
## 328       N        22       44   1017.8     1 14.3       Yes           No
## 329      SW         6       33   1027.7     1 16.5        No           No
## 330     NNW        13       32   1026.9     1 18.1        No           No
## 331     WNW        26       35   1020.6     6 20.0        No           No
## 332      NW        24       25   1016.4     1 24.7        No           No
## 333      NW        30       25   1009.9     1 23.0        No           No
## 334      NW        22       32   1013.9     7 16.0        No           No
## 335     NNW        28       34   1017.0     1 16.3        No           No
## 336       N        30       16   1015.4     1 19.5        No           No
## 337      NW        28       21   1014.1     0 26.7        No           No
## 338      NW        41       22   1011.8     1 28.4        No          Yes
## 339     NNW        19       65   1013.2     4 19.3       Yes          Yes
## 340       N        19       46   1013.6     1 19.8       Yes           No
## 341       W        33       40   1005.3     4 16.2        No          Yes
## 342       N        28       45   1013.3     1 14.6       Yes           No
## 343     NNW        26       33   1017.5     1 16.6        No           No
## 344       N         9       22   1024.2     1 18.8        No           No
## 345       N        19       25   1024.9     2 21.4        No           No
## 346      NW        17       30   1023.8     3 20.6        No           No
## 347     NNW        11       27   1021.5     4 22.3        No           No
## 348     NNW        33       47   1016.0     7 23.2        No          Yes
## 349       N        24       61   1016.7     3 19.4       Yes           No
## 350     NNW         7       42   1019.7     4 18.4        No           No
## 351      NW         9       30   1022.3     1 19.2        No           No
## 352     NNW        26       34   1020.7     1 21.9        No           No
## 353      NW        20       31   1022.2     7 23.7        No           No
## 354      NW        26       30   1019.8     6 27.4        No           No
## 355      NW        31       20   1017.5     1 26.3        No           No
## 356      SW        11       28   1018.6     5 18.5        No           No
## 357       S        37       24   1023.1     5 14.3        No           No
## 358       S        15       25   1022.8     2 16.3        No           No
## 359       N        17       29   1018.4     8 19.1        No           No
## 360     NNW        19       16   1014.6     3 24.8        No           No
## 361     WNW        19       20   1014.2     8 25.9        No           No
## 362      NW        50       15   1010.8     3 30.0        No           No
## 363     NNW        19       22   1016.9     1 28.2        No           No
## 364     ENE         9       47   1022.8     2 18.3        No           No
## 365     WNW        28       39   1016.2     7 25.9        No           No
## 366     WNW        35       13   1009.2     1 28.6        No           No

1.1.2 ๋ฐ์ดํ„ฐ ํ™•์ธ ๋ฐฉ๋ฒ•

length(weather$Date) # ๋ฐ์ดํ„ฐ ๊ฐ์ฒด์˜ ์š”์†Œ๋“ค์˜ ๊ฐœ์ˆ˜
## [1] 366
names(weather) # ๋ฐ์ดํ„ฐ ๊ฐ์ฒด ๊ตฌ์„ฑ์š”์†Œ ์ด๋ฆ„
##  [1] "Date"          "MinTemp"       "MaxTemp"       "Rainfall"     
##  [5] "Sunshine"      "WindGustDir"   "WindGustSpeed" "WindDir"      
##  [9] "WindSpeed"     "Humidity"      "Pressure"      "Cloud"        
## [13] "Temp"          "RainToday"     "RainTomorrow"
class(weather) # ๋ฐ์ดํ„ฐ ๊ฐ์ฒด ๊ตฌ์„ฑ์š”์†Œ์˜ ์†์„ฑ
## [1] "data.frame"
attributes(weather) # ๋ณ€์ˆ˜ ์†์„ฑ ๋ณด๊ธฐ
## $names
##  [1] "Date"          "MinTemp"       "MaxTemp"       "Rainfall"     
##  [5] "Sunshine"      "WindGustDir"   "WindGustSpeed" "WindDir"      
##  [9] "WindSpeed"     "Humidity"      "Pressure"      "Cloud"        
## [13] "Temp"          "RainToday"     "RainTomorrow" 
## 
## $class
## [1] "data.frame"
## 
## $row.names
##   [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17
##  [18]  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34
##  [35]  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51
##  [52]  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68
##  [69]  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85
##  [86]  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102
## [103] 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
## [120] 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
## [137] 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
## [154] 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
## [171] 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
## [188] 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
## [205] 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
## [222] 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
## [239] 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
## [256] 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
## [273] 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
## [290] 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
## [307] 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
## [324] 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
## [341] 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
## [358] 358 359 360 361 362 363 364 365 366
summary(weather) # ๋ฐ์ดํ„ฐ ์š”์•ฝ ๋ณด๊ธฐ
##      Date              MinTemp          MaxTemp         Rainfall     
##  Length:366         Min.   :-5.300   Min.   : 7.60   Min.   : 0.000  
##  Class :character   1st Qu.: 2.300   1st Qu.:15.03   1st Qu.: 0.000  
##  Mode  :character   Median : 7.450   Median :19.65   Median : 0.000  
##                     Mean   : 7.266   Mean   :20.55   Mean   : 1.428  
##                     3rd Qu.:12.500   3rd Qu.:25.50   3rd Qu.: 0.200  
##                     Max.   :20.900   Max.   :35.80   Max.   :39.800  
##                                                                      
##     Sunshine      WindGustDir        WindGustSpeed     WindDir         
##  Min.   : 0.000   Length:366         Min.   :13.00   Length:366        
##  1st Qu.: 5.950   Class :character   1st Qu.:31.00   Class :character  
##  Median : 8.600   Mode  :character   Median :39.00   Mode  :character  
##  Mean   : 7.909                      Mean   :39.84                     
##  3rd Qu.:10.500                      3rd Qu.:46.00                     
##  Max.   :13.600                      Max.   :98.00                     
##  NA's   :3                           NA's   :2                         
##    WindSpeed        Humidity        Pressure          Cloud      
##  Min.   : 0.00   Min.   :13.00   Min.   : 996.8   Min.   :0.000  
##  1st Qu.:11.00   1st Qu.:32.25   1st Qu.:1012.8   1st Qu.:1.000  
##  Median :17.00   Median :43.00   Median :1017.4   Median :4.000  
##  Mean   :17.99   Mean   :44.52   Mean   :1016.8   Mean   :4.025  
##  3rd Qu.:24.00   3rd Qu.:55.00   3rd Qu.:1021.5   3rd Qu.:7.000  
##  Max.   :52.00   Max.   :96.00   Max.   :1033.2   Max.   :8.000  
##                                                                  
##       Temp        RainToday         RainTomorrow      
##  Min.   : 5.10   Length:366         Length:366        
##  1st Qu.:14.15   Class :character   Class :character  
##  Median :18.55   Mode  :character   Mode  :character  
##  Mean   :19.23                                        
##  3rd Qu.:24.00                                        
##  Max.   :34.50                                        
## 
dim(weather) # ๋ฐ์ดํ„ฐ ๊ฐ์ฒด์˜ ์ฐจ์›๋ณด๊ธฐ
## [1] 366  15
head(weather) # ์ƒ์œ„ 6๊ฐœ ๊ด€์ธก์น˜ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
##         Date MinTemp MaxTemp Rainfall Sunshine WindGustDir WindGustSpeed
## 1 2014-11-01     8.0    24.3      0.0      6.3          NW            30
## 2 2014-11-02    14.0    26.9      3.6      9.7         ENE            39
## 3 2014-11-03    13.7    23.4      3.6      3.3          NW            85
## 4 2014-11-04    13.3    15.5     39.8      9.1          NW            54
## 5 2014-11-05     7.6    16.1      2.8     10.6         SSE            50
## 6 2014-11-06     6.2    16.9      0.0      8.2          SE            44
##   WindDir WindSpeed Humidity Pressure Cloud Temp RainToday RainTomorrow
## 1      NW        20       29   1015.0     7 23.6        No          Yes
## 2       W        17       36   1008.4     3 25.7       Yes          Yes
## 3     NNE         6       69   1007.2     7 20.2       Yes          Yes
## 4       W        24       56   1007.0     7 14.1       Yes          Yes
## 5     ESE        28       49   1018.5     7 15.4       Yes           No
## 6       E        24       57   1021.7     5 14.8        No           No
tail(weather) # ํ•˜์œ„ 6๊ฐœ ๊ด€์ธก์น˜ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
##           Date MinTemp MaxTemp Rainfall Sunshine WindGustDir WindGustSpeed
## 361 2015-10-27     7.9    26.1        0      3.5         NNW            43
## 362 2015-10-28     9.0    30.7        0     12.1         NNW            76
## 363 2015-10-29     7.1    28.4        0     12.7           N            48
## 364 2015-10-30    12.5    19.9        0      5.3         ESE            43
## 365 2015-10-31    12.5    26.9        0      7.1          NW            46
## 366 2015-11-01    12.3    30.2        0     12.6          NW            78
##     WindDir WindSpeed Humidity Pressure Cloud Temp RainToday RainTomorrow
## 361     WNW        19       20   1014.2     8 25.9        No           No
## 362      NW        50       15   1010.8     3 30.0        No           No
## 363     NNW        19       22   1016.9     1 28.2        No           No
## 364     ENE         9       47   1022.8     2 18.3        No           No
## 365     WNW        28       39   1016.2     7 25.9        No           No
## 366     WNW        35       13   1009.2     1 28.6        No           No
str(weather) # ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ, ๋ณ€์ˆ˜ ๊ฐœ์ˆ˜, ๋ณ€์ˆ˜ ๋ช…, ๊ด€์ฐฐ์น˜ ๊ฐœ์ˆ˜, ๊ด€์ฐฐ์น˜์˜ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
## 'data.frame':    366 obs. of  15 variables:
##  $ Date         : chr  "2014-11-01" "2014-11-02" "2014-11-03" "2014-11-04" ...
##  $ MinTemp      : num  8 14 13.7 13.3 7.6 6.2 6.1 8.3 8.8 8.4 ...
##  $ MaxTemp      : num  24.3 26.9 23.4 15.5 16.1 16.9 18.2 17 19.5 22.8 ...
##  $ Rainfall     : num  0 3.6 3.6 39.8 2.8 0 0.2 0 0 16.2 ...
##  $ Sunshine     : num  6.3 9.7 3.3 9.1 10.6 8.2 8.4 4.6 4.1 7.7 ...
##  $ WindGustDir  : chr  "NW" "ENE" "NW" "NW" ...
##  $ WindGustSpeed: int  30 39 85 54 50 44 43 41 48 31 ...
##  $ WindDir      : chr  "NW" "W" "NNE" "W" ...
##  $ WindSpeed    : int  20 17 6 24 28 24 26 24 17 6 ...
##  $ Humidity     : int  29 36 69 56 49 57 47 57 48 32 ...
##  $ Pressure     : num  1015 1008 1007 1007 1018 ...
##  $ Cloud        : int  7 3 7 7 7 5 6 7 7 1 ...
##  $ Temp         : num  23.6 25.7 20.2 14.1 15.4 14.8 17.3 15.5 18.9 21.7 ...
##  $ RainToday    : chr  "No" "Yes" "Yes" "Yes" ...
##  $ RainTomorrow : chr  "Yes" "Yes" "Yes" "Yes" ...

1.1.3 ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ

weather_num <- weather[, c(-1, -6, -8, -14, -15)]
str(weather_num)
## 'data.frame':    366 obs. of  10 variables:
##  $ MinTemp      : num  8 14 13.7 13.3 7.6 6.2 6.1 8.3 8.8 8.4 ...
##  $ MaxTemp      : num  24.3 26.9 23.4 15.5 16.1 16.9 18.2 17 19.5 22.8 ...
##  $ Rainfall     : num  0 3.6 3.6 39.8 2.8 0 0.2 0 0 16.2 ...
##  $ Sunshine     : num  6.3 9.7 3.3 9.1 10.6 8.2 8.4 4.6 4.1 7.7 ...
##  $ WindGustSpeed: int  30 39 85 54 50 44 43 41 48 31 ...
##  $ WindSpeed    : int  20 17 6 24 28 24 26 24 17 6 ...
##  $ Humidity     : int  29 36 69 56 49 57 47 57 48 32 ...
##  $ Pressure     : num  1015 1008 1007 1007 1018 ...
##  $ Cloud        : int  7 3 7 7 7 5 6 7 7 1 ...
##  $ Temp         : num  23.6 25.7 20.2 14.1 15.4 14.8 17.3 15.5 18.9 21.7 ...
# ๊ฒฐ์ธก์น˜ ํ™•์ธ
colSums(is.na(weather_num))
##       MinTemp       MaxTemp      Rainfall      Sunshine WindGustSpeed 
##             0             0             0             3             2 
##     WindSpeed      Humidity      Pressure         Cloud          Temp 
##             0             0             0             0             0

1.1.4 ์ƒ๊ด€๊ณ„์ˆ˜ ํ™•์ธ

# cor(weather) # numeric ๋ฐ์ดํ„ฐ๋งŒ ๊ฐ€๋Šฅ
cor(weather_num, method = "pearson") # ์ƒ๊ด€๊ด€๊ณ„ ํ™•์ธ
##                   MinTemp     MaxTemp    Rainfall Sunshine WindGustSpeed
## MinTemp        1.00000000  0.75247079  0.20193872       NA            NA
## MaxTemp        0.75247079  1.00000000 -0.07355958       NA            NA
## Rainfall       0.20193872 -0.07355958  1.00000000       NA            NA
## Sunshine               NA          NA          NA        1            NA
## WindGustSpeed          NA          NA          NA       NA             1
## WindSpeed     -0.06592182 -0.16787312  0.05600849       NA            NA
## Humidity      -0.04070877 -0.53332688  0.28901341       NA            NA
## Pressure      -0.49800692 -0.37939373 -0.25021761       NA            NA
## Cloud          0.11839736 -0.13599065  0.12779204       NA            NA
## Temp           0.72273050  0.98926079 -0.08749319       NA            NA
##                 WindSpeed    Humidity    Pressure       Cloud        Temp
## MinTemp       -0.06592182 -0.04070877 -0.49800692  0.11839736  0.72273050
## MaxTemp       -0.16787312 -0.53332688 -0.37939373 -0.13599065  0.98926079
## Rainfall       0.05600849  0.28901341 -0.25021761  0.12779204 -0.08749319
## Sunshine               NA          NA          NA          NA          NA
## WindGustSpeed          NA          NA          NA          NA          NA
## WindSpeed      1.00000000 -0.02636775 -0.33732535  0.00720724 -0.18756965
## Humidity      -0.02636775  1.00000000 -0.01005189  0.51010790 -0.58167615
## Pressure      -0.33732535 -0.01005189  1.00000000 -0.14383718 -0.34548531
## Cloud          0.00720724  0.51010790 -0.14383718  1.00000000 -0.17281423
## Temp          -0.18756965 -0.58167615 -0.34548531 -0.17281423  1.00000000

1.1.5 ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ 2

weather_num2 <- na.omit(weather_num) # ๊ฒฐ์ธก์น˜๋ฅผ ํฌํ•จํ•œ ํ–‰ ์ œ๊ฑฐ

colSums(is.na(weather_num2)) # ๊ฒฐ์ธก์น˜ ์ œ๊ฑฐ ํ™•์ธ
##       MinTemp       MaxTemp      Rainfall      Sunshine WindGustSpeed 
##             0             0             0             0             0 
##     WindSpeed      Humidity      Pressure         Cloud          Temp 
##             0             0             0             0             0

1.1.6 ์ƒ๊ด€๊ณ„์ˆ˜ ํ™•์ธ

cor(weather_num2, method = "pearson")
##                   MinTemp    MaxTemp    Rainfall    Sunshine WindGustSpeed
## MinTemp        1.00000000  0.7528417  0.19629243  0.03712155    0.21563742
## MaxTemp        0.75284166  1.0000000 -0.07818860  0.45408861    0.10694128
## Rainfall       0.19629243 -0.0781886  1.00000000 -0.15068501    0.09532589
## Sunshine       0.03712155  0.4540886 -0.15068501  1.00000000    0.09584272
## WindGustSpeed  0.21563742  0.1069413  0.09532589  0.09584272    1.00000000
## WindSpeed     -0.07057462 -0.1687830  0.05117158  0.07254811    0.69470706
## Humidity      -0.04856916 -0.5383779  0.28666809 -0.75979510   -0.07029527
## Pressure      -0.49520944 -0.3770701 -0.25125627 -0.03740636   -0.52478951
## Cloud          0.10821155 -0.1432029  0.13105977 -0.66232664    0.05052383
## Temp           0.72354652  0.9892214 -0.09172749  0.47233003    0.06968778
##                  WindSpeed    Humidity    Pressure        Cloud
## MinTemp       -0.070574620 -0.04856916 -0.49520944  0.108211552
## MaxTemp       -0.168782971 -0.53837794 -0.37707008 -0.143202950
## Rainfall       0.051171576  0.28666809 -0.25125627  0.131059766
## Sunshine       0.072548114 -0.75979510 -0.03740636 -0.662326636
## WindGustSpeed  0.694707060 -0.07029527 -0.52478951  0.050523835
## WindSpeed      1.000000000 -0.03101386 -0.33839811  0.006244681
## Humidity      -0.031013858  1.00000000 -0.01170095  0.511175462
## Pressure      -0.338398109 -0.01170095  1.00000000 -0.141730139
## Cloud          0.006244681  0.51117546 -0.14173014  1.000000000
## Temp          -0.188218230 -0.58636265 -0.34304952 -0.179481518
##                      Temp
## MinTemp        0.72354652
## MaxTemp        0.98922136
## Rainfall      -0.09172749
## Sunshine       0.47233003
## WindGustSpeed  0.06968778
## WindSpeed     -0.18821823
## Humidity      -0.58636265
## Pressure      -0.34304952
## Cloud         -0.17948152
## Temp           1.00000000

1.1.7 Pairs() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ์‚ฐ์ ๋„ ํ–‰๋ ฌ์„ ๊ทธ๋ฆฌ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ์ž ์ •์˜ํ•จ์ˆ˜ ์‚ฌ์šฉ

# help("pairs")์—์„œ ์ฐธ๊ณ ํ•œ ํ•จ์ˆ˜๋“ค
# ์‚ฐ์ ๋„ ํ–‰๋ ฌ์˜ ๋Œ€๊ฐ์„ ์— ํžˆ์Šคํ† ๊ทธ๋žจ์„ ์ถ”๊ฐ€ํ•˜๋Š” ์‚ฌ์šฉ์ž ์ •์˜ ํ•จ์ˆ˜
panel.hist <- function(x, ...)
{
  usr <- par("usr"); on.exit(par(usr))
  par(usr = c(usr[1:2], 0, 1.5) )
  h <- hist(x, plot = FALSE)
  breaks <- h$breaks; nB <- length(breaks)
  y <- h$counts; y <- y/max(y)
  rect(breaks[-nB], 0, breaks[-1], y, col = "cyan", ...)
} 

# ๋‹ค์Œ์œผ๋กœ ์‚ฐ์ ๋„ ํ–‰๋ ฌ์˜ ์œ„์ชฝ์— ์ƒ๊ด€๊ณ„์ˆ˜ ์ˆซ์ž๋ฅผ ์ง‘์–ด๋„ฃ๋Š” ์‚ฌ์šฉ์ž ์ •์˜ ํ•จ์ˆ˜
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
{
  usr <- par("usr"); on.exit(par(usr))
  par(usr = c(0, 1, 0, 1))
  r <- abs(cor(x, y))
  txt <- format(c(r, 0.123456789), digits = digits)[1]
  txt <- paste0(prefix, txt)
  if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
  text(0.5, 0.5, txt, cex = cex.cor * r)
} 

# ์‚ฐ์ ๋„์— ์„ ํ˜• ํšŒ๊ท€์„ ์„ ์ถ”๊ฐ€ํ•˜๋Š” ์‚ฌ์šฉ์ž ์ •์˜ ํ•จ์ˆ˜
panel.lm <- function(x, y, col=par("col"), bg=NA, pch=par("pch"), 
                     cex=1, col.smooth="black", ...) {
  points(x, y, pch=pch, col=col, bg=bg, cex=cex) 
  abline(stats::lm(y~x), col=col.smooth, ...)
} 

1.1.8 ์‚ฐ์ ๋„ ํ–‰๋ ฌ(scatter-plot matrix), ์ƒ๊ด€๊ณ„์ˆ˜(correlation), ํžˆ์Šคํ† ๊ทธ๋žจ(histogram)

pairs(
  weather_num2,
  lower.panel = panel.lm,
  upper.panel = panel.cor,
  diag.panel = panel.hist,
  pch="*",
  main = "์‚ฐ์ ๋„ ํ–‰๋ ฌ, ์ƒ๊ด€๊ณ„์ˆ˜ , ํžˆ์Šคํ† ๊ทธ๋žจ"
)

pairs(
  weather_num2,
  pch=21,
  bg=rainbow(10)
)

1.1.9 ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ 3

# ๊ด€๋ จ์ด ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋งŒ ๋‹ค์‹œ ์ „์ฒ˜๋ฆฌ
weather_num3 <- weather_num2[, c(-3)]

1.1.10 ์‚ฐ์ ๋„ ํ–‰๋ ฌ(scatter-plot matrix), ์ƒ๊ด€๊ณ„์ˆ˜(correlation), ํžˆ์Šคํ† ๊ทธ๋žจ(histogram) 2

# cor(weather_num3, method="pearson") # ๋Œ€์ƒ๋ณ€์ˆ˜๊ฐ€ ๋“ฑ๊ฐ„์ฒ™๋„ ๋˜๋Š” ๋น„์œจ์ฒ™๋„ ์ผ ๋•Œ pearson ์ƒ๊ด€๊ณ„์ˆ˜๋ฅผ ์ ์šฉ
# cor(weather_num3, method="spearman") # ์„œ์—ด์ฒ™๋„์ผ ๋•Œ๋Š” spearman ์ƒ๊ด€๊ณ„์ˆ˜๋ฅผ ์ ์šฉ
pairs(
  weather_num3,
  lower.panel = panel.lm,
  upper.panel = panel.cor,
  diag.panel = panel.hist,
  pch=21,
  bg=rainbow(5)
)

2 ์˜ˆ์ธก ๋ถ„์„

  • ์ถ”๋ก  ํ†ต๊ณ„ ๋ฐ ํŒจํ„ด(๊ทœ์น™)์„ ์ ์šฉํ•˜์—ฌ ๋ฏธ๋ž˜์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์˜ˆ์ธกํ•˜๋Š” ๋ถ„์„๋ฐฉ๋ฒ•

2.1 ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€๋ถ„์„

  • ์ข…์†๋ณ€์ˆ˜์™€ ๋…๋ฆฝ๋ณ€์ˆ˜ ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ๋‚˜ํƒ€๋‚ด์–ด ์˜ˆ์ธก ๋ชจ๋ธ์„ ์ƒ์„ฑํ•œ๋‹ค๋Š” ์ ์—์„œ ์„ ํ˜•ํšŒ๊ท€๋ถ„์„๊ณผ ๋™์ผ
  • ๋…๋ฆฝ๋ณ€์ˆ˜(x)์— ์˜ํ•ด์„œ ์ข…์†๋ณ€์ˆ˜(y)์˜ ๋ฒ”์ฃผ๋กœ ๋ถ„๋ฅ˜ํ•œ๋‹ค๋Š” ์ธก๋ฉด์€ ๋ถ„๋ฅ˜๋ถ„์„ ๋ฐฉ๋ฒ•์œผ๋กœ ๋ถ„๋ฅ˜๋œ๋‹ค.

2.1.1 ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€๋ถ„์„์˜ ํŠน์ง•

  • ๋ถ„์„ ๋ชฉ์  : ์ข…์†๋ณ€์ˆ˜์™€ ๋…๋ฆฝ๋ณ€์ˆ˜ ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ํ†ตํ•ด์„œ ์˜ˆ์ธก ๋ชจ๋ธ์„ ์ƒ์„ฑํ•˜๋Š” ๋ฐ ์žˆ๋‹ค.
  • ๋‹จ์ˆœ ํšŒ๊ท€๋ถ„์„๊ณผ ์ฐจ์ด์ : ์ข…์†๋ณ€์ˆ˜๋Š” ๋ฐ˜๋“œ์‹œ ๋ฒ”์ฃผํ˜• ๋ณ€์ˆ˜์ด์–ด์•ผ ํ•œ๋‹ค.
  • ์ •๊ทœ์„ฑ: ์ •๊ทœ๋ถ„๋Œ€์‹ ์— ์ดํ•ญ๋ถ„ํฌ๋ฅผ ๋”ฐ๋ฅธ๋‹ค.
  • ๋กœ์ง“ ๋ณ€ํ™˜ : ์ข…์†๋ณ€์ˆ˜์˜ ์ถœ๋ ฅ๋ฒ”์œ„๋ฅผ 0๊ณผ 1๋กœ ์กฐ์ •ํ•˜๋Š” ๊ณผ์ •์„ ์˜๋ฏธ
  • ํ™œ์šฉ ๋ถ„์•ผ : ์˜๋ฃŒ, ํ†ต์‹ , ๋‚ ์”จ ๋“ฑ ๋‹ค์–‘ํ•œ ๋ถ„์•ผ์—์„œ ํ™œ์šฉ

2.1.2 ๋ฐ์ดํ„ฐ ํ™•์ธ

str(weather) # ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ, ๋ณ€์ˆ˜ ๊ฐœ์ˆ˜, ๋ณ€์ˆ˜ ๋ช…, ๊ด€์ฐฐ์น˜ ๊ฐœ์ˆ˜, ๊ด€์ฐฐ์น˜์˜ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
## 'data.frame':    366 obs. of  15 variables:
##  $ Date         : chr  "2014-11-01" "2014-11-02" "2014-11-03" "2014-11-04" ...
##  $ MinTemp      : num  8 14 13.7 13.3 7.6 6.2 6.1 8.3 8.8 8.4 ...
##  $ MaxTemp      : num  24.3 26.9 23.4 15.5 16.1 16.9 18.2 17 19.5 22.8 ...
##  $ Rainfall     : num  0 3.6 3.6 39.8 2.8 0 0.2 0 0 16.2 ...
##  $ Sunshine     : num  6.3 9.7 3.3 9.1 10.6 8.2 8.4 4.6 4.1 7.7 ...
##  $ WindGustDir  : chr  "NW" "ENE" "NW" "NW" ...
##  $ WindGustSpeed: int  30 39 85 54 50 44 43 41 48 31 ...
##  $ WindDir      : chr  "NW" "W" "NNE" "W" ...
##  $ WindSpeed    : int  20 17 6 24 28 24 26 24 17 6 ...
##  $ Humidity     : int  29 36 69 56 49 57 47 57 48 32 ...
##  $ Pressure     : num  1015 1008 1007 1007 1018 ...
##  $ Cloud        : int  7 3 7 7 7 5 6 7 7 1 ...
##  $ Temp         : num  23.6 25.7 20.2 14.1 15.4 14.8 17.3 15.5 18.9 21.7 ...
##  $ RainToday    : chr  "No" "Yes" "Yes" "Yes" ...
##  $ RainTomorrow : chr  "Yes" "Yes" "Yes" "Yes" ...

2.1.3 ๋ฐ์ดํ„ฐ ์ „์ฒ˜๋ฆฌ

  • ๋‚ ์”จ ๋ฐ์ดํ„ฐ์˜ ๋ถ„์„์„ ์œ„ํ•ด x, y ๋ณ€์ˆ˜๋ฅผ ๊ฒฐ์ •
  • y(๋…๋ฆฝ๋ณ€์ˆ˜) ๋ณ€์ˆ˜๋ฅผ ๋Œ€์ƒ์œผ๋กœ ๋กœ์ง“ ๋ณ€ํ™˜ํ•˜์—ฌ ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€๋ถ„์„์„ ์œ„ํ•œ ํ™˜๊ฒฝ์„ ๋งˆ๋ จ

2.1.3.1 ๊ฒฐ์ธก์น˜ ํ™•์ธ

# sum(is.na(weather)) # ์ „์ฒด ๊ฒฐ์ธก์น˜ ๊ฐฏ์ˆ˜ ํ™•์ธ
# sum(is.na(weather$Sunshine)) # Sunshine ์ปฌ๋Ÿผ์˜ ๊ฒฐ์ธก์น˜ ๊ฐฏ์ˆ˜ ํ™•์ธ
# sum(is.na(weather$WindGustDir)) # WindGustDir ์ปฌ๋Ÿผ์˜ ๊ฒฐ์ธก์น˜ ๊ฐฏ์ˆ˜ ํ™•์ธ
# sum(is.na(weather$WindGustSpeed)) # WindGustSpeed ์ปฌ๋Ÿผ์˜ ๊ฒฐ์ธก์น˜ ๊ฐฏ์ˆ˜ ํ™•์ธ
# sum(is.na(weather$WindDir)) # WindDir ์ปฌ๋Ÿผ์˜ ๊ฒฐ์ธก์น˜ ๊ฐฏ์ˆ˜ ํ™•์ธ

colSums(is.na(weather)) # ํ•œ๋ฒˆ์— ๊ฒฐ์ธก๊ฐ’ ํ˜„ํ™ฉ ํŒŒ์•…ํ•˜๋Š” ๋ฐฉ๋ฒ•
##          Date       MinTemp       MaxTemp      Rainfall      Sunshine 
##             0             0             0             0             3 
##   WindGustDir WindGustSpeed       WindDir     WindSpeed      Humidity 
##             3             2             1             0             0 
##      Pressure         Cloud          Temp     RainToday  RainTomorrow 
##             0             0             0             0             0

2.1.3.2 ๋ฐ์ดํ„ฐ ๋ณ€ํ™˜

weather_df <- weather[, c(-1, -6, -8, -14)] # chr ๋ฐ์ดํ„ฐ ํƒ€์ž… ์ปฌ๋Ÿผ, Date, RainToday ์ปฌ๋Ÿผ ์ œ๊ฑฐ
str(weather_df) # ์ปฌ๋Ÿผ ์‚ญ์ œ ํ›„ ํ™•์ธ
## 'data.frame':    366 obs. of  11 variables:
##  $ MinTemp      : num  8 14 13.7 13.3 7.6 6.2 6.1 8.3 8.8 8.4 ...
##  $ MaxTemp      : num  24.3 26.9 23.4 15.5 16.1 16.9 18.2 17 19.5 22.8 ...
##  $ Rainfall     : num  0 3.6 3.6 39.8 2.8 0 0.2 0 0 16.2 ...
##  $ Sunshine     : num  6.3 9.7 3.3 9.1 10.6 8.2 8.4 4.6 4.1 7.7 ...
##  $ WindGustSpeed: int  30 39 85 54 50 44 43 41 48 31 ...
##  $ WindSpeed    : int  20 17 6 24 28 24 26 24 17 6 ...
##  $ Humidity     : int  29 36 69 56 49 57 47 57 48 32 ...
##  $ Pressure     : num  1015 1008 1007 1007 1018 ...
##  $ Cloud        : int  7 3 7 7 7 5 6 7 7 1 ...
##  $ Temp         : num  23.6 25.7 20.2 14.1 15.4 14.8 17.3 15.5 18.9 21.7 ...
##  $ RainTomorrow : chr  "Yes" "Yes" "Yes" "Yes" ...
weather_df$RainTomorrow[weather_df$RainTomorrow=="Yes"] <- 1 # Yes -> 1
weather_df$RainTomorrow[weather_df$RainTomorrow=="No"] <- 0 # Tes -> 0
weather_df$RainTomorrow <- as.numeric(weather_df$RainTomorrow) # ์ˆ˜์ •ํ•œ ๊ฐ’์„ numeric์œผ๋กœ ํ˜•๋ณ€ํ™˜

2.1.3.3 ๋ฐ์ดํ„ฐ ํ™•์ธ

head(weather_df)
##   MinTemp MaxTemp Rainfall Sunshine WindGustSpeed WindSpeed Humidity
## 1     8.0    24.3      0.0      6.3            30        20       29
## 2    14.0    26.9      3.6      9.7            39        17       36
## 3    13.7    23.4      3.6      3.3            85         6       69
## 4    13.3    15.5     39.8      9.1            54        24       56
## 5     7.6    16.1      2.8     10.6            50        28       49
## 6     6.2    16.9      0.0      8.2            44        24       57
##   Pressure Cloud Temp RainTomorrow
## 1   1015.0     7 23.6            1
## 2   1008.4     3 25.7            1
## 3   1007.2     7 20.2            1
## 4   1007.0     7 14.1            1
## 5   1018.5     7 15.4            0
## 6   1021.7     5 14.8            0

2.1.4 ํ•™์Šต ๋ฐ์ดํ„ฐ์™€ ๊ฒ€์ • ๋ฐ์ดํ„ฐ ์ƒ์„ฑ (7:3 ๋น„์œจ)

# ๋‹จ์ˆœ ์ž„์˜ ์ถ”์ถœ
idx <- sample(1:nrow(weather_df), nrow(weather_df) * 0.7) # 70%์˜ ๋ฐ์ดํ„ฐ๋งŒ์„ training ๋ฐ์ดํ„ฐ๋กœ  ์‚ฌ
train <- weather_df[idx, ]
# train <- na.omit(train)
test <- weather_df[-idx, ]
# colSums(is.na(train))

2.1.5 ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€๋ชจ๋ธ ์ƒ์„ฑ

# generalized linear model
# glm(y ~ x, data, family)
# family์˜ 'binomial'์€ y ๋ณ€์ˆ˜๊ฐ€ ์ดํ•ญํ˜•์ธ ๊ฒฝ์šฐ ์ง€์ •ํ•˜๋Š” ์†์„ฑ ๊ฐ’
weather_model <- glm(RainTomorrow ~ ., data=train, family="binomial")
# weather_model
summary(weather_model)
## 
## Call:
## glm(formula = RainTomorrow ~ ., family = "binomial", data = train)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9778  -0.4104  -0.2377  -0.1159   2.5506  
## 
## Coefficients:
##                Estimate Std. Error z value Pr(>|z|)   
## (Intercept)   114.25407   47.04648   2.429  0.01516 * 
## MinTemp        -0.03327    0.08344  -0.399  0.69004   
## MaxTemp         0.09486    0.24714   0.384  0.70110   
## Rainfall       -0.00701    0.04652  -0.151  0.88022   
## Sunshine       -0.24363    0.11034  -2.208  0.02724 * 
## WindGustSpeed   0.07092    0.02718   2.609  0.00908 **
## WindSpeed      -0.05203    0.03590  -1.450  0.14717   
## Humidity        0.04411    0.02910   1.516  0.12957   
## Pressure       -0.12007    0.04539  -2.645  0.00816 **
## Cloud           0.15245    0.12346   1.235  0.21688   
## Temp            0.05501    0.25933   0.212  0.83201   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 223.48  on 250  degrees of freedom
## Residual deviance: 135.47  on 240  degrees of freedom
##   (5 observations deleted due to missingness)
## AIC: 157.47
## 
## Number of Fisher Scoring iterations: 6
  • ํ‘œ์˜ ๊ฐ€์žฅ ์šฐ์ธก ์—ด์˜ p-value๊ฐ€ 0.05๋ณด๋‹ค ๋‚ฎ์€ ๋ณ€์ˆ˜๊ฐ€ ํ†ต๊ณ„์ ์œผ๋กœ ์œ ์˜ํ•˜๋‹ค.
  • Sunshine, WindGustSpeed, Humidity, Pressure
  • ๊ฐ€์žฅ ๋‚ฎ์€ Pressure์˜ p-value๊ฐ€ ๊ฐ€์žฅ ๋‚ฎ์€ ๊ฒƒ์œผ๋กœ ๋ณด์•„ ์˜ˆ์ธก๋ ฅ์ด ์ข€ ๋” ๊ฐ•ํ•œ ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.

2.1.6 ๋กœ์ง€์Šคํ‹ฑ ํšŒ๊ท€๋ชจ๋ธ ์˜ˆ์ธก์น˜ ์ƒ์„ฑ

# newdata=test : ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ ์…‹, type="response" : 0~1 ํ™•๋ฅ ๊ฐ’์œผ๋กœ ์˜ˆ์ธก 
pred <- predict(weather_model, newdata=test, type="response")
pred # 1์— ๊ฐ€๊นŒ์šธ ์ˆ˜๋ก ๋น„์˜ฌ ํ™•๋ฅ ์ด ๋†’๋‹ค.
##           8          13          16          17          20          26 
## 0.082115121 0.017274689 0.180177640 0.301677803 0.070515284 0.112748564 
##          31          32          38          39          41          46 
## 0.841413738 0.162171299 0.155714814 0.147765326 0.307673241 0.911056878 
##          55          61          63          64          65          66 
## 0.171589945 0.023007921 0.179803984 0.598131096 0.090903154 0.108643927 
##          67          72          75          76          77          80 
## 0.304035101 0.297083988 0.512341304 0.103100520 0.899911646 0.921963895 
##          82          84          85          86          88          93 
## 0.646011883 0.026284127 0.071935995 0.112707219 0.140555257 0.164192722 
##          95          99         100         102         107         121 
## 0.379266690 0.971043121 0.525270786 0.178225296 0.020997980 0.018537022 
##         127         134         139         143         146         147 
## 0.063308913 0.074958433 0.042379658 0.295676982 0.943548288 0.155731749 
##         151         154         156         157         159         164 
## 0.039986232 0.760835491 0.007410535 0.005471428 0.034042100 0.115611073 
##         165         166         171         180         181         185 
## 0.128889500 0.007449905 0.027582548 0.417665049 0.004621378 0.015178765 
##         187         189         194         197         203         205 
## 0.070338936 0.020049819 0.011652736 0.015860685 0.014891827 0.006316835 
##         206         211         213         214         216         223 
## 0.003128058 0.003290890 0.005710666 0.047054532 0.191320641 0.607736668 
##         226         228         232         233         235         237 
## 0.079176540 0.012455864 0.142718991 0.410047853 0.011477871 0.078542387 
##         238         243         245         256         258         259 
## 0.009702368 0.755303342 0.072965528 0.179220076 0.038360628 0.088690383 
##         261         267         268         269         273         275 
## 0.202764501 0.007349650 0.003863110 0.061200940 0.016003944 0.951657123 
##         278         279         282         288         290         291 
## 0.058978945 0.256617314 0.025571361 0.010642118 0.010407592 0.001805273 
##         295         296         304         305         306         307 
## 0.091364840 0.096289075 0.292735732 0.934845365 0.003706873 0.006565586 
##         309         311         316         320         326         327 
## 0.048061538 0.073698075 0.005760850 0.778081600 0.006950789 0.965108811 
##         330         341         345         351         353         357 
## 0.002467565 0.267586729 0.006375774 0.003789188 0.062359355 0.011094684 
##         363         366 
## 0.032521701 0.178580148
# summary(pred)
# str(pred)
# ์˜ˆ์ธก์น˜ : 0๊ณผ 1๋กœ ๋ณ€ํ™˜(0.7 ๊ธฐ์ค€)
result_pred <- ifelse(pred >= 0.7, 1, 0)
result_pred
##   8  13  16  17  20  26  31  32  38  39  41  46  55  61  63  64  65  66 
##   0   0   0   0   0   0   1   0   0   0   0   1   0   0   0   0   0   0 
##  67  72  75  76  77  80  82  84  85  86  88  93  95  99 100 102 107 121 
##   0   0   0   0   1   1   0   0   0   0   0   0   0   1   0   0   0   0 
## 127 134 139 143 146 147 151 154 156 157 159 164 165 166 171 180 181 185 
##   0   0   0   0   1   0   0   1   0   0   0   0   0   0   0   0   0   0 
## 187 189 194 197 203 205 206 211 213 214 216 223 226 228 232 233 235 237 
##   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 
## 238 243 245 256 258 259 261 267 268 269 273 275 278 279 282 288 290 291 
##   0   1   0   0   0   0   0   0   0   0   0   1   0   0   0   0   0   0 
## 295 296 304 305 306 307 309 311 316 320 326 327 330 341 345 351 353 357 
##   0   0   0   1   0   0   0   0   0   1   0   1   0   0   0   0   0   0 
## 363 366 
##   0   0
# table(data.frame)
table(result_pred)
## result_pred
##  0  1 
## 98 12
  • ๋ชจ๋ธ์„ ํ‰๊ฐ€ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ˜ผ๋ˆ ๋งคํŠธ๋ฆญ์Šค๋ฅผ ์ด์šฉํ•œ๋‹ค.
  • ์˜ˆ์ธก์น˜๊ฐ€ ํ™•๋ฅ  ๊ฐ’์œผ๋กœ ์ œ๊ณต๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฅผ ์ดํ•ญํ˜•์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค.
  • ifelse() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ์˜ˆ์ธก์น˜์˜ vector๋ณ€์ˆ˜(pred)๋ฅผ ์ž…๋ ฅ์œผ๋กœ ์ดํ•ญํ˜•์˜ vector ๋ณ€์ˆ˜(result_pred)๋ฅผ ์ƒ์„ฑ

2.1.7 ๋ชจ๋ธ ํ‰๊ฐ€: ๋ถ„๋ฅ˜์ •ํ™•๋„ ๊ณ„์‚ฐ

table(result_pred, test$RainTomorrow)
##            
## result_pred  0  1
##           0 86 12
##           1  0 12
## result_pred  0  1
##           0 89 10
##           1  3 7
(89 + 7) / nrow(test)
## [1] 0.8727273
  • ๋ชจ๋ธ์˜ ์˜ˆ์ธก์น˜์™€ ๊ฒ€์ •๋ฐ์ดํ„ฐ์˜ y ๋ณ€์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ํ˜ผ๋ˆ ๋งคํŠธ๋ฆญ์Šค๋ฅผ ์ƒ์„ฑ
  • ์ด๋ฅผ ํ† ๋Œ€๋กœ ๋ชจ๋ธ์˜ ๋ถ„๋ฅ˜์ •ํ™•๋„๋ฅผ ๊ณ„์‚ฐํ•  ์ˆ˜ ์žˆ๋‹ค.

2.1.8 ROC Curve๋ฅผ ์ด์šฉํ•œ ๋ชจ๋ธ ํ‰๊ฐ€

# Receiver Operating Characteristic
# install.packages("ROCR")
library(ROCR)
## Loading required package: gplots
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
# ROCR ํŒจํ‚ค์ง€ ์ œ๊ณต ํ•จ์ˆ˜ : prediction() -> performance
#
pr <- prediction(pred, test$RainTomorrow)
prf <- performance(pr, measure = "tpr", x.measure = "fpr")
plot(prf)

  • ROC ๊ณก์„ ์—์„œ ์™ผ์ชฝ ์ƒ๋‹จ์˜ ๊ณ„๋‹จ ๋ชจ์–‘์˜ ๋นˆ๊ณต๋ฐฑ๋งŒํผ์ด ๋ถ„๋ฅ˜์ •ํ™•๋„์—์„œ ์˜ค๋ถ„๋ฅ˜(missing)๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.

2.2 ๋ถ„๋ฅ˜๋ถ„์„

  • ๋‹ค์ˆ˜์˜ ๋ณ€์ˆ˜๋ฅผ ๊ฐ–๋Š” ๋ฐ์ดํ„ฐ ์…‹์„ ๋Œ€์ƒ์œผ๋กœ ํŠน์ • ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ์กฐ๊ฑด์œผ๋กœ ์ง€์ •ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„๋ฅ˜ํ•˜๊ณ  ํŠธ๋ฆฌ ํ˜•ํƒœ์˜ ๋ชจ๋ธ์„ ์ƒ์„ฑํ•˜๋Š” ๋ถ„์„๋ฐฉ๋ฒ•

2.2.1 ๋ถ„๋ฅ˜๋ถ„์„์˜ ํŠน์ง•

  • y๋ณ€์ˆ˜ ์กด์žฌ: ์„ค๋ช…๋ณ€์ˆ˜(x ๋ณ€์ˆ˜)์™€ ๋ฐ˜์‘๋ณ€์ˆ˜(y ๋ณ€์ˆ˜)๊ฐ€ ์กด์žฌํ•œ๋‹ค.
  • ์˜์‚ฌ๊ฒฐ์ •ํŠธ๋ฆฌ: ๋ถ„๋ฅ˜์˜ˆ์ธก๋ชจ๋ธ์— ์˜ํ•ด์„œ ์˜์‚ฌ๊ฒฐ์ •ํŠธ๋ฆฌ ํ˜•ํƒœ๋กœ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ถ„๋ฅ˜๋œ๋‹ค.
  • ๋น„๋ชจ์ˆ˜ ๊ฒ€์ •: ์„ ํ˜•์„ฑ, ์ •๊ทœ์„ฑ, ๋“ฑ๋ถ„์‚ฐ์„ฑ ๊ฐ€์ •์ด ํ•„์š” ์—†๋‹ค.
  • ์ถ”๋ก  ๊ธฐ๋Šฅ: ์œ ์˜์ˆ˜์ค€ ํŒ๋‹จ ๊ธฐ์ค€์ด ์—†๋‹ค.(์ถ”๋ก  ๊ธฐ๋Šฅ ์—†์Œ)
  • ํ™œ์šฉ ๋ถ„์•ผ: ๋Œ€์ถœ์€ํ–‰์—์„œ ๊ณ ๊ฐ์˜ ์‹ ์šฉ์ƒํƒœ, ๋ณ‘์›์—์„œ ํ™˜์ž์˜ ์ข…์–‘ ๊ฒ€์‚ฌ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ข…์–‘์˜ ์•…์„ฑ ๋˜๋Š” ์–‘์„ฑ ์—ฌ๋ถ€

2.2.2 ๋ถ„๋ฅ˜๋ถ„์„์˜ ์ ˆ์ฐจ

  1. ๊ธฐ์กด์˜ ์•Œ๋ ค์ง„ ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ง‘ํ•˜์—ฌ ํ•™์Šต๋ฐ์ดํ„ฐ(ํ•™์Šต ํ‘œ๋ณธ)๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
  2. ์ˆ˜์ง‘๋œ ํ•™์Šต๋ฐ์ดํ„ฐ๋ฅผ ๋Œ€์ƒ์œผ๋กœ ๋ถ„๋ฅ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ†ตํ•ด ์˜ˆ์ธก ๋ชจ๋ธ์„ ์ƒ์„ฑํ•œ๋‹ค.
  3. ๊ฒ€์ • ๋ฐ์ดํ„ฐ๋ฅผ ํ†ตํ•ด ๋ถ„๋ฅ˜๊ทœ์น™์ด ์ œ๋Œ€๋กœ ๋˜์—ˆ๋Š”์ง€ ๋ชจ๋ธ์„ ํ‰๊ฐ€(๋ชจํ˜•ํ‰๊ฐ€)ํ•œ๋‹ค.
  • ๋ชจํ˜•ํ‰๊ฐ€๋ž€? ์–ด๋–ค ๋ชจํ˜•์ด randomํ•˜๊ฒŒ ์˜ˆ์ธกํ•˜๋Š” ๋ชจํ˜•๋ณด๋‹ค ์˜ˆ์ธก๋ ฅ์ด ์šฐ์ˆ˜ํ•œ์ง€,
  • ๊ทธ๋ฆฌ๊ณ  ๊ณ ๋ ค๋œ ์—ฌ๋Ÿฌ ๋ชจํ˜• ์ค‘ ์–ด๋Š ๋ชจํ˜•์ด ๊ฐ€์žฅ ์ข‹์€ ์˜ˆ์ธก๋ ฅ์„ ๋ณด์œ ํ•˜๊ณ  ์žˆ๋Š”์ง€๋ฅผ ๋น„๊ต/๋ถ„์„ํ•˜๋Š” ๊ณผ์ •์„ ๋งํ•œ๋‹ค.
  1. ๋ชจ๋ธ ํ‰๊ฐ€๊ฒฐ๊ณผ๋ฅผ ํ† ๋Œ€๋กœ ๋ชจ๋ธ์„ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ๋ชจ๋ธ์„ ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ์— ์ ์šฉํ•˜์—ฌ ๋ฏธ๋ž˜ ๊ฒฐ๊ณผ๋ฅผ ์˜ˆ์ธก

2.2.3 rpart ํŒจํ‚ค์ง€๋ฅผ ์ด์šฉํ•œ ๋ถ„๋ฅ˜๋ถ„์„

# install.packages("rpart")
library(rpart)

2.2.4 ๋ฐ์ดํ„ฐ ํŠน์„ฑ ๋ณด๊ธฐ

str(weather)
## 'data.frame':    366 obs. of  15 variables:
##  $ Date         : chr  "2014-11-01" "2014-11-02" "2014-11-03" "2014-11-04" ...
##  $ MinTemp      : num  8 14 13.7 13.3 7.6 6.2 6.1 8.3 8.8 8.4 ...
##  $ MaxTemp      : num  24.3 26.9 23.4 15.5 16.1 16.9 18.2 17 19.5 22.8 ...
##  $ Rainfall     : num  0 3.6 3.6 39.8 2.8 0 0.2 0 0 16.2 ...
##  $ Sunshine     : num  6.3 9.7 3.3 9.1 10.6 8.2 8.4 4.6 4.1 7.7 ...
##  $ WindGustDir  : chr  "NW" "ENE" "NW" "NW" ...
##  $ WindGustSpeed: int  30 39 85 54 50 44 43 41 48 31 ...
##  $ WindDir      : chr  "NW" "W" "NNE" "W" ...
##  $ WindSpeed    : int  20 17 6 24 28 24 26 24 17 6 ...
##  $ Humidity     : int  29 36 69 56 49 57 47 57 48 32 ...
##  $ Pressure     : num  1015 1008 1007 1007 1018 ...
##  $ Cloud        : int  7 3 7 7 7 5 6 7 7 1 ...
##  $ Temp         : num  23.6 25.7 20.2 14.1 15.4 14.8 17.3 15.5 18.9 21.7 ...
##  $ RainToday    : chr  "No" "Yes" "Yes" "Yes" ...
##  $ RainTomorrow : chr  "Yes" "Yes" "Yes" "Yes" ...
names(weather)
##  [1] "Date"          "MinTemp"       "MaxTemp"       "Rainfall"     
##  [5] "Sunshine"      "WindGustDir"   "WindGustSpeed" "WindDir"      
##  [9] "WindSpeed"     "Humidity"      "Pressure"      "Cloud"        
## [13] "Temp"          "RainToday"     "RainTomorrow"

2.2.5 ๋ถ„๋ฅ˜๋ถ„์„ - ์˜์‚ฌ๊ฒฐ์ •ํŠธ๋ฆฌ ์ƒ์„ฑ

# RainTomorrow ์ปฌ๋Ÿผ์„ y๋ณ€์ˆ˜๋กœ ์ง€์ •
# ๋‚ ์”จ ์š”์ธ๊ณผ ๊ด€๋ จ์ด ์—†๋Š” Data์™€ RainToday ์ปฌ๋Ÿผ์„ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€ ๋ณ€์ˆ˜๋ฅผ x ๋ณ€์ˆ˜๋กœ ์ง€์ •ํ•˜์—ฌ ๋ถ„๋ฅ˜๋ชจ๋ธ์„ ์ˆ˜ํ–‰
# rpart(๋ฐ˜์‘๋ณ€์ˆ˜ ~ ์„ค๋ช…๋ณ€์ˆ˜, data)
weather.df <- rpart(RainTomorrow ~., data=weather[, c(-1, -14)], cp=0.01)

2.2.6 ๋ถ„๋ฅ˜๋ถ„์„์˜ ์‹œ๊ฐํ™”

# X11() # ์ฐจํŠธ๋ฅผ ๋„์šธ ๋ณ„๋„์˜ ์ฐฝ ์ƒ์„ฑ
plot(weather.df) # ํŠธ๋ฆฌ ํ”„๋ ˆ์ž„ ๋ณด์ž„
text(weather.df, use.n = T, cex=0.7) # ํ…์ŠคํŠธ ์ถ”๊ฐ€

post(weather.df, file="") # ํƒ€์›์ œ๊ณต - rpart ํŒจํ‚ค์ง€ ์ œ๊ณต 

  • Humidity >= 71.5์ผ ๋•Œ RainTomorrow๋Š” Yes:20, No:7
  • Humidity < 71.5 ์ด๊ณ  WindGustSpeed >= 64์ด๋ฉด RainTomorrow๋Š” Yes:12, No:6
  • ๋ถ„๊ธฐ ์กฐ๊ฑด์˜ ์ฐธ์ผ ๋•Œ ์™ผ์ชฝ, ๊ฑฐ์ง“์ผ ๋•Œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋ถ„๋ฅ˜
  • rpart() ํ•จ์ˆ˜์˜ cp ์†์„ฑ๊ฐ’์„ ๋†’์ด๋ฉด ๊ฐ€์ง€์ˆ˜๊ฐ€ ์ ์–ด์ง€๊ณ , ๋‚ฎ์ถ”๋ฉด ๊ฐ€์ง€ ์ˆ˜๊ฐ€ ๋งŽ์•„์ง„๋‹ค.
  • cp์˜ ๊ธฐ๋ณธ ๊ฐ’์€ 0.01

2.2.7 ์˜ˆ์ธก์น˜ ์ƒ์„ฑ๊ณผ ์ฝ”๋”ฉ ๋ณ€๊ฒฝ

2.2.7.1 ์˜ˆ์ธก์น˜ ์ƒ์„ฑ

weather_pred <- predict(weather.df, weather)
head(weather_pred)
##          No        Yes
## 1 0.9684685 0.03153153
## 2 0.8648649 0.13513514
## 3 0.3333333 0.66666667
## 4 0.8648649 0.13513514
## 5 0.9684685 0.03153153
## 6 0.9684685 0.03153153

2.2.7.2 y์˜ ๋ฒ”์ฃผ๋กœ ์ฝ”๋”ฉ ๋ณ€ํ™˜ : Yes(0.5์ด์ƒ), No(0.5 ๋ฏธ๋งŒ)

weather_pred2 <- ifelse(weather_pred[,2] >= 0.7, 'Yes', 'No' )
  • rpart์˜ ๋ถ„๋ฅ˜๋ชจ๋ธ์˜ ์˜ˆ์ธก์น˜๋Š” ๋น„ ์œ ๋ฌด๋ฅผ 0 ~ 1 ์‚ฌ์ด์˜ ํ™•๋ฅ ๊ฐ’์œผ๋กœ ์˜ˆ์ธกํ•œ๋‹ค.
  • ๋”ฐ๋ผ์„œ 0.7 ์ด์ƒ์ด๋ฉด ๋น„๊ฐ€ ์˜ค๋Š” ๊ฒฝ์šฐ๋กœ, 0.7 ๋ฏธ๋งŒ์ด๋ฉด ๋น„๊ฐ€ ์˜ค์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋กœ ๋ฒ”์ฃผํ™”ํ•˜์—ฌ ์ฝ”๋”ฉ ๋ณ€๊ฒฝํ•ด์•ผ ํ˜ผ๋ˆ ๋งคํŠธ๋ฆญ์Šค๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ถ„๋ฅ˜์ •ํ™•๋„๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค.

2.2.8 ๋ชจ๋ธ ํ‰๊ฐ€

table(weather_pred2, weather$RainTomorrow)
##              
## weather_pred2  No Yes
##           No  287  29
##           Yes  13  37
(287 + 37) / nrow(weather)
## [1] 0.8852459
  • y ๋ณ€์ˆ˜์˜ ๋ฒ”์ฃผ๋กœ ์ฝ”๋”ฉ ๋ณ€๊ฒฝํ•œ ๋ณ€์ˆ˜๋ฅผ ๋Œ€์ƒ์œผ๋กœ ์›ํ˜• ๋ฐ์ดํ„ฐ์˜ y๋ณ€์ˆ˜์™€ ํ˜ผ๋ˆ ๋งคํŠธ๋ฆญ์Šค๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ๋ถ„๋ฅ˜์ •ํ™•๋„๋ฅผ ๊ณ„์‚ฐ