summaryrefslogtreecommitdiff
path: root/posts/2020-01-16-Image-Classifier-Using-Turicreate/index.html
blob: 48254d881e32c133be3748dd0f67064404f8a03e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><meta name="og:site_name" content="Navan Chauhan"/><link rel="canonical" href="https://navanchauhan.github.io/posts/2020-01-16-Image-Classifier-Using-Turicreate"/><meta name="twitter:url" content="https://navanchauhan.github.io/posts/2020-01-16-Image-Classifier-Using-Turicreate"/><meta name="og:url" content="https://navanchauhan.github.io/posts/2020-01-16-Image-Classifier-Using-Turicreate"/><title>Creating a Custom Image Classifier using Turicreate to detect Smoke and Fire | Navan Chauhan</title><meta name="twitter:title" content="Creating a Custom Image Classifier using Turicreate to detect Smoke and Fire | Navan Chauhan"/><meta name="og:title" content="Creating a Custom Image Classifier using Turicreate to detect Smoke and Fire | Navan Chauhan"/><meta name="description" content="Tutorial on creating a custom Image Classifier using Turicreate and a dataset from Kaggle"/><meta name="twitter:description" content="Tutorial on creating a custom Image Classifier using Turicreate and a dataset from Kaggle"/><meta name="og:description" content="Tutorial on creating a custom Image Classifier using Turicreate and a dataset from Kaggle"/><meta name="twitter:card" content="summary"/><link rel="stylesheet" href="/styles.css" type="text/css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="shortcut icon" href="/images/favicon.png" type="image/png"/><link rel="alternate" href="/feed.rss" type="application/rss+xml" title="Subscribe to Navan Chauhan"/><meta name="twitter:image" content="https://navanchauhan.github.io/images/logo.png"/><meta name="og:image" content="https://navanchauhan.github.io/images/logo.png"/></head><head><script>var _paq=window._paq=window._paq||[];_paq.push(['trackPageView']),_paq.push(['enableLinkTracking']),function(){var a='http://navanspi.duckdns.org:6969/analytics/';_paq.push(['setTrackerUrl',a+'matomo.php']),_paq.push(['setSiteId','1']);var e=document,t=e.createElement('script'),p=e.getElementsByTagName('script')[0];t.type='text/javascript',t.async=!0,t.src=a+'matomo.js',p.parentNode.insertBefore(t,p)}();</script></head><head><script src="https://www.googletagmanager.com/gtag/js?id=UA-108635191-1v"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-108635191-1');</script></head><body class="item-page"><header><div class="wrapper"><a class="site-name" href="/">Navan Chauhan</a><nav><ul><li><a href="/about">About Me</a></li><li><a class="selected" href="/posts">Posts</a></li><li><a href="/publications">Publications</a></li><li><a href="/assets/résumé.pdf">Résumé</a></li><li><a href="https://navanchauhan.github.io/repo">Repo</a></li></ul></nav></div></header><div class="wrapper"><article><div class="content"><span class="reading-time">6 minute read</span><span class="reading-time">Created on January 16, 2020</span><span class="reading-time">Last modified on June 1, 2020</span><h1>Creating a Custom Image Classifier using Turicreate to detect Smoke and Fire</h1><p><em>For setting up Kaggle with Google Colab, please refer to <a href="/posts/2020-01-15-Setting-up-Kaggle-to-use-with-Colab/"> my previous post</a></em></p><h2>Dataset</h2><h3>Mounting Google Drive</h3><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">google.colab</span> <span class="kn">import</span> <span class="n">drive</span>
<span class="n">drive</span><span class="o">.</span><span class="n">mount</span><span class="p">(</span><span class="s1">&#39;/content/drive&#39;</span><span class="p">)</span>
</div></code></pre><h3>Downloading Dataset from Kaggle</h3><pre><code><div class="highlight"><span></span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">&#39;KAGGLE_CONFIG_DIR&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;/content/drive/My Drive/&quot;</span>
<span class="err">!</span><span class="n">kaggle</span> <span class="n">datasets</span> <span class="n">download</span> <span class="n">ashutosh69</span><span class="o">/</span><span class="n">fire</span><span class="o">-</span><span class="ow">and</span><span class="o">-</span><span class="n">smoke</span><span class="o">-</span><span class="n">dataset</span>
<span class="err">!</span><span class="n">unzip</span> <span class="s2">&quot;fire-and-smoke-dataset.zip&quot;</span>
</div></code></pre><h2>Pre-Processing</h2><pre><code><div class="highlight"><span></span><span class="nt">!mkdir</span><span class="na"> default smoke fire</span>
</div></code></pre><p><br></p><pre><code><div class="highlight"><span></span><span class="nt">!ls</span><span class="na"> data/data/img_data/train/default/*.jpg</span>
</div></code></pre><p><br></p><pre><code><div class="highlight"><span></span><span class="nt">img_1002.jpg</span><span class="na">   img_20.jpg     img_519.jpg     img_604.jpg       img_80.jpg</span>
<span class="na">img_1003.jpg   img_21.jpg     img_51.jpg     img_60.jpg       img_8.jpg</span>
<span class="na">img_1007.jpg   img_22.jpg     img_520.jpg     img_61.jpg       img_900.jpg</span>
<span class="na">img_100.jpg    img_23.jpg     img_521.jpg    &#39;img_62 (2).jpg&#39;   img_920.jpg</span>
<span class="na">img_1014.jpg   img_24.jpg    &#39;img_52 (2).jpg&#39;     img_62.jpg       img_921.jpg</span>
<span class="na">img_1018.jpg   img_29.jpg     img_522.jpg    &#39;img_63 (2).jpg&#39;   img_922.jpg</span>
<span class="na">img_101.jpg    img_3000.jpg   img_523.jpg     img_63.jpg       img_923.jpg</span>
<span class="na">img_1027.jpg   img_335.jpg    img_524.jpg     img_66.jpg       img_924.jpg</span>
<span class="na">img_102.jpg    img_336.jpg    img_52.jpg     img_67.jpg       img_925.jpg</span>
<span class="na">img_1042.jpg   img_337.jpg    img_530.jpg     img_68.jpg       img_926.jpg</span>
<span class="na">img_1043.jpg   img_338.jpg    img_531.jpg     img_700.jpg       img_927.jpg</span>
<span class="na">img_1046.jpg   img_339.jpg   &#39;img_53 (2).jpg&#39;     img_701.jpg       img_928.jpg</span>
<span class="na">img_1052.jpg   img_340.jpg    img_532.jpg     img_702.jpg       img_929.jpg</span>
<span class="na">img_107.jpg    img_341.jpg    img_533.jpg     img_703.jpg       img_930.jpg</span>
<span class="na">img_108.jpg    img_3.jpg      img_537.jpg     img_704.jpg       img_931.jpg</span>
<span class="na">img_109.jpg    img_400.jpg    img_538.jpg     img_705.jpg       img_932.jpg</span>
<span class="na">img_10.jpg     img_471.jpg    img_539.jpg     img_706.jpg       img_933.jpg</span>
<span class="na">img_118.jpg    img_472.jpg    img_53.jpg     img_707.jpg       img_934.jpg</span>
<span class="na">img_12.jpg     img_473.jpg    img_540.jpg     img_708.jpg       img_935.jpg</span>
<span class="na">img_14.jpg     img_488.jpg    img_541.jpg     img_709.jpg       img_938.jpg</span>
<span class="na">img_15.jpg     img_489.jpg   &#39;img_54 (2).jpg&#39;     img_70.jpg       img_958.jpg</span>
<span class="na">img_16.jpg     img_490.jpg    img_542.jpg     img_710.jpg       img_971.jpg</span>
<span class="na">img_17.jpg     img_491.jpg    img_543.jpg    &#39;img_71 (2).jpg&#39;   img_972.jpg</span>
<span class="na">img_18.jpg     img_492.jpg    img_54.jpg     img_71.jpg       img_973.jpg</span>
<span class="na">img_19.jpg     img_493.jpg   &#39;img_55 (2).jpg&#39;     img_72.jpg       img_974.jpg</span>
<span class="na">img_1.jpg      img_494.jpg    img_55.jpg     img_73.jpg       img_975.jpg</span>
<span class="na">img_200.jpg    img_495.jpg    img_56.jpg     img_74.jpg       img_980.jpg</span>
<span class="na">img_201.jpg    img_496.jpg    img_57.jpg     img_75.jpg       img_988.jpg</span>
<span class="na">img_202.jpg    img_497.jpg    img_58.jpg     img_76.jpg       img_9.jpg</span>
<span class="na">img_203.jpg    img_4.jpg      img_59.jpg     img_77.jpg</span>
<span class="na">img_204.jpg    img_501.jpg    img_601.jpg     img_78.jpg</span>
<span class="na">img_205.jpg    img_502.jpg    img_602.jpg     img_79.jpg</span>
<span class="na">img_206.jpg    img_50.jpg     img_603.jpg     img_7.jpg</span>
</div></code></pre><p>The image files are not actually JPEG, thus we first need to save them in the correct format for Turicreate</p><pre><code><div class="highlight"><span></span><span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">glob</span>


<span class="n">folders</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;default&quot;</span><span class="p">,</span><span class="s2">&quot;smoke&quot;</span><span class="p">,</span><span class="s2">&quot;fire&quot;</span><span class="p">]</span>
<span class="k">for</span> <span class="n">folder</span> <span class="ow">in</span> <span class="n">folders</span><span class="p">:</span>
  <span class="n">n</span> <span class="o">=</span> <span class="mi">1</span>
  <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">&quot;./data/data/img_data/train/&quot;</span> <span class="o">+</span> <span class="n">folder</span> <span class="o">+</span> <span class="s2">&quot;/*.jpg&quot;</span><span class="p">):</span>
    <span class="n">im</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
    <span class="n">rgb_im</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="s1">&#39;RGB&#39;</span><span class="p">)</span>
    <span class="n">rgb_im</span><span class="o">.</span><span class="n">save</span><span class="p">((</span><span class="n">folder</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;.jpg&quot;</span><span class="p">),</span> <span class="n">quality</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="n">n</span> <span class="o">+=</span><span class="mi">1</span> 
  <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">&quot;./data/data/img_data/train/&quot;</span> <span class="o">+</span> <span class="n">folder</span> <span class="o">+</span> <span class="s2">&quot;/*.jpg&quot;</span><span class="p">):</span>
    <span class="n">im</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
    <span class="n">rgb_im</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="s1">&#39;RGB&#39;</span><span class="p">)</span>
    <span class="n">rgb_im</span><span class="o">.</span><span class="n">save</span><span class="p">((</span><span class="n">folder</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">n</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;.jpg&quot;</span><span class="p">),</span> <span class="n">quality</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
    <span class="n">n</span> <span class="o">+=</span><span class="mi">1</span>
</div></code></pre><p><br></p><pre><code><div class="highlight"><span></span><span class="nt">!mkdir</span><span class="na"> train</span>
<span class="na">!mv default ./train</span>
<span class="na">!mv smoke ./train</span>
<span class="na">!mv fire ./train</span>
</div></code></pre><h2>Making the Image Classifier</h2><h3>Making an SFrame</h3><pre><code><div class="highlight"><span></span><span class="nt">!pip</span><span class="na"> install turicreate</span>
</div></code></pre><p><br></p><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">turicreate</span> <span class="k">as</span> <span class="nn">tc</span>
<span class="kn">import</span> <span class="nn">os</span>

<span class="n">data</span> <span class="o">=</span> <span class="n">tc</span><span class="o">.</span><span class="n">image_analysis</span><span class="o">.</span><span class="n">load_images</span><span class="p">(</span><span class="s2">&quot;./train&quot;</span><span class="p">,</span> <span class="n">with_path</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="n">data</span><span class="p">[</span><span class="s2">&quot;label&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;path&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="k">lambda</span> <span class="n">path</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">path</span><span class="p">)))</span>

<span class="nb">print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>

<span class="n">data</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="s1">&#39;fire-smoke.sframe&#39;</span><span class="p">)</span>
</div></code></pre><p><br></p><pre><code><div class="highlight"><span></span><span class="nt">+-------------------------+------------------------+</span>
<span class="err">|           path          |         image          |</span>
<span class="nt">+-------------------------+------------------------+</span>
<span class="err">|  ./train/default/1.jpg  | Height: 224 Width: 224 |</span>
<span class="err">|  ./train/default/10.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/100.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/101.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/102.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/103.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/104.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/105.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/106.jpg | Height: 224 Width: 224 |</span>
<span class="err">| ./train/default/107.jpg | Height: 224 Width: 224 |</span>
<span class="nt">+-------------------------+------------------------+</span>
<span class="nt">[2028</span><span class="na"> rows x 2 columns]</span>
<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span>
<span class="nt">You</span><span class="na"> can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.</span>
<span class="na">+-------------------------+------------------------+---------+</span>
<span class="p">|</span><span class="na">           path          </span><span class="p">|</span><span class="na">         image          </span><span class="p">|</span><span class="na">  label  </span><span class="p">|</span>
<span class="nt">+-------------------------+------------------------+---------+</span>
<span class="err">|  ./train/default/1.jpg  | Height: 224 Width: 224 | default |</span>
<span class="err">|  ./train/default/10.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/100.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/101.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/102.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/103.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/104.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/105.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/106.jpg | Height: 224 Width: 224 | default |</span>
<span class="err">| ./train/default/107.jpg | Height: 224 Width: 224 | default |</span>
<span class="nt">+-------------------------+------------------------+---------+</span>
<span class="nt">[2028</span><span class="na"> rows x 3 columns]</span>
<span class="na">Note</span><span class="p">:</span><span class="err"> </span><span class="nc">Only</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">head</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">the</span><span class="err"> </span><span class="nc">SFrame</span><span class="err"> </span><span class="nc">is</span><span class="err"> </span><span class="nc">printed.</span>
<span class="nt">You</span><span class="na"> can use print_rows(num_rows=m, num_columns=n) to print more rows and columns.</span>
</div></code></pre><h3>Making the Model</h3><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">turicreate</span> <span class="k">as</span> <span class="nn">tc</span>

<span class="c1"># Load the data</span>
<span class="n">data</span> <span class="o">=</span>  <span class="n">tc</span><span class="o">.</span><span class="n">SFrame</span><span class="p">(</span><span class="s1">&#39;fire-smoke.sframe&#39;</span><span class="p">)</span>

<span class="c1"># Make a train-test split</span>
<span class="n">train_data</span><span class="p">,</span> <span class="n">test_data</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">random_split</span><span class="p">(</span><span class="mf">0.8</span><span class="p">)</span>

<span class="c1"># Create the model</span>
<span class="n">model</span> <span class="o">=</span> <span class="n">tc</span><span class="o">.</span><span class="n">image_classifier</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">train_data</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="s1">&#39;label&#39;</span><span class="p">)</span>

<span class="c1"># Save predictions to an SArray</span>
<span class="n">predictions</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">test_data</span><span class="p">)</span>

<span class="c1"># Evaluate the model and print the results</span>
<span class="n">metrics</span> <span class="o">=</span> <span class="n">model</span><span class="o">.</span><span class="n">evaluate</span><span class="p">(</span><span class="n">test_data</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">metrics</span><span class="p">[</span><span class="s1">&#39;accuracy&#39;</span><span class="p">])</span>

<span class="c1"># Save the model for later use in Turi Create</span>
<span class="n">model</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="s1">&#39;fire-smoke.model&#39;</span><span class="p">)</span>

<span class="c1"># Export for use in Core ML</span>
<span class="n">model</span><span class="o">.</span><span class="n">export_coreml</span><span class="p">(</span><span class="s1">&#39;fire-smoke.mlmodel&#39;</span><span class="p">)</span>
</div></code></pre><p><br></p><pre><code><div class="highlight"><span></span><span class="nt">Performing</span><span class="na"> feature extraction on resized images...</span>
<span class="na">Completed   64/1633</span>
<span class="na">Completed  128/1633</span>
<span class="na">Completed  192/1633</span>
<span class="na">Completed  256/1633</span>
<span class="na">Completed  320/1633</span>
<span class="na">Completed  384/1633</span>
<span class="na">Completed  448/1633</span>
<span class="na">Completed  512/1633</span>
<span class="na">Completed  576/1633</span>
<span class="na">Completed  640/1633</span>
<span class="na">Completed  704/1633</span>
<span class="na">Completed  768/1633</span>
<span class="na">Completed  832/1633</span>
<span class="na">Completed  896/1633</span>
<span class="na">Completed  960/1633</span>
<span class="na">Completed 1024/1633</span>
<span class="na">Completed 1088/1633</span>
<span class="na">Completed 1152/1633</span>
<span class="na">Completed 1216/1633</span>
<span class="na">Completed 1280/1633</span>
<span class="na">Completed 1344/1633</span>
<span class="na">Completed 1408/1633</span>
<span class="na">Completed 1472/1633</span>
<span class="na">Completed 1536/1633</span>
<span class="na">Completed 1600/1633</span>
<span class="na">Completed 1633/1633</span>
<span class="na">PROGRESS</span><span class="p">:</span><span class="err"> </span><span class="nc">Creating</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">validation</span><span class="err"> </span><span class="nc">set</span><span class="err"> </span><span class="nc">from</span><span class="err"> </span><span class="nc">5</span><span class="err"> </span><span class="nc">percent</span><span class="err"> </span><span class="nc">of</span><span class="err"> </span><span class="nc">training</span><span class="err"> </span><span class="nc">data.</span><span class="err"> </span><span class="nc">This</span><span class="err"> </span><span class="nc">may</span><span class="err"> </span><span class="nc">take</span><span class="err"> </span><span class="nc">a</span><span class="err"> </span><span class="nc">while.</span>
          <span class="err">You can set ``validation_set=None`` to disable validation tracking.</span>

<span class="nt">Logistic</span><span class="na"> regression</span><span class="p">:</span>
<span class="nt">--------------------------------------------------------</span>
<span class="nt">Number</span><span class="na"> of examples          </span><span class="p">:</span><span class="err"> </span><span class="nc">1551</span>
<span class="nt">Number</span><span class="na"> of classes           </span><span class="p">:</span><span class="err"> </span><span class="nc">3</span>
<span class="nt">Number</span><span class="na"> of feature columns   </span><span class="p">:</span><span class="err"> </span><span class="nc">1</span>
<span class="nt">Number</span><span class="na"> of unpacked features </span><span class="p">:</span><span class="err"> </span><span class="nc">2048</span>
<span class="nt">Number</span><span class="na"> of coefficients      </span><span class="p">:</span><span class="err"> </span><span class="nc">4098</span>
<span class="nt">Starting</span><span class="na"> L-BFGS</span>
<span class="na">--------------------------------------------------------</span>
<span class="na">+-----------+----------+-----------+--------------+-------------------+---------------------+</span>
<span class="p">|</span><span class="na"> Iteration </span><span class="p">|</span><span class="na"> Passes   </span><span class="p">|</span><span class="na"> Step size </span><span class="p">|</span><span class="na"> Elapsed Time </span><span class="p">|</span><span class="na"> Training Accuracy </span><span class="p">|</span><span class="na"> Validation Accuracy </span><span class="p">|</span>
<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span>
<span class="err">| 0         | 6        | 0.018611  | 0.891830     | 0.553836          | 0.560976            |</span>
<span class="err">| 1         | 10       | 0.390832  | 1.622383     | 0.744681          | 0.792683            |</span>
<span class="err">| 2         | 11       | 0.488541  | 1.943987     | 0.733075          | 0.804878            |</span>
<span class="err">| 3         | 14       | 2.442703  | 2.512545     | 0.727917          | 0.841463            |</span>
<span class="err">| 4         | 15       | 2.442703  | 2.826964     | 0.861380          | 0.853659            |</span>
<span class="err">| 9         | 28       | 2.340435  | 5.492035     | 0.941328          | 0.975610            |</span>
<span class="nt">+-----------+----------+-----------+--------------+-------------------+---------------------+</span>
<span class="nt">Performing</span><span class="na"> feature extraction on resized images...</span>
<span class="na">Completed  64/395</span>
<span class="na">Completed 128/395</span>
<span class="na">Completed 192/395</span>
<span class="na">Completed 256/395</span>
<span class="na">Completed 320/395</span>
<span class="na">Completed 384/395</span>
<span class="na">Completed 395/395</span>
<span class="na">0.9316455696202531</span>
</div></code></pre><p>We just got an accuracy of 94% on Training Data and 97% on Validation Data!</p></div><span>Tagged with: </span><ul class="tag-list"><li><a href="/tags/tutorial">Tutorial</a></li><li><a href="/tags/colab">Colab</a></li><li><a href="/tags/turicreate">Turicreate</a></li></ul></article></div><footer><p>Made with ❤️ using <a href="https://github.com/johnsundell/publish">Publish</a></p><p><a href="/feed.rss">RSS feed</a></p></footer></body></html>