keesephillips commited on
Commit
a7e459d
·
verified ·
1 Parent(s): a1011d3

Upload 19 files

Browse files
.gitattributes CHANGED
@@ -1,35 +1,37 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ data/thads2011.txt filter=lfs diff=lfs merge=lfs -text
37
+ data/thads2013n.txt filter=lfs diff=lfs merge=lfs -text
.streamlit/config.toml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ [theme]
2
+ backgroundColor="#525252"
3
+ secondaryBackgroundColor="#5b5b5c"
4
+ textColor="#f3f6ff"
5
+ font="monospace"
README.md CHANGED
@@ -1,12 +1,73 @@
1
- ---
2
- title: Xai Final Project
3
- emoji: 🚀
4
- colorFrom: pink
5
- colorTo: purple
6
- sdk: streamlit
7
- sdk_version: 1.40.2
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: XAI Term Project
3
+ emoji: 👁
4
+ colorFrom: red
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.40.2
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # Explainable AI for Housing Estimates
13
+
14
+ ## Instructions to Run
15
+ 1. Clone the repo
16
+ ```bash
17
+ git clone https://huggingface.co/spaces/keesephillips/xai_term_project
18
+ ```
19
+ 2. Install all the package dependencies
20
+ ```bash
21
+ pip install -r requirements.txt
22
+ ```
23
+ 3. Run the application via streamlit
24
+ ```bash
25
+ streamlit run app.py
26
+ ```
27
+ 4. Access via localhost (port 8501 on windows)
28
+
29
+ ## Background
30
+
31
+ _This application is designed to demonstrate an understanding of how complex problems can be explained using Generalized Additive Models (GAMs) and LIME, and when used in conjunction of one another can sometimes explain the decision boundary no matter the complexity._
32
+
33
+ **Generalized Additive Models**
34
+
35
+ GAMs are an extension of linear regression models that allow for non-linear relationships between the features and target.
36
+
37
+ GAMs use "smooth functions of our feature variables, which can take on a great many forms, with more detail on what that means in the following section" (Clarke). This is where GAMs differ from generalized linear models like linear regression. A GAM is "composed of a sum of smooth functions of features instead of or in addition to the standard linear feature contributions" (Clarke). These smooth functions or spline functions can create non-linear decision boundaries. Spline functions show the partial dependence of each feature on the target variable, enabling a high-level understanding of the model predictions.
38
+
39
+ **Local Interpretable Model-agnostic Explanations (LIME)**
40
+ - Local - explanation should reflect the behavior of the classifier in the neighborhood of the instance being predicted
41
+ - Interpretable - human is able to make sense of it
42
+ - Model Agnostic - applied to any machine learning model
43
+ - Explanation - that helps interpret the model
44
+
45
+ LIME is a powerful tool that explains some predictions created by a neural network.
46
+ However, LIME only explains a local area within the neural network model and does not fully explain the entire decision space of a given model.
47
+ This is an important consideration when using LIME, for example, you are only mapping a subset of the entire decision space of a black box model.
48
+
49
+
50
+ ## Purpose
51
+
52
+ This project aims to provide insights into Generalized Additive Models and how they can be used to create non-linear solutions.
53
+
54
+ ## Models
55
+
56
+ - **Neural Network**: 3 linear layers using PyTorch
57
+ - **GAM**: Linear GAM using PyGAM
58
+
59
+ ## Author
60
+
61
+ Created by Keese Phillips
62
+
63
+ ## Contact
64
+
65
+ For any questions or inquiries, please contact [keese.phillips@duke.edu](mailto:keese.phillips@duke.edu)
66
+
67
+ ## References
68
+
69
+ Clark, Michael. "Generalized Additive Models." Generalized Additive Models, m-clark.github.io/generalized-additive-models/introduction.html. Accessed 2 Dec. 2024.
70
+
71
+ ## Attribution
72
+
73
+ [Dr. Brinnae Bent](https://github.com/AIPI-590-XAI/Duke-AI-XAI)
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_option_menu import option_menu
3
+ from pages import main, about
4
+
5
+ if __name__ == '__main__':
6
+
7
+ st.set_page_config(page_title="Generalized Additive Models", page_icon="🚀")
8
+
9
+ page = option_menu(
10
+ menu_title=None,
11
+ options=["Home", "About"],
12
+ icons=["house", "book"],
13
+ menu_icon="cast",
14
+ default_index=0,
15
+ orientation="horizontal",
16
+ )
17
+
18
+ if page == "Home":
19
+ st.switch_page("pages/main.py")
20
+ elif page == "About":
21
+ st.switch_page("pages/about.py")
22
+
23
+ st.info("This app is for explaining the problem domain using Generalized Additive Models")
24
+
data/cal_cities_lat_long.csv ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Name,Latitude,Longitude
2
+ Adelanto,34.582769,-117.409214
3
+ Agoura Hills,34.153339,-118.761675
4
+ Alameda,37.765206,-122.241636
5
+ Albany,37.886869,-122.297747
6
+ Alhambra,34.095286,-118.127014
7
+ Aliso Viejo,33.575,-117.725556
8
+ Alturas,41.487114,-120.542456
9
+ Amador City,38.419356,-120.824103
10
+ American Canyon,38.174917,-122.260803
11
+ Anaheim,33.835292,-117.914503
12
+ Anderson,40.448208,-122.297783
13
+ Angels,38.067783,-120.538531
14
+ Antioch,38.004922,-121.805789
15
+ Arcadia,34.139728,-118.035344
16
+ Arcata,40.866517,-124.082839
17
+ Arroyo Grande,35.118586,-120.590725
18
+ Artesia,33.865847,-118.083122
19
+ Arvin,35.2018,-118.833106
20
+ Atascadero,35.489417,-120.670725
21
+ Atwater,37.347717,-120.609083
22
+ Auburn,38.896564,-121.076889
23
+ Avalon,33.342819,-118.328228
24
+ Avenal,36.004122,-120.129028
25
+ Azusa,34.133619,-117.907564
26
+ Bakersfield,35.373292,-119.018711
27
+ Baldwin Park,34.085286,-117.960897
28
+ Banning,33.925572,-116.876411
29
+ Barstow,34.895797,-117.017283
30
+ Beaumont,33.929461,-116.977247
31
+ Bell,33.977514,-118.187017
32
+ Bell Gardens,33.965292,-118.151458
33
+ Bellflower,33.881683,-118.117011
34
+ Belmont,37.520214,-122.275800
35
+ Belvedere,37.872703,-122.464417
36
+ Berkeley,37.871592,-122.272747
37
+ Beverly Hills,34.073619,-118.400356
38
+ Big Bear Lake,34.243897,-116.911422
39
+ Biggs,39.412389,-121.712750
40
+ Bishop,37.363539,-118.395111
41
+ Blue Lake,40.882908,-123.983950
42
+ Blythe,33.617233,-114.589175
43
+ Bradbury,34.14695,-117.970897
44
+ Brawley,32.978658,-115.530267
45
+ Brea,33.916681,-117.900061
46
+ Brentwood,34.057361,-118.480511
47
+ Brisbane,37.680767,-122.399972
48
+ Buellton,34.613597,-120.192650
49
+ Buena Park,33.867514,-117.998117
50
+ Burbank,34.180839,-118.308967
51
+ Burlingame,37.584103,-122.366083
52
+ Calabasas,34.138333,-118.660833
53
+ Calexico,32.678947,-115.498883
54
+ California City,35.1258,-117.985903
55
+ Calimesa,34.003903,-117.061975
56
+ Calipatria,33.125597,-115.514153
57
+ Calistoga,38.578797,-122.579706
58
+ Camarillo,34.216394,-119.037603
59
+ Campbell,37.287164,-121.949958
60
+ Canyon Lake,33.685022,-117.273092
61
+ Capitola,36.975228,-121.953292
62
+ Carlsbad,33.158092,-117.350594
63
+ Carmel-By-the-Sea,36.555239,-121.923289
64
+ Carpinteria,34.398883,-119.518456
65
+ Carson,33.831406,-118.282017
66
+ Cathedral City,33.779742,-116.465292
67
+ Ceres,37.594933,-120.957711
68
+ Cerritos,33.858347,-118.064786
69
+ Chico,39.728494,-121.837478
70
+ Chino,34.012236,-117.688944
71
+ Chino Hills,33.989819,-117.732586
72
+ Chowchilla,37.123,-120.260175
73
+ Chula Vista,32.640053,-117.084197
74
+ Citrus Heights,38.707125,-121.281061
75
+ Claremont,34.096675,-117.719778
76
+ Clayton,37.941033,-121.935792
77
+ Clearlake,38.958231,-122.626372
78
+ Cloverdale,38.805461,-123.017222
79
+ Clovis,36.825228,-119.702919
80
+ Coachella,33.6803,-116.173894
81
+ Coalinga,36.139678,-120.360150
82
+ Colfax,39.100731,-120.953275
83
+ Colton,34.073903,-117.313656
84
+ Colusa,39.214333,-122.009417
85
+ Commerce,34.000569,-118.159792
86
+ Compton,33.89585,-118.220072
87
+ Concord,37.977978,-122.031072
88
+ Corcoran,37.977978,-122.031072
89
+ Corning,39.927658,-122.179156
90
+ Corona,33.875294,-117.566439
91
+ Coronado,32.685886,-117.183089
92
+ Costa Mesa,33.641133,-117.918669
93
+ Cotati,38.327778,-122.709167
94
+ Covina,34.090008,-117.890339
95
+ Crescent City,41.755947,-124.201747
96
+ Cudahy,33.960569,-118.185350
97
+ Culver City,34.021122,-118.396467
98
+ Cupertino,37.322997,-122.032183
99
+ Cypress,37.320531,-121.962242
100
+ Daly City,37.687925,-122.470208
101
+ Dana Point,33.466972,-117.698108
102
+ Davis,38.544906,-121.740517
103
+ Del Mar,32.959489,-117.265314
104
+ Del Rey Oaks,36.593292,-121.834953
105
+ Delano,35.768842,-119.247053
106
+ Desert Hot Springs,33.961125,-116.501678
107
+ Diamond Bar,34.028622,-117.810336
108
+ Dinuba,36.543283,-119.387067
109
+ Dixon,38.445464,-121.823297
110
+ Dorris,41.967369,-121.918061
111
+ Dos Palos,36.986058,-120.626572
112
+ Downey,33.940014,-118.132569
113
+ Duarte,34.13945,-117.977286
114
+ Dublin,37.702153,-121.935792
115
+ Dunsmuir,41.208208,-122.271953
116
+ East Palo Alto,37.468828,-122.141075
117
+ Eastvale,33.963056,-117.563889
118
+ El Cajon,32.794772,-116.962528
119
+ El Centro,32.792,-115.563050
120
+ El Cerrito,37.916133,-122.310764
121
+ El Monte,34.068622,-118.027567
122
+ El Segundo,33.919181,-118.416464
123
+ Elk Grove,38.4088,-121.371617
124
+ Emeryville,37.831317,-122.285247
125
+ Encinitas,33.036986,-117.291983
126
+ Escalon,37.797428,-120.996603
127
+ Escondido,33.119208,-117.086422
128
+ Etna,41.456806,-122.894756
129
+ Eureka,40.802072,-124.163672
130
+ Exeter,36.296061,-119.142053
131
+ Fairfield,38.249358,-122.039967
132
+ Farmersville,36.297728,-119.206778
133
+ Ferndale,40.576242,-124.263944
134
+ Fillmore,34.399164,-118.918153
135
+ Firebaugh,36.858839,-120.456008
136
+ Folsom,38.677958,-121.176058
137
+ Fontana,34.092233,-117.435047
138
+ Fort Bragg,39.445722,-123.805292
139
+ Fort Jones,41.663864,-124.252892
140
+ Fortuna,40.598186,-124.157275
141
+ Foster City,37.558547,-122.271078
142
+ Fountain Valley,33.709186,-117.953669
143
+ Fowler,36.630506,-119.678469
144
+ Fremont,37.548269,-121.988572
145
+ Fresno,36.746842,-119.772586
146
+ Fullerton,33.870292,-117.925339
147
+ Galt,38.254636,-121.299947
148
+ Garden Grove,33.773906,-117.941447
149
+ Gardena,33.88835,-118.308961
150
+ Gilroy,37.005783,-121.568275
151
+ Glendale,34.142508,-118.255075
152
+ Glendora,34.136119,-117.865339
153
+ Goleta,34.435828,-119.827639
154
+ Gonzales,36.506628,-121.444381
155
+ Grand Terrace,34.033903,-117.313653
156
+ Grass Valley,39.219061,-121.061061
157
+ Greenfield,36.3208,-121.243814
158
+ Gridley,39.363778,-121.693583
159
+ Grover Beach,35.121642,-120.621283
160
+ Guadalupe,34.971644,-120.571836
161
+ Gustine,37.257717,-120.998814
162
+ Half Moon Bay,37.463553,-122.428586
163
+ Hanford,36.32745,-119.645683
164
+ Hawaiian Gardens,33.831403,-118.072842
165
+ Hawthorne,33.916403,-118.352575
166
+ Hayward,37.668819,-122.080797
167
+ Healdsburg,38.610467,-122.869161
168
+ Hemet,33.747519,-116.971967
169
+ Hercules,38.017144,-122.288581
170
+ Hermosa Beach,33.862236,-118.399519
171
+ Hesperia,34.426389,-117.300878
172
+ Hidden Hills,34.160283,-118.652311
173
+ Highland,34.128344,-117.208650
174
+ Hollister,36.852453,-121.401603
175
+ Holtville,32.811161,-115.380264
176
+ Hughson,37.602725,-120.866481
177
+ Huntington Beach,33.660297,-117.999225
178
+ Huntington Park,33.981681,-118.225072
179
+ Huron,36.202731,-120.102917
180
+ Imperial,32.847553,-115.569439
181
+ Imperial Beach,32.583944,-117.113086
182
+ Indian Wells,33.717631,-116.340756
183
+ Indio,33.720578,-116.215561
184
+ Industry,34.019733,-117.958675
185
+ Inglewood,33.961681,-118.353131
186
+ Ione,38.352692,-120.932717
187
+ Irvine,33.683947,-117.794694
188
+ Irwindale,34.106953,-117.935342
189
+ Isleton,38.161861,-121.611622
190
+ Jackson,38.348803,-120.774103
191
+ Jurupa Valley,33.999522,-117.475397
192
+ Kerman,36.723558,-120.059878
193
+ King City,36.212744,-121.126028
194
+ Kingsburg,36.513839,-119.554017
195
+ La Cañada Flintridge,34.206817,-118.200028
196
+ La Habra,33.931958,-117.946172
197
+ La Habra Heights,33.960847,-117.950619
198
+ La Mesa,32.767828,-117.023083
199
+ La Mirada,33.917236,-118.012008
200
+ La Palma,33.846403,-118.046731
201
+ La Puente,34.020011,-117.949508
202
+ La Quinta,33.646692,-116.310008
203
+ La Verne,34.100842,-117.767836
204
+ Lafayette,37.885758,-122.118019
205
+ Laguna Beach,33.542247,-117.783111
206
+ Laguna Hills,33.599722,-117.699444
207
+ Laguna Niguel,33.522525,-117.707553
208
+ Laguna Woods,33.6103,-117.725331
209
+ Lake Elsinore,33.668078,-117.327261
210
+ Lake Forest,33.646967,-117.689217
211
+ Lakeport,39.04295,-122.915828
212
+ Lakewood,33.853628,-118.133956
213
+ Lancaster,34.686786,-118.154164
214
+ Larkspur,37.934092,-122.535253
215
+ Lathrop,37.822706,-121.276611
216
+ Lawndale,33.887236,-118.352575
217
+ Lemon Grove,32.742553,-117.031417
218
+ Lemoore,36.300783,-119.782911
219
+ Lincoln,38.891564,-121.293008
220
+ Lindsay,36.203006,-119.088161
221
+ Live Oak,36.983561,-121.980517
222
+ Livermore,37.681875,-121.768008
223
+ Livingston,37.386883,-120.723533
224
+ Lodi,38.134147,-121.272219
225
+ Loma Linda,34.048347,-117.261153
226
+ Lomita,33.792239,-118.315072
227
+ Lompoc,34.63915,-120.457942
228
+ Long Beach,33.768322,-118.195617
229
+ Los Alamitos,33.803072,-118.072564
230
+ Los Altos,33.796331,-118.118119
231
+ Los Angeles,34.052233,-118.243686
232
+ Los Banos,37.058278,-120.849914
233
+ Loyalton,39.676294,-120.241039
234
+ Lynwood,33.930292,-118.211461
235
+ Madera,36.961336,-120.060717
236
+ Malibu,34.005008,-118.810172
237
+ Manhattan Beach,33.884736,-118.410908
238
+ Manteca,37.797428,-121.216053
239
+ Maricopa,35.058858,-119.400950
240
+ Marina,36.684403,-121.802172
241
+ Martinez,38.019367,-122.134133
242
+ Marysville,39.145725,-121.591356
243
+ Maywood,33.986681,-118.185350
244
+ McFarland,35.678011,-119.229275
245
+ Mendota,36.753561,-120.381558
246
+ Menifee,33.678333,-117.166944
247
+ Menlo Park,37.453828,-122.182186
248
+ Merced,37.302164,-120.482967
249
+ Mill Valley,37.906036,-122.544975
250
+ Millbrae,37.598547,-122.387194
251
+ Milpitas,37.428272,-121.906625
252
+ Mission Viejo,33.600022,-117.671994
253
+ Modesto,37.639097,-120.996878
254
+ Monrovia,34.144428,-118.001947
255
+ Montague,41.728197,-122.527800
256
+ Montclair,34.077511,-117.689778
257
+ Monte Sereno,37.236333,-121.992458
258
+ Montebello,34.016506,-118.113753
259
+ Monterey,36.600239,-121.894675
260
+ Monterey Park,34.062511,-118.122847
261
+ Moorpark,34.144897,-118.268742
262
+ Moreno Valley,33.942467,-117.229672
263
+ Morgan Hill,37.1305,-121.654389
264
+ Morro Bay,35.365808,-120.849900
265
+ Mount Shasta,41.410806,-122.194575
266
+ Mountain View,37.386053,-122.083850
267
+ Murrieta,33.553914,-117.213922
268
+ Napa,38.297539,-122.286864
269
+ National City,32.678108,-117.099197
270
+ Needles,34.848061,-114.614133
271
+ Nevada City,39.261561,-121.016058
272
+ Newark,37.529658,-122.040239
273
+ Newman,37.313828,-121.020761
274
+ Newport Beach,33.618911,-117.928947
275
+ Norco,33.931125,-117.548661
276
+ Norwalk,33.902236,-118.081733
277
+ Novato,38.107419,-122.569703
278
+ Oakdale,37.766594,-120.847153
279
+ Oakland,37.804364,-122.271114
280
+ Oakley,37.997422,-121.712453
281
+ Oceanside,33.195869,-117.379483
282
+ Ojai,34.44805,-119.242889
283
+ Ontario,34.063344,-117.650889
284
+ Orange,33.787794,-117.853111
285
+ Orange Cove,36.624394,-119.313731
286
+ Orinda,37.877147,-122.179689
287
+ Orland,39.747381,-122.196375
288
+ Oroville,39.513775,-121.556358
289
+ Oxnard,34.197506,-119.177053
290
+ Pacific Grove,36.617736,-121.916622
291
+ Pacifica,37.613825,-122.486919
292
+ Palm Desert,33.722244,-116.374456
293
+ Palm Springs,33.830297,-116.545292
294
+ Palmdale,34.579433,-118.116461
295
+ Palo Alto,37.441883,-122.143019
296
+ Palos Verdes Estates,33.800572,-118.390075
297
+ Paramount,33.889461,-118.159792
298
+ Parlier,36.611617,-119.527072
299
+ Pasadena,34.147786,-118.144517
300
+ Paso Robles,35.632278,-120.664186
301
+ Patterson,37.4716,-121.129656
302
+ Perris,33.782519,-117.228647
303
+ Petaluma,38.232417,-122.636653
304
+ Pico Rivera,33.983069,-118.096736
305
+ Piedmont,37.824372,-122.231636
306
+ Pinole,38.004367,-122.298858
307
+ Pismo Beach,35.142753,-120.641283
308
+ Pittsburg,38.027975,-121.884681
309
+ Placentia,33.872236,-117.870336
310
+ Placerville,38.729625,-120.798547
311
+ Pleasant Hill,37.947978,-122.060797
312
+ Pleasanton,37.662431,-121.874678
313
+ Plymouth,38.481853,-120.844658
314
+ Point Arena,38.908797,-123.693072
315
+ Pomona,34.055228,-117.752306
316
+ Port Hueneme,34.180728,-119.208158
317
+ Porterville,36.065231,-119.016767
318
+ Portola,39.810458,-120.469103
319
+ Poway,32.962822,-117.035864
320
+ Rancho Cordova,38.589072,-121.302728
321
+ Rancho Cucamonga,34.1064,-117.593108
322
+ Rancho Mirage,33.739744,-116.412789
323
+ Rancho Palos Verdes,33.744461,-118.387017
324
+ Rancho Santa Margarita,33.640856,-117.603103
325
+ Red Bluff,40.178489,-122.235831
326
+ Redding,40.586539,-122.391675
327
+ Redlands,34.055569,-117.182539
328
+ Redondo Beach,33.849183,-118.388408
329
+ Redwood City,37.485214,-122.236356
330
+ Reedley,36.596339,-119.450403
331
+ Rialto,34.1064,-117.370325
332
+ Richmond,37.935758,-122.347750
333
+ Ridgecrest,35.622456,-117.670897
334
+ Rio Dell,40.4993,-124.106436
335
+ Rio Vista,38.15575,-121.691344
336
+ Ripon,37.739453,-121.135414
337
+ Riverbank,37.736039,-120.935489
338
+ Riverside,33.95335,-117.396156
339
+ Rocklin,38.790733,-121.235783
340
+ Rohnert Park,38.339636,-122.701097
341
+ Rolling Hills,33.756961,-118.353961
342
+ Rolling Hills Estates,33.787794,-118.358128
343
+ Rosemead,34.080564,-118.072847
344
+ Roseville,38.752122,-121.288006
345
+ Sacramento,38.581572,-121.494400
346
+ Salinas,36.677736,-121.655500
347
+ San Bernardino,34.108344,-117.289764
348
+ San Bruno,37.630489,-122.411083
349
+ San Carlos,37.507158,-122.260522
350
+ San Clemente,33.426972,-117.611992
351
+ San Diego,32.715328,-117.157256
352
+ San Dimas,34.106675,-117.806725
353
+ San Fernando,34.281947,-118.438972
354
+ San Francisco,37.774931,-122.419417
355
+ San Gabriel,34.096111,-118.105833
356
+ San Jacinto,33.783908,-116.958636
357
+ San Joaquin,36.606617,-120.189044
358
+ San Jose,37.339386,-121.894956
359
+ San Juan Bautista,36.845511,-121.537997
360
+ San Juan Capistrano,33.501692,-117.662550
361
+ San Leandro,37.724931,-122.156078
362
+ San Luis Obispo,35.282753,-120.659617
363
+ San Marcos,33.143372,-117.166144
364
+ San Marino,34.121397,-118.106458
365
+ San Mateo,37.562992,-122.325525
366
+ San Pablo,37.962147,-122.345525
367
+ San Rafael,37.973536,-122.531086
368
+ San Ramon,37.779928,-121.978014
369
+ Sand City,36.617183,-121.848286
370
+ Sanger,36.708006,-119.555964
371
+ Santa Ana,33.745572,-117.867833
372
+ Santa Barbara,34.420831,-119.698189
373
+ Santa Clara,37.354108,-121.955236
374
+ Santa Clarita,34.391664,-118.542586
375
+ Santa Cruz,36.974117,-122.030797
376
+ Santa Fe Springs,33.947236,-118.085344
377
+ Santa Maria,34.953033,-120.435719
378
+ Santa Monica,34.019453,-118.491192
379
+ Santa Paula,34.354167,-119.059269
380
+ Santa Rosa,38.440467,-122.714431
381
+ Santee,32.838383,-116.973917
382
+ Saratoga,37.263833,-122.023014
383
+ Sausalito,37.859094,-122.485250
384
+ Scotts Valley,37.051061,-122.014683
385
+ Seal Beach,33.741406,-118.104786
386
+ Seaside,33.819361,-118.366647
387
+ Sebastopol,38.402136,-122.823881
388
+ Selma,36.570783,-119.612075
389
+ Shafter,35.500514,-119.271775
390
+ Shasta Lake,40.680428,-122.370842
391
+ Sierra Madre,34.161672,-118.052847
392
+ Signal Hill,33.804461,-118.167847
393
+ Simi Valley,34.269447,-118.781483
394
+ Solana Beach,32.991156,-117.271147
395
+ Soledad,32.991156,-117.271147
396
+ Solvang,34.595819,-120.137647
397
+ Sonoma,38.291858,-122.458036
398
+ Sonora,37.984092,-120.382139
399
+ South El Monte,34.051956,-118.046733
400
+ South Gate,33.954736,-118.212017
401
+ South Lake Tahoe,38.939925,-119.977186
402
+ South Pasadena,34.116119,-118.150350
403
+ South San Francisco,37.654656,-122.407750
404
+ St. Helena,38.505242,-122.470386
405
+ Stanton,33.802517,-117.993117
406
+ Stockton,37.957703,-121.290781
407
+ Suisun City,38.238247,-122.040244
408
+ Sunnyvale,37.368831,-122.036350
409
+ Susanville,40.416283,-120.653006
410
+ Sutter Creek,38.392967,-120.802436
411
+ Taft,35.142467,-119.456508
412
+ Tehachapi,35.132189,-118.448975
413
+ Tehama,40.027103,-122.123322
414
+ Temecula,33.493639,-117.148364
415
+ Temple City,34.107231,-118.057847
416
+ Thousand Oaks,34.107231,-118.057847
417
+ Torrance,33.83585,-118.340628
418
+ Tracy,37.73965,-121.425222
419
+ Trinidad,41.059292,-124.143125
420
+ Tulare,36.207728,-119.347339
421
+ Tulelake,41.955989,-121.477492
422
+ Turlock,37.494658,-120.846594
423
+ Tustin,33.74585,-117.826167
424
+ Twentynine Palms,34.135558,-116.054169
425
+ Ukiah,39.150172,-123.207783
426
+ Union City,37.593392,-122.043831
427
+ Upland,34.097511,-117.648389
428
+ Vacaville,38.356578,-121.987744
429
+ Vallejo,38.104086,-122.256636
430
+ Ventura,34.274639,-119.229006
431
+ Vernon,34.003903,-118.230072
432
+ Victorville,34.536108,-117.291158
433
+ Villa Park,33.814461,-117.813111
434
+ Visalia,36.330228,-119.292058
435
+ Vista,33.200036,-117.242536
436
+ Walnut,34.020289,-117.865339
437
+ Walnut Creek,37.910078,-122.065183
438
+ Wasco,35.594125,-119.340947
439
+ Waterford,37.641319,-120.760483
440
+ Watsonville,36.910231,-121.756894
441
+ Weed,41.42265,-122.386128
442
+ West Covina,34.068622,-117.938953
443
+ West Hollywood,34.090008,-118.361744
444
+ West Sacramento,38.580461,-121.530233
445
+ Westlake Village,34.145839,-118.805647
446
+ Westminster,33.751342,-117.993992
447
+ Westmorland,33.037267,-115.621383
448
+ Wheatland,39.009894,-121.423014
449
+ Whittier,33.979178,-118.032844
450
+ Wildomar,33.598914,-117.280036
451
+ Williams,39.154614,-122.149419
452
+ Willits,39.409608,-123.355567
453
+ Willows,39.524325,-122.193592
454
+ Winters,38.524906,-121.970803
455
+ Woodlake,36.413561,-119.098717
456
+ Woodland,38.678517,-121.773297
457
+ Yorba Linda,33.888625,-117.813111
458
+ Yreka,41.735419,-122.634472
459
+ Yuba City,39.140447,-121.616911
460
+ Yucaipa,34.033625,-117.043086
data/cal_populations_city.csv ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ County,City,Incorportation_date,pop_april_1980,pop_april_1990,pop_april_2000,pop_april_2010
2
+ San Bernardino,Adelanto,1970,2164,8517,18130,31765
3
+ Los Angeles,Agoura Hills,1982,,20390,20537,20330
4
+ Alameda,Alameda,1854,63852,76459,72259,73812
5
+ Alameda,Albany,1908,15130,16327,16444,18539
6
+ Los Angeles,Alhambra,1903,64767,82106,85804,83089
7
+ Modoc,Alturas,1901,3025,3231,2892,2827
8
+ Amador,Amador City,1915,136,196,196,185
9
+ Orange,Anaheim,1876,219494,266406,328014,336265
10
+ Shasta,Anderson,1956,7381,8299,9022,9932
11
+ Calaveras,Angels,1912,2302,2409,3004,3836
12
+ Contra Costa,Antioch,1872,42683,62195,90532,102372
13
+ San Bernardino,Apple Valley,1988,,46079,54239,69135
14
+ Los Angeles,Arcadia,1903,45993,48290,53054,56364
15
+ Humboldt,Arcata,1858,12850,15197,16651,17231
16
+ San Luis Obispo,Arroyo Grande,1911,11290,14378,15851,17252
17
+ Los Angeles,Artesia,1959,14301,15464,16380,16522
18
+ Kern,Arvin,1960,6863,9286,12956,19304
19
+ San Luis Obispo,Atascadero,1979,16232,23138,26411,28310
20
+ San Mateo,Atherton,1923,7797,7163,7194,6914
21
+ Merced,Atwater,1922,17530,22282,23113,28168
22
+ Placer,Auburn,1888,7540,10592,12462,13330
23
+ Los Angeles,Avalon,1913,2022,2918,3127,3728
24
+ Kings,Avenal,1979,4137,9770,14674,15505
25
+ Los Angeles,Azusa,1898,29380,41333,44712,46361
26
+ Kern,Bakersfield,1873,105611,174820,246889,347483
27
+ Los Angeles,Baldwin Park,1956,50554,69330,75837,75390
28
+ Riverside,Banning,1913,14020,20570,23562,29603
29
+ San Bernardino,Barstow,1947,17690,21472,21119,22639
30
+ Riverside,Beaumont,1912,6818,9685,11384,36877
31
+ Los Angeles,Bell,1927,25450,34365,36664,35477
32
+ Los Angeles,Bell Gardens,1961,34117,42355,44054,42072
33
+ Los Angeles,Bellflower,1957,53441,61815,72878,76616
34
+ San Mateo,Belmont,1926,24505,24127,25123,25835
35
+ Marin,Belvedere,1896,2401,2147,2125,2068
36
+ Solano,Benicia,1850,15376,24437,26865,26997
37
+ Alameda,Berkeley,1878,103328,102724,102743,112580
38
+ Los Angeles,Beverly Hills,1914,32646,31971,33784,34109
39
+ San Bernardino,Big Bear Lake,1980,,5351,5438,5019
40
+ Butte,Biggs,1903,1413,1581,1793,1707
41
+ Inyo,Bishop,1903,3333,3475,3575,3879
42
+ Humboldt,Blue Lake,1910,1201,1235,1135,1253
43
+ Riverside,Blythe,1916,6805,8428,20463,20817
44
+ Los Angeles,Bradbury,1957,846,829,855,1048
45
+ Imperial,Brawley,1908,14946,18923,22052,24953
46
+ Orange,Brea,1917,27913,32873,35410,39282
47
+ Contra Costa,Brentwood,1948,4434,7563,23302,51481
48
+ San Mateo,Brisbane,1961,2969,2952,3597,4282
49
+ Orange,Buena Park,1953,64165,68784,78282,80530
50
+ Los Angeles,Burbank,1911,84625,93643,100316,103340
51
+ San Mateo,Burlingame,1908,26173,26801,28158,28806
52
+ Imperial,Calexico,1908,14412,18633,27109,38572
53
+ Kern,California City,1965,2743,5955,8385,14120
54
+ Imperial,Calipatria,1919,2636,2690,7289,7705
55
+ Napa,Calistoga,1886,3879,4468,5190,5155
56
+ Ventura,Camarillo,1964,37797,52303,57077,65201
57
+ Santa Clara,Campbell,1952,26910,36048,38138,39349
58
+ Santa Cruz,Capitola,1949,9095,10171,10033,9918
59
+ San Diego,Carlsbad,1952,35490,63126,78247,105328
60
+ Monterey,Carmel-By-The-Sea,1916,4707,4239,4081,3722
61
+ Santa Barbara,Carpinteria,1965,10835,13747,14194,13040
62
+ Los Angeles,Carson,1968,81221,83995,89730,91714
63
+ Riverside,Cathedral City,1981,,30085,42647,51200
64
+ Stanislaus,Ceres,1918,13281,26314,34609,45417
65
+ Los Angeles,Cerritos,1956,53020,53240,51488,49041
66
+ Butte,Chico,1872,26716,40079,60516,86187
67
+ San Bernardino,Chino,1910,40165,59682,67168,77983
68
+ Madera,Chowchilla,1923,5122,5930,14416,18720
69
+ San Diego,Chula Vista,1911,35490,63126,173556,243916
70
+ Los Angeles,Claremont,1907,31028,32503,33998,34926
71
+ Contra Costa,Clayton,1964,4325,7317,10762,10897
72
+ Sonoma,Cloverdale,1872,3989,4924,6831,8618
73
+ Fresno,Clovis,1912,33021,50323,68468,95631
74
+ Riverside,Coachella,1946,9129,16896,22724,40704
75
+ Fresno,Coalinga,1906,6593,8212,16213,13380
76
+ Placer,Colfax,1910,981,1306,1496,1963
77
+ San Mateo,Colma,1924,395,1103,1187,1792
78
+ San Bernardino,Colton,1887,21310,40213,47662,52154
79
+ Colusa,Colusa,1868,4075,4934,5402,5971
80
+ Los Angeles,Commerce,1960,10509,12135,12568,12823
81
+ Los Angeles,Compton,1888,81347,90454,93493,96455
82
+ Contra Costa,Concord,1905,103763,111348,121780,122067
83
+ Kings,Corcoran,1914,6454,13364,20835,24813
84
+ Tehama,Corning,1907,4745,5870,6741,7663
85
+ Riverside,Corona,1896,37791,76095,124966,152374
86
+ San Diego,Coronado,1890,18790,26540,24100,18912
87
+ Marin,Corte Madera,1916,8074,8272,9100,9253
88
+ Orange,Costa Mesa,1953,82562,96357,108724,109960
89
+ Sonoma,Cotati,1963,3346,5714,6471,7265
90
+ Los Angeles,Covina,1901,32746,43207,46837,47796
91
+ Del Norte,Crescent City,1854,3075,4380,7347,7643
92
+ Los Angeles,Cudahy,1960,18275,22817,24208,23805
93
+ Los Angeles,Culver City,1917,38139,38793,38816,38883
94
+ Santa Clara,Cupertino,1955,34297,40263,50546,58302
95
+ Orange,Cypress,1956,40738,42655,46229,47802
96
+ San Mateo,Daly City,1911,78427,92311,103625,101123
97
+ Orange,Dana Point,1989,,31896,35110,33351
98
+ Contra Costa,Danville,1982,26446,31306,41715,42039
99
+ Yolo,Davis,1917,36640,46209,60308,65622
100
+ San Diego,Del Mar,1959,5017,4860,4389,4161
101
+ Monterey,Del Rey Oaks,1953,1557,1661,1650,1624
102
+ Kern,Delano,1915,16491,22762,39489,53041
103
+ Riverside,Desert Hot Springs,1963,5941,11668,16582,25938
104
+ Los Angeles,Diamond Bar,1989,,53672,56287,55544
105
+ Tulare,Dinuba,1906,9907,12743,16844,21453
106
+ Solano,Dixon,1878,7541,10401,16103,18351
107
+ Siskiyou,Dorris,1908,836,892,886,939
108
+ Merced,Dos Palos,1935,3121,4196,4581,4950
109
+ Los Angeles,Downey,1956,82602,91444,107323,111772
110
+ Los Angeles,Duarte,1957,16766,20688,21486,21321
111
+ Alameda,Dublin,1982,13496,23229,29973,46036
112
+ Siskiyou,Dunsmuir,1909,2253,2129,1923,1650
113
+ San Mateo,East Palo Alto,1983,,23451,29506,28155
114
+ San Diego,El Cajon,1912,73892,88693,94869,99478
115
+ Imperial,El Centro,1908,23996,31384,37835,42598
116
+ Contra Costa,El Cerrito,1917,22731,22869,23171,23549
117
+ Los Angeles,El Monte,1912,79494,106209,115965,113475
118
+ Los Angeles,El Segundo,1917,13752,15223,16033,16654
119
+ Alameda,Emeryville,1896,3714,5740,6882,10080
120
+ San Diego,Encinitas,1986,,55386,58014,59518
121
+ San Joaquin,Escalon,1957,3127,4437,5963,7132
122
+ San Diego,Escondido,1888,64355,108635,133559,143911
123
+ Siskiyou,Etna,1878,754,835,781,737
124
+ Humboldt,Eureka,1856,24153,27025,26128,27191
125
+ Tulare,Exeter,1911,5606,7276,9168,10334
126
+ Marin,Fairfax,1931,7391,6931,7319,7441
127
+ Solano,Fairfield,1903,58099,77211,96178,105321
128
+ Tulare,Farmersville,1960,5544,6235,8737,10588
129
+ Humboldt,Ferndale,1893,1367,1331,1382,1371
130
+ Ventura,Fillmore,1914,9602,11992,13643,15002
131
+ Fresno,Firebaugh,1914,3740,4429,5743,7549
132
+ Sacramento,Folsom,1946,11003,29802,51884,72203
133
+ San Bernardino,Fontana,1952,36991,87535,128929,196069
134
+ Mendocino,Fort Bragg,1889,5019,6078,6814,7273
135
+ Siskiyou,Fort Jones,1872,544,639,660,839
136
+ Humboldt,Fortuna,1906,7591,8788,10497,11926
137
+ San Mateo,Foster City,1971,23287,28176,28803,30567
138
+ Orange,Fountain Valley,1957,55080,53691,54978,55313
139
+ Fresno,Fowler,1908,2496,3208,3979,5570
140
+ Alameda,Fremont,1956,131945,173339,203413,214089
141
+ Fresno,Fresno,1885,217129,354202,427652,494665
142
+ Orange,Fullerton,1904,102246,114144,126003,135161
143
+ Sacramento,Galt,1946,5514,8889,19472,23647
144
+ Orange,Garden Grove,1956,123307,143050,165196,170883
145
+ Los Angeles,Gardena,1930,45165,49847,57746,58829
146
+ Santa Clara,Gilroy,1870,25769,26303,41464,48821
147
+ Los Angeles,Glendale,1906,139060,180038,194973,191719
148
+ Los Angeles,Glendora,1911,38500,47828,49415,50073
149
+ Monterey,Gonzales,1947,2891,4660,7564,8187
150
+ San Bernardino,Grand Terrace,1978,8498,10946,11626,12040
151
+ Nevada,Grass Valley,1893,6697,9048,10922,12860
152
+ Monterey,Greenfield,1947,4181,7464,12648,16330
153
+ Butte,Gridley,1905,3982,4631,5382,6584
154
+ San Luis Obispo,Grover Beach,1959,8827,11656,13067,13156
155
+ Santa Barbara,Guadalupe,1946,3629,5479,5659,7080
156
+ Merced,Gustine,1915,3142,3931,4698,5520
157
+ San Mateo,Half Moon Bay,1959,7282,8886,11842,11324
158
+ Kings,Hanford,1891,20958,30897,41686,53967
159
+ Los Angeles,Hawaiian Gardens,1964,10548,13639,14779,14254
160
+ Los Angeles,Hawthorne,1922,56437,71349,84112,84293
161
+ Alameda,Hayward,1876,94342,111498,140030,144186
162
+ Sonoma,Healdsburg,1867,7217,9469,10722,11254
163
+ Riverside,Hemet,1910,22454,36094,58812,78657
164
+ Contra Costa,Hercules,1900,5963,16829,19488,24060
165
+ Los Angeles,Hermosa Beach,1907,18070,18219,18566,19506
166
+ San Bernardino,Hesperia,1988,,50418,62582,90173
167
+ Los Angeles,Hidden Hills,1961,1760,1729,1875,1856
168
+ San Bernardino,Highland,1987,,34439,44605,53104
169
+ San Mateo,Hillsborough,1910,10372,10667,10825,10825
170
+ San Benito,Hollister,1872,11488,19212,34413,34928
171
+ Imperial,Holtville,1908,4399,4820,5612,5939
172
+ Stanislaus,Hughson,1972,2943,3259,3980,6640
173
+ Orange,Huntington Beach,1909,170505,181519,189594,189992
174
+ Los Angeles,Huntington Park,1906,45932,56065,61348,58114
175
+ Fresno,Huron,1951,2768,4766,6306,6754
176
+ Imperial,Imperial,1904,3451,4113,7560,14758
177
+ San Diego,Imperial Beach,1956,22689,26512,26992,26324
178
+ Riverside,Indian Wells,1967,1394,2647,3816,4958
179
+ Riverside,Indio,1930,21611,36793,49116,76036
180
+ Los Angeles,Industry,1957,412,631,777,219
181
+ Los Angeles,Inglewood,1908,94162,109602,112580,109673
182
+ Amador,Ione,1953,2207,6516,7129,7918
183
+ Orange,Irvine,1971,62134,110330,143072,212375
184
+ Los Angeles,Irwindale,1957,1030,1050,1446,1422
185
+ Sacramento,Isleton,1923,914,833,828,804
186
+ Amador,Jackson,1905,2331,3545,3989,4651
187
+ Fresno,Kerman,1946,4002,5448,8551,13544
188
+ Monterey,King City,1911,5495,7634,11204,12874
189
+ Fresno,Kingsburg,1908,5115,7205,9199,11382
190
+ Los Angeles,La Cañada Flintridge,1976,20153,19378,20318,20246
191
+ Orange,La Habra,1925,45232,51266,58974,60239
192
+ Los Angeles,La Habra Heights,1978,4786,6226,5712,5325
193
+ San Diego,La Mesa,1912,50308,52931,54749,57065
194
+ Los Angeles,La Mirada,1960,40986,40452,46783,48527
195
+ Orange,La Palma,1955,15399,15392,15408,15568
196
+ Los Angeles,La Puente,1956,30882,36955,41063,39816
197
+ Riverside,La Quinta,1982,,11215,23694,37467
198
+ Los Angeles,La Verne,1906,23508,30897,31638,31063
199
+ Contra Costa,Lafayette,1968,20837,23501,23908,23893
200
+ Orange,Laguna Beach,1927,17858,23170,23727,22723
201
+ Orange,Laguna Niguel,1989,,44400,61891,62979
202
+ Riverside,Lake Elsinore,1888,5982,18285,28928,51821
203
+ Lake,Lakeport,1888,3675,4390,4820,4753
204
+ Los Angeles,Lakewood,1954,74654,73557,79345,80048
205
+ Los Angeles,Lancaster,1977,48027,97291,118718,156633
206
+ Marin,Larkspur,1908,11064,11070,12014,11926
207
+ San Joaquin,Lathrop,1989,,6841,10445,18023
208
+ Los Angeles,Lawndale,1959,23460,27331,31711,32769
209
+ San Diego,Lemon Grove,1977,20780,23984,24918,25320
210
+ Kings,Lemoore,1900,8832,13622,19712,24531
211
+ Placer,Lincoln,1890,4132,7248,11205,42819
212
+ Tulare,Lindsay,1910,6936,8338,10297,11768
213
+ Sutter,Live Oak,1947,3103,4320,6229,8392
214
+ Alameda,Livermore,1876,48349,56741,73345,80968
215
+ Merced,Livingston,1922,5326,7317,10473,13058
216
+ San Joaquin,Lodi,1906,35221,51874,56999,62134
217
+ San Bernardino,Loma Linda,1970,10694,17400,18681,23261
218
+ Los Angeles,Lomita,1964,18807,19382,20046,20256
219
+ Santa Barbara,Lompoc,1888,26267,37649,41103,42434
220
+ Los Angeles,Long Beach,"i. 1888/ d.1896/
221
+ ri. 1897",361355,429433,461522,462257
222
+ Placer,Loomis,1984,,5705,6260,6430
223
+ Orange,Los Alamitos,1960,11529,11676,11536,11449
224
+ Santa Clara,Los Altos,1952,25769,26303,27693,28976
225
+ Santa Clara,Los Altos Hills,1956,7421,7514,7902,7922
226
+ Los Angeles,Los Angeles,1850,2968579,3485398,3694742,3792621
227
+ Merced,Los Banos,1907,10341,14519,25869,35972
228
+ Santa Clara,Los Gatos,1887,26906,27357,28592,29413
229
+ Sierra,Loyalton,1901,1030,931,862,769
230
+ Los Angeles,Lynwood,1921,48409,61945,69845,69772
231
+ Madera,Madera,1907,21732,29281,43207,61416
232
+ Mono,Mammoth Lakes,1984,3929,4785,7093,8234
233
+ Los Angeles,Manhattan Beach,1912,31542,32063,33852,35135
234
+ San Joaquin,Manteca,1918,24925,40773,49258,67096
235
+ Kern,Maricopa,1911,946,1193,1111,1154
236
+ Monterey,Marina,1975,20647,26436,18925,19718
237
+ Contra Costa,Martinez,1876,22582,31808,35866,35824
238
+ Yuba,Marysville,1851,9898,12324,12268,12072
239
+ Los Angeles,Maywood,1924,21810,27850,28083,27395
240
+ Kern,McFarland,1957,5151,7005,9837,12707
241
+ Fresno,Mendota,1942,5038,6821,7890,11014
242
+ San Mateo,Menlo Park,1927,26438,28040,30785,32026
243
+ Merced,Merced,1889,36499,56216,63893,78958
244
+ Marin,Mill Valley,1900,12967,13038,13600,13903
245
+ San Mateo,Millbrae,1948,20058,20412,20718,21532
246
+ Santa Clara,Milpitas,1954,37820,50686,62698,66790
247
+ Orange,Mission Viejo,1988,,72820,93102,93305
248
+ Stanislaus,Modesto,1884,106963,164730,188856,201165
249
+ Los Angeles,Monrovia,1887,30531,35761,36929,36590
250
+ Siskiyou,Montague,1909,1285,1415,1456,1443
251
+ San Bernardino,Montclair,1956,22628,28434,33049,36664
252
+ Santa Clara,Monte Sereno,1957,3434,3287,3483,3341
253
+ Los Angeles,Montebello,1920,52929,59564,62150,62500
254
+ Monterey,Monterey,1890,27558,31954,29696,27810
255
+ Los Angeles,Monterey Park,1916,54338,60738,60051,60269
256
+ Ventura,Moorpark,1983,,25494,31415,34421
257
+ Contra Costa,Moraga,1974,15014,15852,16290,16016
258
+ Riverside,Moreno Valley,1984,,118779,142381,193365
259
+ Santa Clara,Morgan Hill,1906,17060,23928,33556,37882
260
+ San Luis Obispo,Morro Bay,1964,9064,9664,10350,10234
261
+ Siskiyou,Mount Shasta,1905,2837,3460,3621,3394
262
+ Santa Clara,Mountain View,1902,58655,67460,70708,74066
263
+ Napa,Napa,1872,50879,61842,72585,76915
264
+ San Diego,National City,1887,48772,54249,54260,58582
265
+ San Bernardino,Needles,1913,4120,5191,4830,4844
266
+ Nevada,Nevada City,1856,2431,2855,3001,3068
267
+ Alameda,Newark,1955,32126,37861,42471,42573
268
+ Stanislaus,Newman,1908,2785,4151,7093,10224
269
+ Orange,Newport Beach,1906,62556,66643,70032,85186
270
+ Riverside,Norco,1964,19732,23302,24157,27063
271
+ Los Angeles,Norwalk,1957,84901,94279,104323,105549
272
+ Marin,Novato,1960,43916,47585,47630,51904
273
+ Stanislaus,Oakdale,1906,8474,11961,15503,20675
274
+ Alameda,Oakland,1852,339337,372242,399484,390724
275
+ San Diego,Oceanside,1888,76698,128398,161029,167086
276
+ Ventura,Ojai,1921,6816,7613,7862,7461
277
+ San Bernardino,Ontario,1891,88820,133179,158007,163924
278
+ Orange,Orange,1888,91450,110658,128868,136416
279
+ Fresno,Orange Cove,1948,4026,5604,7722,9078
280
+ Contra Costa,Orinda,1985,,16642,17599,17643
281
+ Glenn,Orland,1909,4031,5052,6281,7291
282
+ Butte,Oroville,1906,8693,11960,13004,15546
283
+ Ventura,Oxnard,1903,108195,142216,170358,197899
284
+ Monterey,Pacific Grove,1889,15755,16117,15522,15041
285
+ San Mateo,Pacifica,1957,36866,37670,38390,37234
286
+ Riverside,Palm Desert,1973,11801,23252,41155,48445
287
+ Riverside,Palm Springs,1938,32359,40181,42807,44552
288
+ Los Angeles,Palmdale,1962,12277,68842,116670,152750
289
+ Santa Clara,Palo Alto,1894,55225,55900,58598,64403
290
+ Los Angeles,Palos Verdes Estates,1939,14376,13512,13340,13438
291
+ Butte,Paradise,1979,22571,25408,26408,26218
292
+ Los Angeles,Paramount,1957,36407,47669,55266,54098
293
+ Fresno,Parlier,1921,2902,7938,11145,14494
294
+ Los Angeles,Pasadena,1886,118072,131591,133936,137122
295
+ San Luis Obispo,Paso Robles,1889,9163,18583,24297,29793
296
+ Stanislaus,Patterson,1919,3908,8626,11606,20413
297
+ Riverside,Perris,1911,6827,21460,36189,68386
298
+ Sonoma,Petaluma,1858,33834,43184,54548,57941
299
+ Los Angeles,Pico Rivera,1958,53387,59177,63428,62942
300
+ Alameda,Piedmont,1907,10498,10602,10952,10667
301
+ Contra Costa,Pinole,1903,14253,17460,19039,18390
302
+ San Luis Obispo,Pismo Beach,1939,5364,7669,8551,7655
303
+ Contra Costa,Pittsburg,1903,33465,47564,56769,63264
304
+ Orange,Placentia,1926,35041,41259,46488,50533
305
+ El Dorado,Placerville,1854,6739,8355,9610,10389
306
+ Contra Costa,Pleasant Hill,1961,25547,31585,32837,33152
307
+ Alameda,Pleasanton,1894,35160,50553,63654,70285
308
+ Amador,Plymouth,1917,699,811,980,1005
309
+ Mendocino,Point Arena,1908,425,407,474,449
310
+ Los Angeles,Pomona,1888,92742,131723,149473,149058
311
+ Ventura,Port Hueneme,1948,17803,20319,21845,21723
312
+ Tulare,Porterville,1902,19707,29563,39615,54165
313
+ Plumas,Portola,1946,1885,2193,2227,2104
314
+ San Mateo,Portola Valley,1964,3939,4194,4462,4353
315
+ San Diego,Poway,1980,,43516,48044,47811
316
+ San Bernardino,Rancho Cucamonga,1977,55250,101409,127743,165269
317
+ Riverside,Rancho Mirage,1973,6281,9778,13249,17218
318
+ Los Angeles,Rancho Palos Verdes,1973,36577,41659,41145,41643
319
+ Tehama,Red Bluff,1876,9490,12363,13147,14076
320
+ Shasta,Redding,1887,41995,66462,80865,89861
321
+ San Bernardino,Redlands,1888,43619,60394,63591,68747
322
+ Los Angeles,Redondo Beach,1892,57102,60167,63261,66748
323
+ San Mateo,Redwood City,1867,54951,66072,75402,76815
324
+ Fresno,Reedley,1913,11071,15791,20756,24194
325
+ San Bernardino,Rialto,1911,37862,72388,91873,99171
326
+ Contra Costa,Richmond,1905,74676,87425,99216,103701
327
+ Kern,Ridgecrest,1963,15929,27725,24927,27616
328
+ Humboldt,Rio Dell,1965,2687,3012,3174,3368
329
+ Solano,Rio Vista,1894,3142,3316,4571,7360
330
+ San Joaquin,Ripon,1945,3509,7455,10146,14297
331
+ Stanislaus,Riverbank,1922,5695,8547,15826,22678
332
+ Riverside,Riverside,1883,170591,226505,255166,303871
333
+ Placer,Rocklin,1893,7344,19033,36330,56974
334
+ Sonoma,Rohnert Park,1962,22965,36326,42236,40971
335
+ Los Angeles,Rolling Hills,1957,2049,1871,1871,1860
336
+ Los Angeles,Rolling Hills Estates,1957,7701,7789,7676,8067
337
+ Los Angeles,Rosemead,1959,42604,51638,53505,53764
338
+ Placer,Roseville,1909,24347,44685,79921,118788
339
+ Marin,Ross,1908,2801,2123,2329,2415
340
+ Sacramento,Sacramento,1850,275741,369365,407018,466488
341
+ Monterey,Salinas,1874,80479,108777,142685,150441
342
+ Marin,San Anselmo,1907,12067,11743,12378,12336
343
+ San Bernardino,San Bernardino,1869,118794,164164,185401,209924
344
+ San Mateo,San Bruno,1914,35417,38961,40165,41114
345
+ San Mateo,San Carlos,1925,24710,26167,27718,28406
346
+ Orange,San Clemente,1928,27325,41100,49936,63522
347
+ San Diego,San Diego,1850,875538,1110549,1223400,1307402
348
+ Los Angeles,San Dimas,1960,24014,32397,34980,33371
349
+ Los Angeles,San Fernando,1911,17731,22580,23564,23645
350
+ San Francisco,San Francisco,1850,678974,723959,776733,805235
351
+ Los Angeles,San Gabriel,1913,30072,37120,39804,39718
352
+ Riverside,San Jacinto,1888,7098,16210,23779,44199
353
+ Fresno,San Joaquin,1920,1930,2311,3270,4001
354
+ Santa Clara,San Jose,1850,629531,782248,894943,945942
355
+ San Benito,San Juan Bautista,1869,1276,1570,1549,1862
356
+ Orange,San Juan Capistrano,1961,18959,26183,33826,34593
357
+ Alameda,San Leandro,1872,63952,68223,79452,84950
358
+ San Luis Obispo,San Luis Obispo,1856,34252,41958,44174,45119
359
+ San Diego,San Marcos,1963,17479,38974,54977,83781
360
+ Los Angeles,San Marino,1913,13307,12959,12945,13147
361
+ San Mateo,San Mateo,1894,77640,85486,92482,97207
362
+ Contra Costa,San Pablo,1948,19750,25158,30215,29139
363
+ Marin,San Rafael,1874,44700,48404,56063,57713
364
+ Contra Costa,San Ramon,1983,,35303,44722,72148
365
+ Monterey,Sand City,1960,182,192,261,334
366
+ Fresno,Sanger,1911,12542,16839,18931,24270
367
+ Orange,Santa Ana,1886,204023,293742,337977,324528
368
+ Santa Barbara,Santa Barbara,1850,74414,85571,89600,88410
369
+ Santa Clara,Santa Clara,1852,87700,93613,102361,116468
370
+ Los Angeles,Santa Clarita,1987,,110642,151088,176320
371
+ Santa Cruz,Santa Cruz,1866,41483,49040,54593,59946
372
+ Los Angeles,Santa Fe Springs,1957,14520,15520,16413,16223
373
+ Santa Barbara,Santa Maria,1905,39685,61284,77423,99553
374
+ Los Angeles,Santa Monica,1886,88314,86905,84084,89736
375
+ Ventura,Santa Paula,1902,20658,25062,28598,29321
376
+ Sonoma,Santa Rosa,1868,82658,113313,147595,167815
377
+ San Diego,Santee,1980,,52902,52975,53413
378
+ Santa Clara,Saratoga,1956,29261,28061,29843,29926
379
+ Marin,Sausalito,1893,7338,7152,7330,7061
380
+ Santa Cruz,Scotts Valley,1966,6891,8615,11385,11580
381
+ Orange,Seal Beach,1915,25975,25098,24157,24168
382
+ Monterey,Seaside,1954,36567,38901,33097,33025
383
+ Sonoma,Sebastopol,1902,5595,7004,7774,7379
384
+ Fresno,Selma,1893,10942,14757,19444,23219
385
+ Kern,Shafter,1938,7010,8409,12736,16988
386
+ Los Angeles,Sierra Madre,1907,10837,10762,10578,10917
387
+ Los Angeles,Signal Hill,1924,5734,8371,9333,11016
388
+ Ventura,Simi Valley,1969,77500,100217,111351,124237
389
+ San Diego,Solana Beach,1986,,12962,12979,12867
390
+ Monterey,Soledad,1921,3091,7146,23015,25738
391
+ Santa Barbara,Solvang,1985,,4741,5332,5245
392
+ Sonoma,Sonoma,1883,6054,8121,9128,10648
393
+ Tuolumne,Sonora,1851,3247,4153,4423,4903
394
+ Los Angeles,South El Monte,1958,16623,20850,21144,20116
395
+ Los Angeles,South Gate,1923,66784,86284,96375,94396
396
+ El Dorado,South Lake Tahoe,1965,20681,21586,23609,21403
397
+ Los Angeles,South Pasadena,1888,22681,23936,24292,25619
398
+ San Mateo,South San Francisco,1908,49393,54312,60552,63632
399
+ Napa,St. Helena,1876,4898,4990,5950,5814
400
+ Orange,Stanton,1911,23723,30491,37403,38186
401
+ San Joaquin,Stockton,1850,148283,210943,243771,291707
402
+ Solano,Suisun City,1868,11087,22686,26118,28111
403
+ Santa Clara,Sunnyvale,1912,106618,117229,131760,140081
404
+ Lassen,Susanville,1900,6520,7279,17428,17947
405
+ Amador,Sutter Creek,1913,1705,1835,2303,2501
406
+ Kern,Taft,1910,5316,5902,8811,9327
407
+ Kern,Tehachapi,1909,4126,5791,11125,14414
408
+ Tehama,Tehama,1906,365,401,432,418
409
+ Riverside,Temecula,1989,,27099,57716,100097
410
+ Los Angeles,Temple City,1960,28972,31100,33377,35558
411
+ Ventura,Thousand Oaks,1964,77072,104352,117005,126683
412
+ Marin,Tiburon,1964,6685,7532,8666,8962
413
+ Los Angeles,Torrance,1921,129881,133107,137946,145438
414
+ San Joaquin,Tracy,1910,18428,33558,56929,82922
415
+ Humboldt,Trinidad,1870,379,362,311,367
416
+ Tulare,Tulare,1888,22530,33249,43994,59278
417
+ Siskiyou,Tulelake,1937,783,1010,1020,1010
418
+ Stanislaus,Turlock,1908,26287,42198,55810,68549
419
+ Orange,Tustin,1927,32256,50689,67504,75540
420
+ San Bernardino,Twentynine Palms,1987,,11821,14764,25048
421
+ Mendocino,Ukiah,1876,12035,14599,15497,16075
422
+ Alameda,Union City,1959,39406,53762,66869,69516
423
+ San Bernardino,Upland,1906,47647,63374,68393,73732
424
+ Solano,Vacaville,1892,43367,71479,88625,92428
425
+ Solano,Vallejo,1868,80303,109199,116760,115942
426
+ Ventura,Ventura,1866,73774,92575,100916,106433
427
+ Los Angeles,Vernon,1905,90,152,91,112
428
+ San Bernardino,Victorville,1962,14220,40674,64029,115903
429
+ Orange,Villa Park,1962,7137,6299,5952,5812
430
+ Tulare,Visalia,1874,49729,75636,91877,124442
431
+ San Diego,Vista,1963,35834,71872,89857,93834
432
+ Los Angeles,Walnut,1959,12478,29105,30004,29172
433
+ Contra Costa,Walnut Creek,1914,53490,60569,64296,64173
434
+ Kern,Wasco,1945,9613,12412,21263,25545
435
+ Stanislaus,Waterford,1969,2683,4771,6924,8456
436
+ Santa Cruz,Watsonville,1868,23662,31099,44265,51199
437
+ Siskiyou,Weed,1961,2879,3062,2978,2967
438
+ Los Angeles,West Covina,1923,81292,96086,105080,106098
439
+ Los Angeles,West Hollywood,1984,,36118,35794,34399
440
+ Yolo,West Sacramento,1987,,28898,31615,48744
441
+ Los Angeles,Westlake Village,1981,,7455,8368,8270
442
+ Orange,Westminster,1957,71133,78118,88207,89701
443
+ Imperial,Westmorland,1934,1590,1380,2131,2225
444
+ Yuba,Wheatland,1874,1474,1631,2275,3456
445
+ Los Angeles,Whittier,1898,68558,77671,83680,85331
446
+ Colusa,Williams,1920,1658,2297,3670,5123
447
+ Mendocino,Willits,1888,4008,5027,5073,4888
448
+ Glenn,Willows,1886,4777,5988,6220,6166
449
+ Yolo,Winters,1898,2652,4639,6125,6624
450
+ Tulare,Woodlake,1941,4343,5678,6651,7279
451
+ Yolo,Woodland,1871,30235,39802,49151,55468
452
+ San Mateo,Woodside,1956,5291,5035,5352,5287
453
+ Orange,Yorba Linda,1967,28254,52422,58918,64234
454
+ Napa,Yountville,1965,2893,3259,3297,2933
455
+ Siskiyou,Yreka,1857,5916,6948,7290,7765
456
+ Sutter,Yuba City,1908,18736,27437,36758,64925
457
+ San Bernardino,Yucaipa,1989,,32824,41207,51367
data/california_cities.csv ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,Latitude,Longitude,County,City,Incorportation_date,pop_april_1980,pop_april_1990,pop_april_2000,pop_april_2010
2
+ 0,34.582769,-117.40921399999999,San Bernardino,Adelanto,1970,2164.0,8517,18130,31765
3
+ 1,34.153339,-118.761675,Los Angeles,Agoura Hills,1982,20390,20390,20537,20330
4
+ 2,37.765206,-122.24163600000001,Alameda,Alameda,1854,63852.0,76459,72259,73812
5
+ 3,37.886869,-122.297747,Alameda,Albany,1908,15130.0,16327,16444,18539
6
+ 4,34.095286,-118.12701399999999,Los Angeles,Alhambra,1903,64767.0,82106,85804,83089
7
+ 5,41.487114,-120.542456,Modoc,Alturas,1901,3025.0,3231,2892,2827
8
+ 6,38.419356,-120.82410300000001,Amador,Amador City,1915,136.0,196,196,185
9
+ 7,33.835291999999995,-117.914503,Orange,Anaheim,1876,219494.0,266406,328014,336265
10
+ 8,40.448208,-122.29778300000001,Shasta,Anderson,1956,7381.0,8299,9022,9932
11
+ 9,38.067783,-120.538531,Calaveras,Angels,1912,2302.0,2409,3004,3836
12
+ 10,38.004922,-121.80578899999999,Contra Costa,Antioch,1872,42683.0,62195,90532,102372
13
+ 11,34.139728000000005,-118.035344,Los Angeles,Arcadia,1903,45993.0,48290,53054,56364
14
+ 12,40.866517,-124.08283899999999,Humboldt,Arcata,1858,12850.0,15197,16651,17231
15
+ 13,35.118586,-120.590725,San Luis Obispo,Arroyo Grande,1911,11290.0,14378,15851,17252
16
+ 14,33.865846999999995,-118.083122,Los Angeles,Artesia,1959,14301.0,15464,16380,16522
17
+ 15,35.2018,-118.833106,Kern,Arvin,1960,6863.0,9286,12956,19304
18
+ 16,35.489416999999996,-120.670725,San Luis Obispo,Atascadero,1979,16232.0,23138,26411,28310
19
+ 17,37.347716999999996,-120.60908300000001,Merced,Atwater,1922,17530.0,22282,23113,28168
20
+ 18,38.896564,-121.076889,Placer,Auburn,1888,7540.0,10592,12462,13330
21
+ 19,33.342819,-118.328228,Los Angeles,Avalon,1913,2022.0,2918,3127,3728
22
+ 20,36.004121999999995,-120.129028,Kings,Avenal,1979,4137.0,9770,14674,15505
23
+ 21,34.133619,-117.907564,Los Angeles,Azusa,1898,29380.0,41333,44712,46361
24
+ 22,35.373292,-119.01871100000001,Kern,Bakersfield,1873,105611.0,174820,246889,347483
25
+ 23,34.085285999999996,-117.960897,Los Angeles,Baldwin Park,1956,50554.0,69330,75837,75390
26
+ 24,33.925571999999995,-116.876411,Riverside,Banning,1913,14020.0,20570,23562,29603
27
+ 25,34.895796999999995,-117.017283,San Bernardino,Barstow,1947,17690.0,21472,21119,22639
28
+ 26,33.929460999999996,-116.97724699999999,Riverside,Beaumont,1912,6818.0,9685,11384,36877
29
+ 27,33.977514,-118.187017,Los Angeles,Bell,1927,25450.0,34365,36664,35477
30
+ 28,33.965292,-118.151458,Los Angeles,Bell Gardens,1961,34117.0,42355,44054,42072
31
+ 29,33.881683,-118.117011,Los Angeles,Bellflower,1957,53441.0,61815,72878,76616
32
+ 30,37.520214,-122.2758,San Mateo,Belmont,1926,24505.0,24127,25123,25835
33
+ 31,37.872703,-122.464417,Marin,Belvedere,1896,2401.0,2147,2125,2068
34
+ 32,37.871592,-122.272747,Alameda,Berkeley,1878,103328.0,102724,102743,112580
35
+ 33,34.073619,-118.400356,Los Angeles,Beverly Hills,1914,32646.0,31971,33784,34109
36
+ 34,34.243897,-116.911422,San Bernardino,Big Bear Lake,1980,5351,5351,5438,5019
37
+ 35,39.412389000000005,-121.71275,Butte,Biggs,1903,1413.0,1581,1793,1707
38
+ 36,37.363539,-118.39511100000001,Inyo,Bishop,1903,3333.0,3475,3575,3879
39
+ 37,40.882908,-123.98395,Humboldt,Blue Lake,1910,1201.0,1235,1135,1253
40
+ 38,33.617233,-114.589175,Riverside,Blythe,1916,6805.0,8428,20463,20817
41
+ 39,34.14695,-117.970897,Los Angeles,Bradbury,1957,846.0,829,855,1048
42
+ 40,32.978658,-115.530267,Imperial,Brawley,1908,14946.0,18923,22052,24953
43
+ 41,33.916681,-117.90006100000001,Orange,Brea,1917,27913.0,32873,35410,39282
44
+ 42,34.057361,-118.480511,Contra Costa,Brentwood,1948,4434.0,7563,23302,51481
45
+ 43,37.680766999999996,-122.39997199999999,San Mateo,Brisbane,1961,2969.0,2952,3597,4282
46
+ 44,33.867514,-117.998117,Orange,Buena Park,1953,64165.0,68784,78282,80530
47
+ 45,34.180839,-118.308967,Los Angeles,Burbank,1911,84625.0,93643,100316,103340
48
+ 46,37.584103000000006,-122.366083,San Mateo,Burlingame,1908,26173.0,26801,28158,28806
49
+ 47,32.678946999999994,-115.498883,Imperial,Calexico,1908,14412.0,18633,27109,38572
50
+ 48,35.1258,-117.98590300000001,Kern,California City,1965,2743.0,5955,8385,14120
51
+ 49,33.125597,-115.51415300000001,Imperial,Calipatria,1919,2636.0,2690,7289,7705
52
+ 50,38.578796999999994,-122.579706,Napa,Calistoga,1886,3879.0,4468,5190,5155
53
+ 51,34.216394,-119.037603,Ventura,Camarillo,1964,37797.0,52303,57077,65201
54
+ 52,37.287164000000004,-121.94995800000001,Santa Clara,Campbell,1952,26910.0,36048,38138,39349
55
+ 53,36.975228,-121.95329199999999,Santa Cruz,Capitola,1949,9095.0,10171,10033,9918
56
+ 54,33.158091999999996,-117.350594,San Diego,Carlsbad,1952,35490.0,63126,78247,105328
57
+ 55,34.398883000000005,-119.518456,Santa Barbara,Carpinteria,1965,10835.0,13747,14194,13040
58
+ 56,33.831406,-118.282017,Los Angeles,Carson,1968,81221.0,83995,89730,91714
59
+ 57,33.779742,-116.46529199999999,Riverside,Cathedral City,1981,30085,30085,42647,51200
60
+ 58,37.594933000000005,-120.957711,Stanislaus,Ceres,1918,13281.0,26314,34609,45417
61
+ 59,33.858346999999995,-118.06478600000001,Los Angeles,Cerritos,1956,53020.0,53240,51488,49041
62
+ 60,39.728494,-121.837478,Butte,Chico,1872,26716.0,40079,60516,86187
63
+ 61,34.012236,-117.68894399999999,San Bernardino,Chino,1910,40165.0,59682,67168,77983
64
+ 62,37.123000000000005,-120.260175,Madera,Chowchilla,1923,5122.0,5930,14416,18720
65
+ 63,32.640053,-117.084197,San Diego,Chula Vista,1911,35490.0,63126,173556,243916
66
+ 64,34.096675,-117.719778,Los Angeles,Claremont,1907,31028.0,32503,33998,34926
67
+ 65,37.941033000000004,-121.93579199999999,Contra Costa,Clayton,1964,4325.0,7317,10762,10897
68
+ 66,38.805461,-123.017222,Sonoma,Cloverdale,1872,3989.0,4924,6831,8618
69
+ 67,36.825228,-119.702919,Fresno,Clovis,1912,33021.0,50323,68468,95631
70
+ 68,33.6803,-116.17389399999999,Riverside,Coachella,1946,9129.0,16896,22724,40704
71
+ 69,36.139678,-120.36015,Fresno,Coalinga,1906,6593.0,8212,16213,13380
72
+ 70,39.100731,-120.953275,Placer,Colfax,1910,981.0,1306,1496,1963
73
+ 71,34.073903,-117.31365600000001,San Bernardino,Colton,1887,21310.0,40213,47662,52154
74
+ 72,39.214333,-122.009417,Colusa,Colusa,1868,4075.0,4934,5402,5971
75
+ 73,34.000569,-118.159792,Los Angeles,Commerce,1960,10509.0,12135,12568,12823
76
+ 74,33.89585,-118.220072,Los Angeles,Compton,1888,81347.0,90454,93493,96455
77
+ 75,37.977978,-122.031072,Contra Costa,Concord,1905,103763.0,111348,121780,122067
78
+ 76,37.977978,-122.031072,Kings,Corcoran,1914,6454.0,13364,20835,24813
79
+ 77,39.927658,-122.179156,Tehama,Corning,1907,4745.0,5870,6741,7663
80
+ 78,33.875294,-117.56643899999999,Riverside,Corona,1896,37791.0,76095,124966,152374
81
+ 79,32.685885999999996,-117.183089,San Diego,Coronado,1890,18790.0,26540,24100,18912
82
+ 80,33.641133,-117.918669,Orange,Costa Mesa,1953,82562.0,96357,108724,109960
83
+ 81,38.327778,-122.709167,Sonoma,Cotati,1963,3346.0,5714,6471,7265
84
+ 82,34.090008000000005,-117.89033899999998,Los Angeles,Covina,1901,32746.0,43207,46837,47796
85
+ 83,41.755947,-124.201747,Del Norte,Crescent City,1854,3075.0,4380,7347,7643
86
+ 84,33.960569,-118.18535,Los Angeles,Cudahy,1960,18275.0,22817,24208,23805
87
+ 85,34.021122,-118.39646699999999,Los Angeles,Culver City,1917,38139.0,38793,38816,38883
88
+ 86,37.322996999999994,-122.032183,Santa Clara,Cupertino,1955,34297.0,40263,50546,58302
89
+ 87,37.320531,-121.96224199999999,Orange,Cypress,1956,40738.0,42655,46229,47802
90
+ 88,37.687925,-122.47020800000001,San Mateo,Daly City,1911,78427.0,92311,103625,101123
91
+ 89,33.466972,-117.698108,Orange,Dana Point,1989,31896,31896,35110,33351
92
+ 90,38.544906,-121.740517,Yolo,Davis,1917,36640.0,46209,60308,65622
93
+ 91,32.959489000000005,-117.26531399999999,San Diego,Del Mar,1959,5017.0,4860,4389,4161
94
+ 92,36.593292,-121.834953,Monterey,Del Rey Oaks,1953,1557.0,1661,1650,1624
95
+ 93,35.768842,-119.24705300000001,Kern,Delano,1915,16491.0,22762,39489,53041
96
+ 94,33.961125,-116.501678,Riverside,Desert Hot Springs,1963,5941.0,11668,16582,25938
97
+ 95,34.028622,-117.810336,Los Angeles,Diamond Bar,1989,53672,53672,56287,55544
98
+ 96,36.543283,-119.38706699999999,Tulare,Dinuba,1906,9907.0,12743,16844,21453
99
+ 97,38.445464,-121.823297,Solano,Dixon,1878,7541.0,10401,16103,18351
100
+ 98,41.967369,-121.91806100000001,Siskiyou,Dorris,1908,836.0,892,886,939
101
+ 99,36.986058,-120.626572,Merced,Dos Palos,1935,3121.0,4196,4581,4950
102
+ 100,33.940014,-118.13256899999999,Los Angeles,Downey,1956,82602.0,91444,107323,111772
103
+ 101,34.13945,-117.977286,Los Angeles,Duarte,1957,16766.0,20688,21486,21321
104
+ 102,37.702153,-121.93579199999999,Alameda,Dublin,1982,13496.0,23229,29973,46036
105
+ 103,41.208208,-122.271953,Siskiyou,Dunsmuir,1909,2253.0,2129,1923,1650
106
+ 104,37.468828,-122.141075,San Mateo,East Palo Alto,1983,23451,23451,29506,28155
107
+ 105,32.794771999999995,-116.962528,San Diego,El Cajon,1912,73892.0,88693,94869,99478
108
+ 106,32.792,-115.56305,Imperial,El Centro,1908,23996.0,31384,37835,42598
109
+ 107,37.916133,-122.31076399999999,Contra Costa,El Cerrito,1917,22731.0,22869,23171,23549
110
+ 108,34.068622,-118.02756699999999,Los Angeles,El Monte,1912,79494.0,106209,115965,113475
111
+ 109,33.919181,-118.41646399999999,Los Angeles,El Segundo,1917,13752.0,15223,16033,16654
112
+ 110,37.831317,-122.285247,Alameda,Emeryville,1896,3714.0,5740,6882,10080
113
+ 111,33.036986,-117.291983,San Diego,Encinitas,1986,55386,55386,58014,59518
114
+ 112,37.797428000000004,-120.99660300000001,San Joaquin,Escalon,1957,3127.0,4437,5963,7132
115
+ 113,33.119208,-117.086422,San Diego,Escondido,1888,64355.0,108635,133559,143911
116
+ 114,41.456806,-122.894756,Siskiyou,Etna,1878,754.0,835,781,737
117
+ 115,40.802071999999995,-124.16367199999999,Humboldt,Eureka,1856,24153.0,27025,26128,27191
118
+ 116,36.296061,-119.142053,Tulare,Exeter,1911,5606.0,7276,9168,10334
119
+ 117,38.249358,-122.03996699999999,Solano,Fairfield,1903,58099.0,77211,96178,105321
120
+ 118,36.297728,-119.206778,Tulare,Farmersville,1960,5544.0,6235,8737,10588
121
+ 119,40.576242,-124.263944,Humboldt,Ferndale,1893,1367.0,1331,1382,1371
122
+ 120,34.399164,-118.918153,Ventura,Fillmore,1914,9602.0,11992,13643,15002
123
+ 121,36.858839,-120.45600800000001,Fresno,Firebaugh,1914,3740.0,4429,5743,7549
124
+ 122,38.677958000000004,-121.17605800000001,Sacramento,Folsom,1946,11003.0,29802,51884,72203
125
+ 123,34.092233,-117.435047,San Bernardino,Fontana,1952,36991.0,87535,128929,196069
126
+ 124,39.445721999999996,-123.805292,Mendocino,Fort Bragg,1889,5019.0,6078,6814,7273
127
+ 125,41.663864000000004,-124.25289199999999,Siskiyou,Fort Jones,1872,544.0,639,660,839
128
+ 126,40.598186,-124.157275,Humboldt,Fortuna,1906,7591.0,8788,10497,11926
129
+ 127,37.558547,-122.271078,San Mateo,Foster City,1971,23287.0,28176,28803,30567
130
+ 128,33.709185999999995,-117.95366899999999,Orange,Fountain Valley,1957,55080.0,53691,54978,55313
131
+ 129,36.630506,-119.67846899999999,Fresno,Fowler,1908,2496.0,3208,3979,5570
132
+ 130,37.548269,-121.98857199999999,Alameda,Fremont,1956,131945.0,173339,203413,214089
133
+ 131,36.746842,-119.772586,Fresno,Fresno,1885,217129.0,354202,427652,494665
134
+ 132,33.870292,-117.925339,Orange,Fullerton,1904,102246.0,114144,126003,135161
135
+ 133,38.254636,-121.299947,Sacramento,Galt,1946,5514.0,8889,19472,23647
136
+ 134,33.773906,-117.941447,Orange,Garden Grove,1956,123307.0,143050,165196,170883
137
+ 135,33.88835,-118.30896100000001,Los Angeles,Gardena,1930,45165.0,49847,57746,58829
138
+ 136,37.005783,-121.568275,Santa Clara,Gilroy,1870,25769.0,26303,41464,48821
139
+ 137,34.142508,-118.255075,Los Angeles,Glendale,1906,139060.0,180038,194973,191719
140
+ 138,34.136119,-117.86533899999999,Los Angeles,Glendora,1911,38500.0,47828,49415,50073
141
+ 139,36.506628000000006,-121.444381,Monterey,Gonzales,1947,2891.0,4660,7564,8187
142
+ 140,34.033903,-117.313653,San Bernardino,Grand Terrace,1978,8498.0,10946,11626,12040
143
+ 141,39.219060999999996,-121.06106100000001,Nevada,Grass Valley,1893,6697.0,9048,10922,12860
144
+ 142,36.3208,-121.24381399999999,Monterey,Greenfield,1947,4181.0,7464,12648,16330
145
+ 143,39.363778,-121.693583,Butte,Gridley,1905,3982.0,4631,5382,6584
146
+ 144,35.121642,-120.621283,San Luis Obispo,Grover Beach,1959,8827.0,11656,13067,13156
147
+ 145,34.971644,-120.571836,Santa Barbara,Guadalupe,1946,3629.0,5479,5659,7080
148
+ 146,37.257717,-120.998814,Merced,Gustine,1915,3142.0,3931,4698,5520
149
+ 147,37.463553000000005,-122.42858600000001,San Mateo,Half Moon Bay,1959,7282.0,8886,11842,11324
150
+ 148,36.32745,-119.645683,Kings,Hanford,1891,20958.0,30897,41686,53967
151
+ 149,33.831403,-118.072842,Los Angeles,Hawaiian Gardens,1964,10548.0,13639,14779,14254
152
+ 150,33.916403,-118.352575,Los Angeles,Hawthorne,1922,56437.0,71349,84112,84293
153
+ 151,37.668819,-122.080797,Alameda,Hayward,1876,94342.0,111498,140030,144186
154
+ 152,38.610467,-122.869161,Sonoma,Healdsburg,1867,7217.0,9469,10722,11254
155
+ 153,33.747519,-116.97196699999999,Riverside,Hemet,1910,22454.0,36094,58812,78657
156
+ 154,38.017144,-122.28858100000001,Contra Costa,Hercules,1900,5963.0,16829,19488,24060
157
+ 155,33.862235999999996,-118.399519,Los Angeles,Hermosa Beach,1907,18070.0,18219,18566,19506
158
+ 156,34.426389,-117.300878,San Bernardino,Hesperia,1988,50418,50418,62582,90173
159
+ 157,34.160283,-118.65231100000001,Los Angeles,Hidden Hills,1961,1760.0,1729,1875,1856
160
+ 158,34.128344,-117.20865,San Bernardino,Highland,1987,34439,34439,44605,53104
161
+ 159,36.852453000000004,-121.40160300000001,San Benito,Hollister,1872,11488.0,19212,34413,34928
162
+ 160,32.811161,-115.380264,Imperial,Holtville,1908,4399.0,4820,5612,5939
163
+ 161,37.602725,-120.86648100000001,Stanislaus,Hughson,1972,2943.0,3259,3980,6640
164
+ 162,33.660297,-117.999225,Orange,Huntington Beach,1909,170505.0,181519,189594,189992
165
+ 163,33.981681,-118.225072,Los Angeles,Huntington Park,1906,45932.0,56065,61348,58114
166
+ 164,36.202731,-120.10291699999999,Fresno,Huron,1951,2768.0,4766,6306,6754
167
+ 165,32.847553000000005,-115.56943899999999,Imperial,Imperial,1904,3451.0,4113,7560,14758
168
+ 166,32.583944,-117.11308600000001,San Diego,Imperial Beach,1956,22689.0,26512,26992,26324
169
+ 167,33.717631,-116.340756,Riverside,Indian Wells,1967,1394.0,2647,3816,4958
170
+ 168,33.720578,-116.21556100000001,Riverside,Indio,1930,21611.0,36793,49116,76036
171
+ 169,34.019733,-117.958675,Los Angeles,Industry,1957,412.0,631,777,219
172
+ 170,33.961681,-118.353131,Los Angeles,Inglewood,1908,94162.0,109602,112580,109673
173
+ 171,38.352692,-120.932717,Amador,Ione,1953,2207.0,6516,7129,7918
174
+ 172,33.683946999999996,-117.79469399999999,Orange,Irvine,1971,62134.0,110330,143072,212375
175
+ 173,34.106953000000004,-117.93534199999999,Los Angeles,Irwindale,1957,1030.0,1050,1446,1422
176
+ 174,38.161861,-121.611622,Sacramento,Isleton,1923,914.0,833,828,804
177
+ 175,38.348803000000004,-120.774103,Amador,Jackson,1905,2331.0,3545,3989,4651
178
+ 176,36.723558000000004,-120.059878,Fresno,Kerman,1946,4002.0,5448,8551,13544
179
+ 177,36.212744,-121.126028,Monterey,King City,1911,5495.0,7634,11204,12874
180
+ 178,36.513839000000004,-119.55401699999999,Fresno,Kingsburg,1908,5115.0,7205,9199,11382
181
+ 179,34.206817,-118.200028,Los Angeles,La Cañada Flintridge,1976,20153.0,19378,20318,20246
182
+ 180,33.931958,-117.946172,Orange,La Habra,1925,45232.0,51266,58974,60239
183
+ 181,33.960846999999994,-117.95061899999999,Los Angeles,La Habra Heights,1978,4786.0,6226,5712,5325
184
+ 182,32.767828,-117.02308300000001,San Diego,La Mesa,1912,50308.0,52931,54749,57065
185
+ 183,33.917235999999995,-118.01200800000001,Los Angeles,La Mirada,1960,40986.0,40452,46783,48527
186
+ 184,33.846403,-118.04673100000001,Orange,La Palma,1955,15399.0,15392,15408,15568
187
+ 185,34.020011,-117.94950800000001,Los Angeles,La Puente,1956,30882.0,36955,41063,39816
188
+ 186,33.646692,-116.31000800000001,Riverside,La Quinta,1982,11215,11215,23694,37467
189
+ 187,34.100842,-117.76783600000002,Los Angeles,La Verne,1906,23508.0,30897,31638,31063
190
+ 188,37.885758,-122.11801899999999,Contra Costa,Lafayette,1968,20837.0,23501,23908,23893
191
+ 189,33.542246999999996,-117.783111,Orange,Laguna Beach,1927,17858.0,23170,23727,22723
192
+ 190,33.522525,-117.707553,Orange,Laguna Niguel,1989,44400,44400,61891,62979
193
+ 191,33.668078,-117.32726100000001,Riverside,Lake Elsinore,1888,5982.0,18285,28928,51821
194
+ 192,39.04295,-122.915828,Lake,Lakeport,1888,3675.0,4390,4820,4753
195
+ 193,33.853628,-118.13395600000001,Los Angeles,Lakewood,1954,74654.0,73557,79345,80048
196
+ 194,34.686786,-118.154164,Los Angeles,Lancaster,1977,48027.0,97291,118718,156633
197
+ 195,37.934092,-122.535253,Marin,Larkspur,1908,11064.0,11070,12014,11926
198
+ 196,37.822706,-121.27661100000002,San Joaquin,Lathrop,1989,6841,6841,10445,18023
199
+ 197,33.887236,-118.352575,Los Angeles,Lawndale,1959,23460.0,27331,31711,32769
200
+ 198,32.742553,-117.03141699999999,San Diego,Lemon Grove,1977,20780.0,23984,24918,25320
201
+ 199,36.300783,-119.78291100000001,Kings,Lemoore,1900,8832.0,13622,19712,24531
202
+ 200,38.891564,-121.293008,Placer,Lincoln,1890,4132.0,7248,11205,42819
203
+ 201,36.203006,-119.08816100000001,Tulare,Lindsay,1910,6936.0,8338,10297,11768
204
+ 202,36.983561,-121.98051699999999,Sutter,Live Oak,1947,3103.0,4320,6229,8392
205
+ 203,37.681875,-121.76800800000001,Alameda,Livermore,1876,48349.0,56741,73345,80968
206
+ 204,37.386883000000005,-120.723533,Merced,Livingston,1922,5326.0,7317,10473,13058
207
+ 205,38.134147,-121.27221899999999,San Joaquin,Lodi,1906,35221.0,51874,56999,62134
208
+ 206,34.048347,-117.26115300000001,San Bernardino,Loma Linda,1970,10694.0,17400,18681,23261
209
+ 207,33.792239,-118.315072,Los Angeles,Lomita,1964,18807.0,19382,20046,20256
210
+ 208,34.63915,-120.45794199999999,Santa Barbara,Lompoc,1888,26267.0,37649,41103,42434
211
+ 209,33.768322,-118.195617,Los Angeles,Long Beach,"i. 1888/ d.1896/
212
+ ri. 1897",361355.0,429433,461522,462257
213
+ 210,33.803072,-118.07256399999999,Orange,Los Alamitos,1960,11529.0,11676,11536,11449
214
+ 211,33.796331,-118.118119,Santa Clara,Los Altos,1952,25769.0,26303,27693,28976
215
+ 212,34.052233,-118.24368600000001,Los Angeles,Los Angeles,1850,2968579.0,3485398,3694742,3792621
216
+ 213,37.058278,-120.84991399999998,Merced,Los Banos,1907,10341.0,14519,25869,35972
217
+ 214,39.676294,-120.24103899999999,Sierra,Loyalton,1901,1030.0,931,862,769
218
+ 215,33.930292,-118.21146100000001,Los Angeles,Lynwood,1921,48409.0,61945,69845,69772
219
+ 216,36.961335999999996,-120.060717,Madera,Madera,1907,21732.0,29281,43207,61416
220
+ 217,33.884736,-118.410908,Los Angeles,Manhattan Beach,1912,31542.0,32063,33852,35135
221
+ 218,37.797428000000004,-121.216053,San Joaquin,Manteca,1918,24925.0,40773,49258,67096
222
+ 219,35.058858,-119.40095,Kern,Maricopa,1911,946.0,1193,1111,1154
223
+ 220,36.684403,-121.802172,Monterey,Marina,1975,20647.0,26436,18925,19718
224
+ 221,38.019366999999995,-122.134133,Contra Costa,Martinez,1876,22582.0,31808,35866,35824
225
+ 222,39.145725,-121.591356,Yuba,Marysville,1851,9898.0,12324,12268,12072
226
+ 223,33.986681,-118.18535,Los Angeles,Maywood,1924,21810.0,27850,28083,27395
227
+ 224,35.678011,-119.229275,Kern,McFarland,1957,5151.0,7005,9837,12707
228
+ 225,36.753561,-120.38155800000001,Fresno,Mendota,1942,5038.0,6821,7890,11014
229
+ 226,37.453828,-122.18218600000002,San Mateo,Menlo Park,1927,26438.0,28040,30785,32026
230
+ 227,37.302164000000005,-120.48296699999999,Merced,Merced,1889,36499.0,56216,63893,78958
231
+ 228,37.906036,-122.544975,Marin,Mill Valley,1900,12967.0,13038,13600,13903
232
+ 229,37.598546999999996,-122.387194,San Mateo,Millbrae,1948,20058.0,20412,20718,21532
233
+ 230,37.428272,-121.906625,Santa Clara,Milpitas,1954,37820.0,50686,62698,66790
234
+ 231,33.600021999999996,-117.671994,Orange,Mission Viejo,1988,72820,72820,93102,93305
235
+ 232,37.639097,-120.99687800000001,Stanislaus,Modesto,1884,106963.0,164730,188856,201165
236
+ 233,34.144428000000005,-118.001947,Los Angeles,Monrovia,1887,30531.0,35761,36929,36590
237
+ 234,41.728196999999994,-122.5278,Siskiyou,Montague,1909,1285.0,1415,1456,1443
238
+ 235,34.077511,-117.689778,San Bernardino,Montclair,1956,22628.0,28434,33049,36664
239
+ 236,37.236333,-121.99245800000001,Santa Clara,Monte Sereno,1957,3434.0,3287,3483,3341
240
+ 237,34.016506,-118.113753,Los Angeles,Montebello,1920,52929.0,59564,62150,62500
241
+ 238,36.600239,-121.894675,Monterey,Monterey,1890,27558.0,31954,29696,27810
242
+ 239,34.062511,-118.122847,Los Angeles,Monterey Park,1916,54338.0,60738,60051,60269
243
+ 240,34.144897,-118.26874199999999,Ventura,Moorpark,1983,25494,25494,31415,34421
244
+ 241,33.942467,-117.229672,Riverside,Moreno Valley,1984,118779,118779,142381,193365
245
+ 242,37.1305,-121.654389,Santa Clara,Morgan Hill,1906,17060.0,23928,33556,37882
246
+ 243,35.365808,-120.8499,San Luis Obispo,Morro Bay,1964,9064.0,9664,10350,10234
247
+ 244,41.410806,-122.194575,Siskiyou,Mount Shasta,1905,2837.0,3460,3621,3394
248
+ 245,37.386053000000004,-122.08385,Santa Clara,Mountain View,1902,58655.0,67460,70708,74066
249
+ 246,38.297539,-122.286864,Napa,Napa,1872,50879.0,61842,72585,76915
250
+ 247,32.678108,-117.099197,San Diego,National City,1887,48772.0,54249,54260,58582
251
+ 248,34.848061,-114.61413300000001,San Bernardino,Needles,1913,4120.0,5191,4830,4844
252
+ 249,39.261561,-121.016058,Nevada,Nevada City,1856,2431.0,2855,3001,3068
253
+ 250,37.529658000000005,-122.04023899999999,Alameda,Newark,1955,32126.0,37861,42471,42573
254
+ 251,37.313828,-121.02076100000001,Stanislaus,Newman,1908,2785.0,4151,7093,10224
255
+ 252,33.618911,-117.928947,Orange,Newport Beach,1906,62556.0,66643,70032,85186
256
+ 253,33.931125,-117.54866100000001,Riverside,Norco,1964,19732.0,23302,24157,27063
257
+ 254,33.902236,-118.08173300000001,Los Angeles,Norwalk,1957,84901.0,94279,104323,105549
258
+ 255,38.107419,-122.569703,Marin,Novato,1960,43916.0,47585,47630,51904
259
+ 256,37.766594,-120.847153,Stanislaus,Oakdale,1906,8474.0,11961,15503,20675
260
+ 257,37.804364,-122.27111399999998,Alameda,Oakland,1852,339337.0,372242,399484,390724
261
+ 258,33.195869,-117.37948300000001,San Diego,Oceanside,1888,76698.0,128398,161029,167086
262
+ 259,34.44805,-119.24288899999999,Ventura,Ojai,1921,6816.0,7613,7862,7461
263
+ 260,34.063344,-117.65088899999999,San Bernardino,Ontario,1891,88820.0,133179,158007,163924
264
+ 261,33.787794,-117.85311100000001,Orange,Orange,1888,91450.0,110658,128868,136416
265
+ 262,36.624394,-119.313731,Fresno,Orange Cove,1948,4026.0,5604,7722,9078
266
+ 263,37.877146999999994,-122.179689,Contra Costa,Orinda,1985,16642,16642,17599,17643
267
+ 264,39.747381,-122.196375,Glenn,Orland,1909,4031.0,5052,6281,7291
268
+ 265,39.513775,-121.556358,Butte,Oroville,1906,8693.0,11960,13004,15546
269
+ 266,34.197506,-119.177053,Ventura,Oxnard,1903,108195.0,142216,170358,197899
270
+ 267,36.617736,-121.916622,Monterey,Pacific Grove,1889,15755.0,16117,15522,15041
271
+ 268,37.613825,-122.486919,San Mateo,Pacifica,1957,36866.0,37670,38390,37234
272
+ 269,33.722244,-116.37445600000001,Riverside,Palm Desert,1973,11801.0,23252,41155,48445
273
+ 270,33.830296999999995,-116.54529199999999,Riverside,Palm Springs,1938,32359.0,40181,42807,44552
274
+ 271,34.579433,-118.11646100000002,Los Angeles,Palmdale,1962,12277.0,68842,116670,152750
275
+ 272,37.441883000000004,-122.143019,Santa Clara,Palo Alto,1894,55225.0,55900,58598,64403
276
+ 273,33.800571999999995,-118.390075,Los Angeles,Palos Verdes Estates,1939,14376.0,13512,13340,13438
277
+ 274,33.889461,-118.159792,Los Angeles,Paramount,1957,36407.0,47669,55266,54098
278
+ 275,36.611616999999995,-119.527072,Fresno,Parlier,1921,2902.0,7938,11145,14494
279
+ 276,34.147785999999996,-118.144517,Los Angeles,Pasadena,1886,118072.0,131591,133936,137122
280
+ 277,35.632278,-120.66418600000002,San Luis Obispo,Paso Robles,1889,9163.0,18583,24297,29793
281
+ 278,37.4716,-121.12965600000001,Stanislaus,Patterson,1919,3908.0,8626,11606,20413
282
+ 279,33.782519,-117.228647,Riverside,Perris,1911,6827.0,21460,36189,68386
283
+ 280,38.232417,-122.63665300000001,Sonoma,Petaluma,1858,33834.0,43184,54548,57941
284
+ 281,33.983069,-118.096736,Los Angeles,Pico Rivera,1958,53387.0,59177,63428,62942
285
+ 282,37.824372,-122.23163600000001,Alameda,Piedmont,1907,10498.0,10602,10952,10667
286
+ 283,38.004366999999995,-122.29885800000001,Contra Costa,Pinole,1903,14253.0,17460,19039,18390
287
+ 284,35.142753000000006,-120.641283,San Luis Obispo,Pismo Beach,1939,5364.0,7669,8551,7655
288
+ 285,38.027975,-121.884681,Contra Costa,Pittsburg,1903,33465.0,47564,56769,63264
289
+ 286,33.872236,-117.87033600000001,Orange,Placentia,1926,35041.0,41259,46488,50533
290
+ 287,38.729625,-120.798547,El Dorado,Placerville,1854,6739.0,8355,9610,10389
291
+ 288,37.947978000000006,-122.060797,Contra Costa,Pleasant Hill,1961,25547.0,31585,32837,33152
292
+ 289,37.662431,-121.874678,Alameda,Pleasanton,1894,35160.0,50553,63654,70285
293
+ 290,38.481853,-120.84465800000001,Amador,Plymouth,1917,699.0,811,980,1005
294
+ 291,38.908797,-123.693072,Mendocino,Point Arena,1908,425.0,407,474,449
295
+ 292,34.055228,-117.752306,Los Angeles,Pomona,1888,92742.0,131723,149473,149058
296
+ 293,34.180728,-119.20815800000001,Ventura,Port Hueneme,1948,17803.0,20319,21845,21723
297
+ 294,36.065231,-119.01676699999999,Tulare,Porterville,1902,19707.0,29563,39615,54165
298
+ 295,39.810458000000004,-120.469103,Plumas,Portola,1946,1885.0,2193,2227,2104
299
+ 296,32.962821999999996,-117.03586399999999,San Diego,Poway,1980,43516,43516,48044,47811
300
+ 297,34.1064,-117.593108,San Bernardino,Rancho Cucamonga,1977,55250.0,101409,127743,165269
301
+ 298,33.739744,-116.41278899999999,Riverside,Rancho Mirage,1973,6281.0,9778,13249,17218
302
+ 299,33.744461,-118.38701699999999,Los Angeles,Rancho Palos Verdes,1973,36577.0,41659,41145,41643
303
+ 300,40.178489,-122.235831,Tehama,Red Bluff,1876,9490.0,12363,13147,14076
304
+ 301,40.586539,-122.391675,Shasta,Redding,1887,41995.0,66462,80865,89861
305
+ 302,34.055569,-117.18253899999999,San Bernardino,Redlands,1888,43619.0,60394,63591,68747
306
+ 303,33.849183000000004,-118.38840800000001,Los Angeles,Redondo Beach,1892,57102.0,60167,63261,66748
307
+ 304,37.485214,-122.236356,San Mateo,Redwood City,1867,54951.0,66072,75402,76815
308
+ 305,36.596339,-119.45040300000001,Fresno,Reedley,1913,11071.0,15791,20756,24194
309
+ 306,34.1064,-117.370325,San Bernardino,Rialto,1911,37862.0,72388,91873,99171
310
+ 307,37.935758,-122.34775,Contra Costa,Richmond,1905,74676.0,87425,99216,103701
311
+ 308,35.622456,-117.670897,Kern,Ridgecrest,1963,15929.0,27725,24927,27616
312
+ 309,40.4993,-124.10643600000002,Humboldt,Rio Dell,1965,2687.0,3012,3174,3368
313
+ 310,38.15575,-121.691344,Solano,Rio Vista,1894,3142.0,3316,4571,7360
314
+ 311,37.739453000000005,-121.13541399999998,San Joaquin,Ripon,1945,3509.0,7455,10146,14297
315
+ 312,37.736039,-120.93548899999999,Stanislaus,Riverbank,1922,5695.0,8547,15826,22678
316
+ 313,33.95335,-117.396156,Riverside,Riverside,1883,170591.0,226505,255166,303871
317
+ 314,38.790733,-121.23578300000001,Placer,Rocklin,1893,7344.0,19033,36330,56974
318
+ 315,38.339636,-122.701097,Sonoma,Rohnert Park,1962,22965.0,36326,42236,40971
319
+ 316,33.756961,-118.35396100000001,Los Angeles,Rolling Hills,1957,2049.0,1871,1871,1860
320
+ 317,33.787794,-118.35812800000001,Los Angeles,Rolling Hills Estates,1957,7701.0,7789,7676,8067
321
+ 318,34.080564,-118.072847,Los Angeles,Rosemead,1959,42604.0,51638,53505,53764
322
+ 319,38.752122,-121.28800600000001,Placer,Roseville,1909,24347.0,44685,79921,118788
323
+ 320,38.581571999999994,-121.4944,Sacramento,Sacramento,1850,275741.0,369365,407018,466488
324
+ 321,36.677735999999996,-121.6555,Monterey,Salinas,1874,80479.0,108777,142685,150441
325
+ 322,34.108344,-117.28976399999999,San Bernardino,San Bernardino,1869,118794.0,164164,185401,209924
326
+ 323,37.630489000000004,-122.411083,San Mateo,San Bruno,1914,35417.0,38961,40165,41114
327
+ 324,37.507158000000004,-122.260522,San Mateo,San Carlos,1925,24710.0,26167,27718,28406
328
+ 325,33.426972,-117.61199199999999,Orange,San Clemente,1928,27325.0,41100,49936,63522
329
+ 326,32.715328,-117.157256,San Diego,San Diego,1850,875538.0,1110549,1223400,1307402
330
+ 327,34.106675,-117.806725,Los Angeles,San Dimas,1960,24014.0,32397,34980,33371
331
+ 328,34.281946999999995,-118.43897199999999,Los Angeles,San Fernando,1911,17731.0,22580,23564,23645
332
+ 329,37.774931,-122.419417,San Francisco,San Francisco,1850,678974.0,723959,776733,805235
333
+ 330,34.096111,-118.105833,Los Angeles,San Gabriel,1913,30072.0,37120,39804,39718
334
+ 331,33.783908000000004,-116.95863600000001,Riverside,San Jacinto,1888,7098.0,16210,23779,44199
335
+ 332,36.606617,-120.189044,Fresno,San Joaquin,1920,1930.0,2311,3270,4001
336
+ 333,37.339386,-121.89495600000001,Santa Clara,San Jose,1850,629531.0,782248,894943,945942
337
+ 334,36.845511,-121.537997,San Benito,San Juan Bautista,1869,1276.0,1570,1549,1862
338
+ 335,33.501692,-117.66255,Orange,San Juan Capistrano,1961,18959.0,26183,33826,34593
339
+ 336,37.724931,-122.15607800000001,Alameda,San Leandro,1872,63952.0,68223,79452,84950
340
+ 337,35.282753,-120.659617,San Luis Obispo,San Luis Obispo,1856,34252.0,41958,44174,45119
341
+ 338,33.143372,-117.16614399999999,San Diego,San Marcos,1963,17479.0,38974,54977,83781
342
+ 339,34.121396999999995,-118.106458,Los Angeles,San Marino,1913,13307.0,12959,12945,13147
343
+ 340,37.562992,-122.325525,San Mateo,San Mateo,1894,77640.0,85486,92482,97207
344
+ 341,37.962146999999995,-122.345525,Contra Costa,San Pablo,1948,19750.0,25158,30215,29139
345
+ 342,37.973535999999996,-122.53108600000002,Marin,San Rafael,1874,44700.0,48404,56063,57713
346
+ 343,37.779928000000005,-121.97801399999999,Contra Costa,San Ramon,1983,35303,35303,44722,72148
347
+ 344,36.617183000000004,-121.84828600000002,Monterey,Sand City,1960,182.0,192,261,334
348
+ 345,36.708006,-119.55596399999999,Fresno,Sanger,1911,12542.0,16839,18931,24270
349
+ 346,33.745571999999996,-117.867833,Orange,Santa Ana,1886,204023.0,293742,337977,324528
350
+ 347,34.420831,-119.69818899999999,Santa Barbara,Santa Barbara,1850,74414.0,85571,89600,88410
351
+ 348,37.354108000000004,-121.95523600000001,Santa Clara,Santa Clara,1852,87700.0,93613,102361,116468
352
+ 349,34.391664,-118.54258600000001,Los Angeles,Santa Clarita,1987,110642,110642,151088,176320
353
+ 350,36.974117,-122.03079699999999,Santa Cruz,Santa Cruz,1866,41483.0,49040,54593,59946
354
+ 351,33.947236,-118.08534399999999,Los Angeles,Santa Fe Springs,1957,14520.0,15520,16413,16223
355
+ 352,34.953033000000005,-120.43571899999999,Santa Barbara,Santa Maria,1905,39685.0,61284,77423,99553
356
+ 353,34.019453000000006,-118.491192,Los Angeles,Santa Monica,1886,88314.0,86905,84084,89736
357
+ 354,34.354167,-119.059269,Ventura,Santa Paula,1902,20658.0,25062,28598,29321
358
+ 355,38.440467,-122.714431,Sonoma,Santa Rosa,1868,82658.0,113313,147595,167815
359
+ 356,32.838383,-116.97391699999999,San Diego,Santee,1980,52902,52902,52975,53413
360
+ 357,37.263833,-122.02301399999999,Santa Clara,Saratoga,1956,29261.0,28061,29843,29926
361
+ 358,37.859094,-122.48525,Marin,Sausalito,1893,7338.0,7152,7330,7061
362
+ 359,37.051061,-122.014683,Santa Cruz,Scotts Valley,1966,6891.0,8615,11385,11580
363
+ 360,33.741406,-118.104786,Orange,Seal Beach,1915,25975.0,25098,24157,24168
364
+ 361,33.819361,-118.366647,Monterey,Seaside,1954,36567.0,38901,33097,33025
365
+ 362,38.402136,-122.823881,Sonoma,Sebastopol,1902,5595.0,7004,7774,7379
366
+ 363,36.570783,-119.612075,Fresno,Selma,1893,10942.0,14757,19444,23219
367
+ 364,35.500514,-119.271775,Kern,Shafter,1938,7010.0,8409,12736,16988
368
+ 365,34.161671999999996,-118.052847,Los Angeles,Sierra Madre,1907,10837.0,10762,10578,10917
369
+ 366,33.804460999999996,-118.167847,Los Angeles,Signal Hill,1924,5734.0,8371,9333,11016
370
+ 367,34.269447,-118.78148300000001,Ventura,Simi Valley,1969,77500.0,100217,111351,124237
371
+ 368,32.991156,-117.271147,San Diego,Solana Beach,1986,12962,12962,12979,12867
372
+ 369,32.991156,-117.271147,Monterey,Soledad,1921,3091.0,7146,23015,25738
373
+ 370,34.595819,-120.137647,Santa Barbara,Solvang,1985,4741,4741,5332,5245
374
+ 371,38.291858000000005,-122.458036,Sonoma,Sonoma,1883,6054.0,8121,9128,10648
375
+ 372,37.984092,-120.382139,Tuolumne,Sonora,1851,3247.0,4153,4423,4903
376
+ 373,34.051956,-118.046733,Los Angeles,South El Monte,1958,16623.0,20850,21144,20116
377
+ 374,33.954736,-118.21201699999999,Los Angeles,South Gate,1923,66784.0,86284,96375,94396
378
+ 375,38.939925,-119.977186,El Dorado,South Lake Tahoe,1965,20681.0,21586,23609,21403
379
+ 376,34.116119,-118.15035,Los Angeles,South Pasadena,1888,22681.0,23936,24292,25619
380
+ 377,37.654656,-122.40775,San Mateo,South San Francisco,1908,49393.0,54312,60552,63632
381
+ 378,38.505241999999996,-122.470386,Napa,St. Helena,1876,4898.0,4990,5950,5814
382
+ 379,33.802517,-117.993117,Orange,Stanton,1911,23723.0,30491,37403,38186
383
+ 380,37.957703,-121.29078100000001,San Joaquin,Stockton,1850,148283.0,210943,243771,291707
384
+ 381,38.238246999999994,-122.040244,Solano,Suisun City,1868,11087.0,22686,26118,28111
385
+ 382,37.368831,-122.03635,Santa Clara,Sunnyvale,1912,106618.0,117229,131760,140081
386
+ 383,40.416283,-120.653006,Lassen,Susanville,1900,6520.0,7279,17428,17947
387
+ 384,38.392967,-120.80243600000001,Amador,Sutter Creek,1913,1705.0,1835,2303,2501
388
+ 385,35.142466999999996,-119.45650800000001,Kern,Taft,1910,5316.0,5902,8811,9327
389
+ 386,35.132189000000004,-118.448975,Kern,Tehachapi,1909,4126.0,5791,11125,14414
390
+ 387,40.027103000000004,-122.123322,Tehama,Tehama,1906,365.0,401,432,418
391
+ 388,33.493639,-117.14836399999999,Riverside,Temecula,1989,27099,27099,57716,100097
392
+ 389,34.107231,-118.057847,Los Angeles,Temple City,1960,28972.0,31100,33377,35558
393
+ 390,34.107231,-118.057847,Ventura,Thousand Oaks,1964,77072.0,104352,117005,126683
394
+ 391,33.83585,-118.34062800000001,Los Angeles,Torrance,1921,129881.0,133107,137946,145438
395
+ 392,37.73965,-121.42522199999999,San Joaquin,Tracy,1910,18428.0,33558,56929,82922
396
+ 393,41.059292,-124.143125,Humboldt,Trinidad,1870,379.0,362,311,367
397
+ 394,36.207728,-119.34733899999999,Tulare,Tulare,1888,22530.0,33249,43994,59278
398
+ 395,41.955989,-121.477492,Siskiyou,Tulelake,1937,783.0,1010,1020,1010
399
+ 396,37.494658,-120.846594,Stanislaus,Turlock,1908,26287.0,42198,55810,68549
400
+ 397,33.74585,-117.826167,Orange,Tustin,1927,32256.0,50689,67504,75540
401
+ 398,34.135558,-116.05416899999999,San Bernardino,Twentynine Palms,1987,11821,11821,14764,25048
402
+ 399,39.150172,-123.207783,Mendocino,Ukiah,1876,12035.0,14599,15497,16075
403
+ 400,37.593392,-122.04383100000001,Alameda,Union City,1959,39406.0,53762,66869,69516
404
+ 401,34.097511,-117.648389,San Bernardino,Upland,1906,47647.0,63374,68393,73732
405
+ 402,38.356578000000006,-121.98774399999999,Solano,Vacaville,1892,43367.0,71479,88625,92428
406
+ 403,38.104085999999995,-122.25663600000001,Solano,Vallejo,1868,80303.0,109199,116760,115942
407
+ 404,34.274639,-119.22900600000001,Ventura,Ventura,1866,73774.0,92575,100916,106433
408
+ 405,34.003903,-118.23007199999999,Los Angeles,Vernon,1905,90.0,152,91,112
409
+ 406,34.536108,-117.29115800000001,San Bernardino,Victorville,1962,14220.0,40674,64029,115903
410
+ 407,33.814461,-117.813111,Orange,Villa Park,1962,7137.0,6299,5952,5812
411
+ 408,36.330228000000005,-119.29205800000001,Tulare,Visalia,1874,49729.0,75636,91877,124442
412
+ 409,33.200036,-117.24253600000002,San Diego,Vista,1963,35834.0,71872,89857,93834
413
+ 410,34.020289,-117.86533899999999,Los Angeles,Walnut,1959,12478.0,29105,30004,29172
414
+ 411,37.910078000000006,-122.065183,Contra Costa,Walnut Creek,1914,53490.0,60569,64296,64173
415
+ 412,35.594125,-119.340947,Kern,Wasco,1945,9613.0,12412,21263,25545
416
+ 413,37.641319,-120.76048300000001,Stanislaus,Waterford,1969,2683.0,4771,6924,8456
417
+ 414,36.910231,-121.75689399999999,Santa Cruz,Watsonville,1868,23662.0,31099,44265,51199
418
+ 415,41.42265,-122.386128,Siskiyou,Weed,1961,2879.0,3062,2978,2967
419
+ 416,34.068622,-117.938953,Los Angeles,West Covina,1923,81292.0,96086,105080,106098
420
+ 417,34.090008000000005,-118.36174399999999,Los Angeles,West Hollywood,1984,36118,36118,35794,34399
421
+ 418,38.580461,-121.53023300000001,Yolo,West Sacramento,1987,28898,28898,31615,48744
422
+ 419,34.145839,-118.805647,Los Angeles,Westlake Village,1981,7455,7455,8368,8270
423
+ 420,33.751342,-117.99399199999999,Orange,Westminster,1957,71133.0,78118,88207,89701
424
+ 421,33.037267,-115.62138300000001,Imperial,Westmorland,1934,1590.0,1380,2131,2225
425
+ 422,39.009894,-121.423014,Yuba,Wheatland,1874,1474.0,1631,2275,3456
426
+ 423,33.979178000000005,-118.032844,Los Angeles,Whittier,1898,68558.0,77671,83680,85331
427
+ 424,39.154614,-122.149419,Colusa,Williams,1920,1658.0,2297,3670,5123
428
+ 425,39.409608,-123.355567,Mendocino,Willits,1888,4008.0,5027,5073,4888
429
+ 426,39.524325,-122.193592,Glenn,Willows,1886,4777.0,5988,6220,6166
430
+ 427,38.524906,-121.970803,Yolo,Winters,1898,2652.0,4639,6125,6624
431
+ 428,36.413561,-119.098717,Tulare,Woodlake,1941,4343.0,5678,6651,7279
432
+ 429,38.678517,-121.773297,Yolo,Woodland,1871,30235.0,39802,49151,55468
433
+ 430,33.888625,-117.813111,Orange,Yorba Linda,1967,28254.0,52422,58918,64234
434
+ 431,41.735419,-122.634472,Siskiyou,Yreka,1857,5916.0,6948,7290,7765
435
+ 432,39.140446999999995,-121.61691100000002,Sutter,Yuba City,1908,18736.0,27437,36758,64925
436
+ 433,34.033625,-117.04308600000002,San Bernardino,Yucaipa,1989,32824,32824,41207,51367
data/california_counties.csv ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,County,Latitude,Longitude,pop_april_1990
2
+ 0,Alameda,37.72108914285714,-122.10629442857139,1159300
3
+ 1,Amador,38.3991342,-120.8356034,12903
4
+ 2,Butte,39.504609,-121.70004225,58251
5
+ 3,Calaveras,38.067783,-120.538531,2409
6
+ 4,Colusa,39.1844735,-122.079418,7231
7
+ 5,Contra Costa,37.70406712500001,-121.891572375,605136
8
+ 6,Del Norte,41.755947,-124.201747,4380
9
+ 7,El Dorado,38.834775,-120.3878665,29941
10
+ 8,Fresno,36.60750253333333,-119.84778606666667,507854
11
+ 9,Glenn,39.635853,-122.1949835,11040
12
+ 10,Humboldt,40.754931000000006,-124.12874871428572,56950
13
+ 11,Imperial,32.895883285714284,-115.52534842857143,81943
14
+ 12,Inyo,37.363539,-118.395111,3475
15
+ 13,Kern,35.381668545454545,-118.90037272727272,281260
16
+ 14,Kings,36.65258325,-120.39717350000001,67653
17
+ 15,Lake,39.04295,-122.915828,4390
18
+ 16,Lassen,40.416283,-120.653006,7279
19
+ 17,Los Angeles,34.01223316279069,-118.16819196511624,7892444
20
+ 18,Madera,37.042168000000004,-120.16044600000001,35211
21
+ 19,Marin,37.942146666666666,-122.52178066666666,129396
22
+ 20,Mendocino,39.22857475,-123.5154285,26111
23
+ 21,Merced,37.22313616666667,-120.71514716666667,108461
24
+ 22,Modoc,41.487114,-120.542456,3231
25
+ 23,Monterey,35.967388909090914,-120.94583863636363,250942
26
+ 24,Napa,38.46052600000001,-122.445652,71300
27
+ 25,Nevada,39.240311000000005,-121.03855949999999,11903
28
+ 26,Orange,33.85135710344828,-118.01976731034482,2183131
29
+ 27,Placer,38.8863428,-121.16939219999999,82864
30
+ 28,Plumas,39.810458,-120.469103,2193
31
+ 29,Riverside,33.78326276190476,-116.72182676190475,785027
32
+ 30,Sacramento,38.41900675,-121.39550675,408889
33
+ 31,San Benito,36.848982,-121.46979999999999,20782
34
+ 32,San Bernardino,34.2241070952381,-117.15653514285717,1049825
35
+ 33,San Diego,32.90077138888889,-117.15095872222221,2027215
36
+ 34,San Francisco,37.774931,-122.419417,723959
37
+ 35,San Joaquin,37.85550214285714,-121.23041471428571,355881
38
+ 36,San Luis Obispo,35.30760528571428,-120.67110271428574,127046
39
+ 37,San Mateo,37.56470973333334,-122.33668913333334,563824
40
+ 38,Santa Barbara,34.66322666666667,-120.13663150000001,208471
41
+ 39,Santa Clara,37.027805692307695,-121.64295630769234,1351329
42
+ 40,Santa Cruz,36.97765925,-121.9389165,98925
43
+ 41,Shasta,40.517373500000005,-122.344729,74761
44
+ 42,Sierra,39.676294,-120.241039,931
45
+ 43,Siskiyou,41.61658977777777,-122.50645877777778,20390
46
+ 44,Solano,38.25824716666667,-121.97320533333334,294292
47
+ 45,Sonoma,38.4312775,-122.741206,228055
48
+ 46,Stanislaus,37.58453255555556,-120.92902288888887,274557
49
+ 47,Sutter,38.062004,-121.79871400000002,31757
50
+ 48,Tehama,40.04441666666666,-122.17943633333334,18634
51
+ 49,Tulare,36.29460325,-119.1973675,178718
52
+ 50,Tuolumne,37.984092,-120.382139,4153
53
+ 51,Ventura,34.2592223,-118.89802030000001,582143
54
+ 52,Yolo,38.5821975,-121.7537125,119548
55
+ 53,Yuba,39.0778095,-121.50718499999999,13955
data/hud_dataset.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/thads2011.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b72ed51a381d6b1a404a921f1979469fd321487b36fb064b700edbc52ff1f470
3
+ size 119914024
data/thads2013n.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb4286817ff2e3081332715d73c3e0dd258f4d8351a641d0af367b11098b9c25
3
+ size 53281106
model.ipynb ADDED
@@ -0,0 +1,1383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "!pip install pygam seaborn statsmodels --quiet"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 2,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "import pickle\n",
19
+ "import torch\n",
20
+ "import torch.nn as nn\n",
21
+ "import torch.optim as optim\n",
22
+ "from sklearn.datasets import fetch_california_housing\n",
23
+ "from sklearn.model_selection import train_test_split\n",
24
+ "import numpy as np\n",
25
+ "import pandas as pd\n",
26
+ "from sklearn.preprocessing import StandardScaler,OrdinalEncoder\n",
27
+ "from sklearn.model_selection import train_test_split\n",
28
+ "from sklearn.linear_model import LinearRegression, LogisticRegression\n",
29
+ "from sklearn.metrics import classification_report, recall_score, precision_score, accuracy_score\n",
30
+ "from sklearn.metrics import mean_squared_error\n",
31
+ "import matplotlib.pyplot as plt\n",
32
+ "import seaborn as sns\n",
33
+ "import zipfile\n",
34
+ "from statsmodels.genmod.generalized_linear_model import GLM\n",
35
+ "from statsmodels.genmod.families import Gamma\n",
36
+ "from statsmodels.genmod.families.links import Log\n",
37
+ "from statsmodels.tools import add_constant\n",
38
+ "from pygam import LinearGAM, GammaGAM, s, f"
39
+ ]
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": 3,
44
+ "metadata": {},
45
+ "outputs": [
46
+ {
47
+ "data": {
48
+ "text/html": [
49
+ "<div>\n",
50
+ "<style scoped>\n",
51
+ " .dataframe tbody tr th:only-of-type {\n",
52
+ " vertical-align: middle;\n",
53
+ " }\n",
54
+ "\n",
55
+ " .dataframe tbody tr th {\n",
56
+ " vertical-align: top;\n",
57
+ " }\n",
58
+ "\n",
59
+ " .dataframe thead th {\n",
60
+ " text-align: right;\n",
61
+ " }\n",
62
+ "</style>\n",
63
+ "<table border=\"1\" class=\"dataframe\">\n",
64
+ " <thead>\n",
65
+ " <tr style=\"text-align: right;\">\n",
66
+ " <th></th>\n",
67
+ " <th>CONTROL</th>\n",
68
+ " <th>AGE1</th>\n",
69
+ " <th>METRO3</th>\n",
70
+ " <th>REGION</th>\n",
71
+ " <th>LMED</th>\n",
72
+ " <th>FMR</th>\n",
73
+ " <th>L30</th>\n",
74
+ " <th>L50</th>\n",
75
+ " <th>L80</th>\n",
76
+ " <th>IPOV</th>\n",
77
+ " <th>...</th>\n",
78
+ " <th>FMTCOST06RELAMICAT</th>\n",
79
+ " <th>FMTCOST08RELAMICAT</th>\n",
80
+ " <th>FMTCOST12RELAMICAT</th>\n",
81
+ " <th>FMTCOSTMEDRELAMICAT</th>\n",
82
+ " <th>FMTINCRELAMICAT</th>\n",
83
+ " <th>FMTASSISTED</th>\n",
84
+ " <th>FMTBURDEN</th>\n",
85
+ " <th>FMTREGION</th>\n",
86
+ " <th>FMTSTATUS</th>\n",
87
+ " <th>HOUSE_AGE</th>\n",
88
+ " </tr>\n",
89
+ " </thead>\n",
90
+ " <tbody>\n",
91
+ " <tr>\n",
92
+ " <th>0</th>\n",
93
+ " <td>'036000001146'</td>\n",
94
+ " <td>34</td>\n",
95
+ " <td>'2'</td>\n",
96
+ " <td>'4'</td>\n",
97
+ " <td>84200</td>\n",
98
+ " <td>2580</td>\n",
99
+ " <td>24950</td>\n",
100
+ " <td>41550</td>\n",
101
+ " <td>66500</td>\n",
102
+ " <td>17849</td>\n",
103
+ " <td>...</td>\n",
104
+ " <td>'7 120% AMI +'</td>\n",
105
+ " <td>'7 120% AMI +'</td>\n",
106
+ " <td>'7 120% AMI +'</td>\n",
107
+ " <td>'7 120% AMI +'</td>\n",
108
+ " <td>'7 120% AMI +'</td>\n",
109
+ " <td>'.'</td>\n",
110
+ " <td>'2 30% to 50%'</td>\n",
111
+ " <td>'West'</td>\n",
112
+ " <td>'-5'</td>\n",
113
+ " <td>9</td>\n",
114
+ " </tr>\n",
115
+ " <tr>\n",
116
+ " <th>1</th>\n",
117
+ " <td>'036000001147'</td>\n",
118
+ " <td>43</td>\n",
119
+ " <td>'2'</td>\n",
120
+ " <td>'4'</td>\n",
121
+ " <td>84200</td>\n",
122
+ " <td>2241</td>\n",
123
+ " <td>27700</td>\n",
124
+ " <td>46150</td>\n",
125
+ " <td>73850</td>\n",
126
+ " <td>22629</td>\n",
127
+ " <td>...</td>\n",
128
+ " <td>'7 120% AMI +'</td>\n",
129
+ " <td>'7 120% AMI +'</td>\n",
130
+ " <td>'7 120% AMI +'</td>\n",
131
+ " <td>'7 120% AMI +'</td>\n",
132
+ " <td>'7 120% AMI +'</td>\n",
133
+ " <td>'.'</td>\n",
134
+ " <td>'1 Less than 30%'</td>\n",
135
+ " <td>'West'</td>\n",
136
+ " <td>'-5'</td>\n",
137
+ " <td>9</td>\n",
138
+ " </tr>\n",
139
+ " <tr>\n",
140
+ " <th>2</th>\n",
141
+ " <td>'036000001149'</td>\n",
142
+ " <td>60</td>\n",
143
+ " <td>'2'</td>\n",
144
+ " <td>'4'</td>\n",
145
+ " <td>84200</td>\n",
146
+ " <td>2577</td>\n",
147
+ " <td>24950</td>\n",
148
+ " <td>41550</td>\n",
149
+ " <td>66500</td>\n",
150
+ " <td>17399</td>\n",
151
+ " <td>...</td>\n",
152
+ " <td>'7 120% AMI +'</td>\n",
153
+ " <td>'7 120% AMI +'</td>\n",
154
+ " <td>'7 120% AMI +'</td>\n",
155
+ " <td>'7 120% AMI +'</td>\n",
156
+ " <td>'7 120% AMI +'</td>\n",
157
+ " <td>'.'</td>\n",
158
+ " <td>'1 Less than 30%'</td>\n",
159
+ " <td>'West'</td>\n",
160
+ " <td>'-5'</td>\n",
161
+ " <td>10</td>\n",
162
+ " </tr>\n",
163
+ " <tr>\n",
164
+ " <th>3</th>\n",
165
+ " <td>'036000001150'</td>\n",
166
+ " <td>37</td>\n",
167
+ " <td>'2'</td>\n",
168
+ " <td>'4'</td>\n",
169
+ " <td>84200</td>\n",
170
+ " <td>2241</td>\n",
171
+ " <td>22200</td>\n",
172
+ " <td>36950</td>\n",
173
+ " <td>59100</td>\n",
174
+ " <td>14985</td>\n",
175
+ " <td>...</td>\n",
176
+ " <td>'7 120% AMI +'</td>\n",
177
+ " <td>'7 120% AMI +'</td>\n",
178
+ " <td>'7 120% AMI +'</td>\n",
179
+ " <td>'7 120% AMI +'</td>\n",
180
+ " <td>'7 120% AMI +'</td>\n",
181
+ " <td>'.'</td>\n",
182
+ " <td>'2 30% to 50%'</td>\n",
183
+ " <td>'West'</td>\n",
184
+ " <td>'-5'</td>\n",
185
+ " <td>10</td>\n",
186
+ " </tr>\n",
187
+ " <tr>\n",
188
+ " <th>4</th>\n",
189
+ " <td>'036000001151'</td>\n",
190
+ " <td>33</td>\n",
191
+ " <td>'2'</td>\n",
192
+ " <td>'4'</td>\n",
193
+ " <td>84200</td>\n",
194
+ " <td>2580</td>\n",
195
+ " <td>27700</td>\n",
196
+ " <td>46150</td>\n",
197
+ " <td>73850</td>\n",
198
+ " <td>22557</td>\n",
199
+ " <td>...</td>\n",
200
+ " <td>'7 120% AMI +'</td>\n",
201
+ " <td>'7 120% AMI +'</td>\n",
202
+ " <td>'7 120% AMI +'</td>\n",
203
+ " <td>'7 120% AMI +'</td>\n",
204
+ " <td>'7 120% AMI +'</td>\n",
205
+ " <td>'.'</td>\n",
206
+ " <td>'2 30% to 50%'</td>\n",
207
+ " <td>'West'</td>\n",
208
+ " <td>'-5'</td>\n",
209
+ " <td>16</td>\n",
210
+ " </tr>\n",
211
+ " </tbody>\n",
212
+ "</table>\n",
213
+ "<p>5 rows × 100 columns</p>\n",
214
+ "</div>"
215
+ ],
216
+ "text/plain": [
217
+ " CONTROL AGE1 METRO3 REGION LMED FMR L30 L50 L80 \\\n",
218
+ "0 '036000001146' 34 '2' '4' 84200 2580 24950 41550 66500 \n",
219
+ "1 '036000001147' 43 '2' '4' 84200 2241 27700 46150 73850 \n",
220
+ "2 '036000001149' 60 '2' '4' 84200 2577 24950 41550 66500 \n",
221
+ "3 '036000001150' 37 '2' '4' 84200 2241 22200 36950 59100 \n",
222
+ "4 '036000001151' 33 '2' '4' 84200 2580 27700 46150 73850 \n",
223
+ "\n",
224
+ " IPOV ... FMTCOST06RELAMICAT FMTCOST08RELAMICAT FMTCOST12RELAMICAT \\\n",
225
+ "0 17849 ... '7 120% AMI +' '7 120% AMI +' '7 120% AMI +' \n",
226
+ "1 22629 ... '7 120% AMI +' '7 120% AMI +' '7 120% AMI +' \n",
227
+ "2 17399 ... '7 120% AMI +' '7 120% AMI +' '7 120% AMI +' \n",
228
+ "3 14985 ... '7 120% AMI +' '7 120% AMI +' '7 120% AMI +' \n",
229
+ "4 22557 ... '7 120% AMI +' '7 120% AMI +' '7 120% AMI +' \n",
230
+ "\n",
231
+ " FMTCOSTMEDRELAMICAT FMTINCRELAMICAT FMTASSISTED FMTBURDEN \\\n",
232
+ "0 '7 120% AMI +' '7 120% AMI +' '.' '2 30% to 50%' \n",
233
+ "1 '7 120% AMI +' '7 120% AMI +' '.' '1 Less than 30%' \n",
234
+ "2 '7 120% AMI +' '7 120% AMI +' '.' '1 Less than 30%' \n",
235
+ "3 '7 120% AMI +' '7 120% AMI +' '.' '2 30% to 50%' \n",
236
+ "4 '7 120% AMI +' '7 120% AMI +' '.' '2 30% to 50%' \n",
237
+ "\n",
238
+ " FMTREGION FMTSTATUS HOUSE_AGE \n",
239
+ "0 'West' '-5' 9 \n",
240
+ "1 'West' '-5' 9 \n",
241
+ "2 'West' '-5' 10 \n",
242
+ "3 'West' '-5' 10 \n",
243
+ "4 'West' '-5' 16 \n",
244
+ "\n",
245
+ "[5 rows x 100 columns]"
246
+ ]
247
+ },
248
+ "execution_count": 3,
249
+ "metadata": {},
250
+ "output_type": "execute_result"
251
+ }
252
+ ],
253
+ "source": [
254
+ "df_2011, df_2013 = pd.read_csv('thads2011.txt'),pd.read_csv('thads2013n.txt')\n",
255
+ "df_2011['HOUSE_AGE'], df_2013['HOUSE_AGE'] = 2011 - df_2011['BUILT'], 2013 - df_2013['BUILT']\n",
256
+ "df = pd.concat([df_2011, df_2013], ignore_index=True)\n",
257
+ "df.head()"
258
+ ]
259
+ },
260
+ {
261
+ "cell_type": "code",
262
+ "execution_count": 4,
263
+ "metadata": {},
264
+ "outputs": [],
265
+ "source": [
266
+ "df = df[df['OWNRENT'] == \"'1'\"]\n",
267
+ "df = df[df['FMTSTRUCTURETYPE'] == \"'1 Single Family'\"]"
268
+ ]
269
+ },
270
+ {
271
+ "cell_type": "code",
272
+ "execution_count": 5,
273
+ "metadata": {},
274
+ "outputs": [
275
+ {
276
+ "data": {
277
+ "text/html": [
278
+ "<div>\n",
279
+ "<style scoped>\n",
280
+ " .dataframe tbody tr th:only-of-type {\n",
281
+ " vertical-align: middle;\n",
282
+ " }\n",
283
+ "\n",
284
+ " .dataframe tbody tr th {\n",
285
+ " vertical-align: top;\n",
286
+ " }\n",
287
+ "\n",
288
+ " .dataframe thead th {\n",
289
+ " text-align: right;\n",
290
+ " }\n",
291
+ "</style>\n",
292
+ "<table border=\"1\" class=\"dataframe\">\n",
293
+ " <thead>\n",
294
+ " <tr style=\"text-align: right;\">\n",
295
+ " <th></th>\n",
296
+ " <th>METRO3</th>\n",
297
+ " <th>REGION</th>\n",
298
+ " <th>LMED</th>\n",
299
+ " <th>BEDRMS</th>\n",
300
+ " <th>HOUSE_AGE</th>\n",
301
+ " <th>VALUE</th>\n",
302
+ " <th>ROOMS</th>\n",
303
+ " <th>PER</th>\n",
304
+ " <th>UTILITY</th>\n",
305
+ " </tr>\n",
306
+ " </thead>\n",
307
+ " <tbody>\n",
308
+ " <tr>\n",
309
+ " <th>0</th>\n",
310
+ " <td>'2'</td>\n",
311
+ " <td>'4'</td>\n",
312
+ " <td>84200</td>\n",
313
+ " <td>4</td>\n",
314
+ " <td>9</td>\n",
315
+ " <td>720000</td>\n",
316
+ " <td>8</td>\n",
317
+ " <td>3</td>\n",
318
+ " <td>300.000000</td>\n",
319
+ " </tr>\n",
320
+ " <tr>\n",
321
+ " <th>1</th>\n",
322
+ " <td>'2'</td>\n",
323
+ " <td>'4'</td>\n",
324
+ " <td>84200</td>\n",
325
+ " <td>3</td>\n",
326
+ " <td>9</td>\n",
327
+ " <td>550000</td>\n",
328
+ " <td>5</td>\n",
329
+ " <td>4</td>\n",
330
+ " <td>256.000000</td>\n",
331
+ " </tr>\n",
332
+ " <tr>\n",
333
+ " <th>2</th>\n",
334
+ " <td>'2'</td>\n",
335
+ " <td>'4'</td>\n",
336
+ " <td>84200</td>\n",
337
+ " <td>5</td>\n",
338
+ " <td>10</td>\n",
339
+ " <td>720000</td>\n",
340
+ " <td>11</td>\n",
341
+ " <td>3</td>\n",
342
+ " <td>233.000000</td>\n",
343
+ " </tr>\n",
344
+ " <tr>\n",
345
+ " <th>3</th>\n",
346
+ " <td>'2'</td>\n",
347
+ " <td>'4'</td>\n",
348
+ " <td>84200</td>\n",
349
+ " <td>3</td>\n",
350
+ " <td>10</td>\n",
351
+ " <td>450000</td>\n",
352
+ " <td>5</td>\n",
353
+ " <td>2</td>\n",
354
+ " <td>152.000000</td>\n",
355
+ " </tr>\n",
356
+ " <tr>\n",
357
+ " <th>4</th>\n",
358
+ " <td>'2'</td>\n",
359
+ " <td>'4'</td>\n",
360
+ " <td>84200</td>\n",
361
+ " <td>4</td>\n",
362
+ " <td>16</td>\n",
363
+ " <td>700000</td>\n",
364
+ " <td>9</td>\n",
365
+ " <td>4</td>\n",
366
+ " <td>656.166667</td>\n",
367
+ " </tr>\n",
368
+ " </tbody>\n",
369
+ "</table>\n",
370
+ "</div>"
371
+ ],
372
+ "text/plain": [
373
+ " METRO3 REGION LMED BEDRMS HOUSE_AGE VALUE ROOMS PER UTILITY\n",
374
+ "0 '2' '4' 84200 4 9 720000 8 3 300.000000\n",
375
+ "1 '2' '4' 84200 3 9 550000 5 4 256.000000\n",
376
+ "2 '2' '4' 84200 5 10 720000 11 3 233.000000\n",
377
+ "3 '2' '4' 84200 3 10 450000 5 2 152.000000\n",
378
+ "4 '2' '4' 84200 4 16 700000 9 4 656.166667"
379
+ ]
380
+ },
381
+ "execution_count": 5,
382
+ "metadata": {},
383
+ "output_type": "execute_result"
384
+ }
385
+ ],
386
+ "source": [
387
+ "keep_columns = [\n",
388
+ " 'METRO3',\n",
389
+ " 'REGION',\n",
390
+ " 'LMED',\n",
391
+ " 'BEDRMS',\n",
392
+ " 'HOUSE_AGE',\n",
393
+ " 'VALUE',\n",
394
+ " 'ROOMS',\n",
395
+ " 'PER',\n",
396
+ " 'UTILITY',\n",
397
+ "]\n",
398
+ "\n",
399
+ "df = df[keep_columns]\n",
400
+ "df.head()"
401
+ ]
402
+ },
403
+ {
404
+ "cell_type": "code",
405
+ "execution_count": 6,
406
+ "metadata": {},
407
+ "outputs": [
408
+ {
409
+ "data": {
410
+ "text/html": [
411
+ "<div>\n",
412
+ "<style scoped>\n",
413
+ " .dataframe tbody tr th:only-of-type {\n",
414
+ " vertical-align: middle;\n",
415
+ " }\n",
416
+ "\n",
417
+ " .dataframe tbody tr th {\n",
418
+ " vertical-align: top;\n",
419
+ " }\n",
420
+ "\n",
421
+ " .dataframe thead th {\n",
422
+ " text-align: right;\n",
423
+ " }\n",
424
+ "</style>\n",
425
+ "<table border=\"1\" class=\"dataframe\">\n",
426
+ " <thead>\n",
427
+ " <tr style=\"text-align: right;\">\n",
428
+ " <th></th>\n",
429
+ " <th>METRO3</th>\n",
430
+ " <th>REGION</th>\n",
431
+ " <th>LMED</th>\n",
432
+ " <th>BEDRMS</th>\n",
433
+ " <th>HOUSE_AGE</th>\n",
434
+ " <th>VALUE</th>\n",
435
+ " <th>ROOMS</th>\n",
436
+ " <th>PER</th>\n",
437
+ " <th>UTILITY</th>\n",
438
+ " </tr>\n",
439
+ " </thead>\n",
440
+ " <tbody>\n",
441
+ " <tr>\n",
442
+ " <th>0</th>\n",
443
+ " <td>2</td>\n",
444
+ " <td>4</td>\n",
445
+ " <td>84200</td>\n",
446
+ " <td>4</td>\n",
447
+ " <td>9</td>\n",
448
+ " <td>720000</td>\n",
449
+ " <td>8</td>\n",
450
+ " <td>3</td>\n",
451
+ " <td>300.000000</td>\n",
452
+ " </tr>\n",
453
+ " <tr>\n",
454
+ " <th>1</th>\n",
455
+ " <td>2</td>\n",
456
+ " <td>4</td>\n",
457
+ " <td>84200</td>\n",
458
+ " <td>3</td>\n",
459
+ " <td>9</td>\n",
460
+ " <td>550000</td>\n",
461
+ " <td>5</td>\n",
462
+ " <td>4</td>\n",
463
+ " <td>256.000000</td>\n",
464
+ " </tr>\n",
465
+ " <tr>\n",
466
+ " <th>2</th>\n",
467
+ " <td>2</td>\n",
468
+ " <td>4</td>\n",
469
+ " <td>84200</td>\n",
470
+ " <td>5</td>\n",
471
+ " <td>10</td>\n",
472
+ " <td>720000</td>\n",
473
+ " <td>11</td>\n",
474
+ " <td>3</td>\n",
475
+ " <td>233.000000</td>\n",
476
+ " </tr>\n",
477
+ " <tr>\n",
478
+ " <th>3</th>\n",
479
+ " <td>2</td>\n",
480
+ " <td>4</td>\n",
481
+ " <td>84200</td>\n",
482
+ " <td>3</td>\n",
483
+ " <td>10</td>\n",
484
+ " <td>450000</td>\n",
485
+ " <td>5</td>\n",
486
+ " <td>2</td>\n",
487
+ " <td>152.000000</td>\n",
488
+ " </tr>\n",
489
+ " <tr>\n",
490
+ " <th>4</th>\n",
491
+ " <td>2</td>\n",
492
+ " <td>4</td>\n",
493
+ " <td>84200</td>\n",
494
+ " <td>4</td>\n",
495
+ " <td>16</td>\n",
496
+ " <td>700000</td>\n",
497
+ " <td>9</td>\n",
498
+ " <td>4</td>\n",
499
+ " <td>656.166667</td>\n",
500
+ " </tr>\n",
501
+ " </tbody>\n",
502
+ "</table>\n",
503
+ "</div>"
504
+ ],
505
+ "text/plain": [
506
+ " METRO3 REGION LMED BEDRMS HOUSE_AGE VALUE ROOMS PER UTILITY\n",
507
+ "0 2 4 84200 4 9 720000 8 3 300.000000\n",
508
+ "1 2 4 84200 3 9 550000 5 4 256.000000\n",
509
+ "2 2 4 84200 5 10 720000 11 3 233.000000\n",
510
+ "3 2 4 84200 3 10 450000 5 2 152.000000\n",
511
+ "4 2 4 84200 4 16 700000 9 4 656.166667"
512
+ ]
513
+ },
514
+ "execution_count": 6,
515
+ "metadata": {},
516
+ "output_type": "execute_result"
517
+ }
518
+ ],
519
+ "source": [
520
+ "df['METRO3'] = df['METRO3'].str.replace(\"'\", \"\").astype(int)\n",
521
+ "df['REGION'] = df['REGION'].str.replace(\"'\", \"\").astype(int)\n",
522
+ "df.head()"
523
+ ]
524
+ },
525
+ {
526
+ "cell_type": "code",
527
+ "execution_count": 7,
528
+ "metadata": {},
529
+ "outputs": [],
530
+ "source": [
531
+ "region_code = {\n",
532
+ " 'Northeast': 1,\n",
533
+ " 'Midwest': 2,\n",
534
+ " 'South': 3,\n",
535
+ " 'West': 4,\n",
536
+ "}\n",
537
+ "\n",
538
+ "metro_code = {\n",
539
+ " 'Central cities of metropolitan areas': 1,\n",
540
+ " 'Inside metropolitan area, but not in central city': 2,\n",
541
+ " 'Inside metropolitan area, but not in central city - rural': 3,\n",
542
+ " 'Outside metropolitan areas, urbanized': 4,\n",
543
+ " 'Outside metropolitan areas, rural': 5,\n",
544
+ "}"
545
+ ]
546
+ },
547
+ {
548
+ "cell_type": "code",
549
+ "execution_count": 8,
550
+ "metadata": {},
551
+ "outputs": [],
552
+ "source": [
553
+ "df.to_csv('hud_dataset.csv', index=False)"
554
+ ]
555
+ },
556
+ {
557
+ "cell_type": "code",
558
+ "execution_count": 9,
559
+ "metadata": {},
560
+ "outputs": [],
561
+ "source": [
562
+ "X, y = df.drop(columns=['VALUE']), df['VALUE']"
563
+ ]
564
+ },
565
+ {
566
+ "cell_type": "code",
567
+ "execution_count": 10,
568
+ "metadata": {},
569
+ "outputs": [],
570
+ "source": [
571
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)"
572
+ ]
573
+ },
574
+ {
575
+ "cell_type": "code",
576
+ "execution_count": 11,
577
+ "metadata": {},
578
+ "outputs": [
579
+ {
580
+ "data": {
581
+ "text/html": [
582
+ "<div>\n",
583
+ "<style scoped>\n",
584
+ " .dataframe tbody tr th:only-of-type {\n",
585
+ " vertical-align: middle;\n",
586
+ " }\n",
587
+ "\n",
588
+ " .dataframe tbody tr th {\n",
589
+ " vertical-align: top;\n",
590
+ " }\n",
591
+ "\n",
592
+ " .dataframe thead th {\n",
593
+ " text-align: right;\n",
594
+ " }\n",
595
+ "</style>\n",
596
+ "<table border=\"1\" class=\"dataframe\">\n",
597
+ " <thead>\n",
598
+ " <tr style=\"text-align: right;\">\n",
599
+ " <th></th>\n",
600
+ " <th>METRO3</th>\n",
601
+ " <th>REGION</th>\n",
602
+ " <th>LMED</th>\n",
603
+ " <th>BEDRMS</th>\n",
604
+ " <th>HOUSE_AGE</th>\n",
605
+ " <th>ROOMS</th>\n",
606
+ " <th>PER</th>\n",
607
+ " <th>UTILITY</th>\n",
608
+ " </tr>\n",
609
+ " </thead>\n",
610
+ " <tbody>\n",
611
+ " <tr>\n",
612
+ " <th>22170</th>\n",
613
+ " <td>2</td>\n",
614
+ " <td>2</td>\n",
615
+ " <td>67109</td>\n",
616
+ " <td>4</td>\n",
617
+ " <td>21</td>\n",
618
+ " <td>9</td>\n",
619
+ " <td>3</td>\n",
620
+ " <td>126.083333</td>\n",
621
+ " </tr>\n",
622
+ " <tr>\n",
623
+ " <th>17193</th>\n",
624
+ " <td>2</td>\n",
625
+ " <td>2</td>\n",
626
+ " <td>62800</td>\n",
627
+ " <td>3</td>\n",
628
+ " <td>41</td>\n",
629
+ " <td>6</td>\n",
630
+ " <td>2</td>\n",
631
+ " <td>201.000000</td>\n",
632
+ " </tr>\n",
633
+ " <tr>\n",
634
+ " <th>137803</th>\n",
635
+ " <td>4</td>\n",
636
+ " <td>1</td>\n",
637
+ " <td>84864</td>\n",
638
+ " <td>4</td>\n",
639
+ " <td>41</td>\n",
640
+ " <td>7</td>\n",
641
+ " <td>5</td>\n",
642
+ " <td>502.500000</td>\n",
643
+ " </tr>\n",
644
+ " <tr>\n",
645
+ " <th>39271</th>\n",
646
+ " <td>2</td>\n",
647
+ " <td>1</td>\n",
648
+ " <td>64200</td>\n",
649
+ " <td>3</td>\n",
650
+ " <td>61</td>\n",
651
+ " <td>7</td>\n",
652
+ " <td>4</td>\n",
653
+ " <td>301.000000</td>\n",
654
+ " </tr>\n",
655
+ " <tr>\n",
656
+ " <th>26364</th>\n",
657
+ " <td>3</td>\n",
658
+ " <td>2</td>\n",
659
+ " <td>61864</td>\n",
660
+ " <td>3</td>\n",
661
+ " <td>91</td>\n",
662
+ " <td>6</td>\n",
663
+ " <td>3</td>\n",
664
+ " <td>461.166667</td>\n",
665
+ " </tr>\n",
666
+ " </tbody>\n",
667
+ "</table>\n",
668
+ "</div>"
669
+ ],
670
+ "text/plain": [
671
+ " METRO3 REGION LMED BEDRMS HOUSE_AGE ROOMS PER UTILITY\n",
672
+ "22170 2 2 67109 4 21 9 3 126.083333\n",
673
+ "17193 2 2 62800 3 41 6 2 201.000000\n",
674
+ "137803 4 1 84864 4 41 7 5 502.500000\n",
675
+ "39271 2 1 64200 3 61 7 4 301.000000\n",
676
+ "26364 3 2 61864 3 91 6 3 461.166667"
677
+ ]
678
+ },
679
+ "execution_count": 11,
680
+ "metadata": {},
681
+ "output_type": "execute_result"
682
+ }
683
+ ],
684
+ "source": [
685
+ "X_train.head()"
686
+ ]
687
+ },
688
+ {
689
+ "cell_type": "code",
690
+ "execution_count": 12,
691
+ "metadata": {},
692
+ "outputs": [
693
+ {
694
+ "name": "stderr",
695
+ "output_type": "stream",
696
+ "text": [
697
+ " 0% (0 of 11) | | Elapsed Time: 0:00:00 ETA: --:--:--\n"
698
+ ]
699
+ },
700
+ {
701
+ "name": "stderr",
702
+ "output_type": "stream",
703
+ "text": [
704
+ " 9% (1 of 11) |## | Elapsed Time: 0:00:35 ETA: 0:05:51\n",
705
+ " 18% (2 of 11) |#### | Elapsed Time: 0:01:09 ETA: 0:05:08\n",
706
+ " 27% (3 of 11) |###### | Elapsed Time: 0:01:44 ETA: 0:04:38\n",
707
+ " 36% (4 of 11) |######### | Elapsed Time: 0:02:22 ETA: 0:04:25\n",
708
+ " 45% (5 of 11) |########### | Elapsed Time: 0:02:55 ETA: 0:03:22\n",
709
+ " 54% (6 of 11) |############# | Elapsed Time: 0:03:28 ETA: 0:02:43\n",
710
+ " 63% (7 of 11) |############### | Elapsed Time: 0:04:01 ETA: 0:02:12\n",
711
+ " 72% (8 of 11) |################## | Elapsed Time: 0:04:36 ETA: 0:01:43\n",
712
+ " 81% (9 of 11) |#################### | Elapsed Time: 0:05:07 ETA: 0:01:02\n",
713
+ " 90% (10 of 11) |##################### | Elapsed Time: 0:05:40 ETA: 0:00:33\n",
714
+ "100% (11 of 11) |########################| Elapsed Time: 0:06:14 Time: 0:06:14\n"
715
+ ]
716
+ },
717
+ {
718
+ "name": "stdout",
719
+ "output_type": "stream",
720
+ "text": [
721
+ "Mean Squared Error: 57308274833.9465\n",
722
+ "Root Mean Squared Error: 239391.4678\n"
723
+ ]
724
+ }
725
+ ],
726
+ "source": [
727
+ "gam_model = LinearGAM(s(0, dtype='categorical') \n",
728
+ " + s(1, dtype='categorical') \n",
729
+ " + s(2, n_splines=250) \n",
730
+ " + s(3, dtype='categorical') \n",
731
+ " + s(4, n_splines=250) \n",
732
+ " + s(5, dtype='categorical') \n",
733
+ " + s(6, dtype='categorical') \n",
734
+ " + s(7, n_splines=250) \n",
735
+ " )\n",
736
+ "\n",
737
+ "gam_model.gridsearch(np.array(X_train), y_train)\n",
738
+ "gam_model.fit(np.array(X_train), y_train)\n",
739
+ "gam_test_preds = gam_model.predict(X_test)\n",
740
+ "\n",
741
+ "mse = mean_squared_error(y_test, gam_test_preds)\n",
742
+ "print(f\"Mean Squared Error: {mse:.4f}\")\n",
743
+ "\n",
744
+ "rmse = np.sqrt(mse)\n",
745
+ "print(f\"Root Mean Squared Error: {rmse:.4f}\")"
746
+ ]
747
+ },
748
+ {
749
+ "cell_type": "code",
750
+ "execution_count": 13,
751
+ "metadata": {},
752
+ "outputs": [],
753
+ "source": [
754
+ "with open('gam_model_hud.pkl', 'wb') as file:\n",
755
+ " pickle.dump(gam_model, file)"
756
+ ]
757
+ },
758
+ {
759
+ "cell_type": "code",
760
+ "execution_count": 14,
761
+ "metadata": {},
762
+ "outputs": [],
763
+ "source": [
764
+ "X_train = torch.FloatTensor(X_train.values)\n",
765
+ "y_train = torch.FloatTensor(y_train.values).reshape(-1, 1)\n",
766
+ "X_test = torch.FloatTensor(X_test.values)\n",
767
+ "y_test = torch.FloatTensor(y_test.values).reshape(-1, 1)"
768
+ ]
769
+ },
770
+ {
771
+ "cell_type": "code",
772
+ "execution_count": 15,
773
+ "metadata": {},
774
+ "outputs": [],
775
+ "source": [
776
+ "class HousePriceModel(nn.Module):\n",
777
+ " def __init__(self, input_size):\n",
778
+ " super(HousePriceModel, self).__init__()\n",
779
+ " self.model = nn.Sequential(\n",
780
+ " nn.Linear(input_size, 128),\n",
781
+ " nn.LeakyReLU(0.2,inplace=True),\n",
782
+ " nn.Linear(128, 64),\n",
783
+ " nn.LeakyReLU(0.2,inplace=True),\n",
784
+ " nn.Linear(64, 32),\n",
785
+ " nn.LeakyReLU(0.2,inplace=True),\n",
786
+ " nn.Linear(32, 1)\n",
787
+ " )\n",
788
+ "\n",
789
+ " def forward(self, x):\n",
790
+ " x = self.model(x)\n",
791
+ " return x\n",
792
+ "\n",
793
+ "model = HousePriceModel(X_train.shape[1])"
794
+ ]
795
+ },
796
+ {
797
+ "cell_type": "code",
798
+ "execution_count": 16,
799
+ "metadata": {},
800
+ "outputs": [],
801
+ "source": [
802
+ "criterion = nn.MSELoss()\n",
803
+ "optimizer = optim.Adam(model.parameters(), lr=0.0001)"
804
+ ]
805
+ },
806
+ {
807
+ "cell_type": "code",
808
+ "execution_count": 17,
809
+ "metadata": {},
810
+ "outputs": [
811
+ {
812
+ "name": "stdout",
813
+ "output_type": "stream",
814
+ "text": [
815
+ "Epoch [10/100], Loss: 461675626496.0000\n",
816
+ "Epoch [20/100], Loss: 461912539136.0000\n",
817
+ "Epoch [30/100], Loss: 465912332288.0000\n",
818
+ "Epoch [40/100], Loss: 465710579712.0000\n",
819
+ "Epoch [50/100], Loss: 465482645504.0000\n",
820
+ "Epoch [60/100], Loss: 465170137088.0000\n",
821
+ "Epoch [70/100], Loss: 464703356928.0000\n",
822
+ "Epoch [80/100], Loss: 464297361408.0000\n",
823
+ "Epoch [90/100], Loss: 463879012352.0000\n",
824
+ "Epoch [100/100], Loss: 463475539968.0000\n"
825
+ ]
826
+ }
827
+ ],
828
+ "source": [
829
+ "num_epochs = 100\n",
830
+ "batch_size = 32\n",
831
+ "\n",
832
+ "for epoch in range(num_epochs):\n",
833
+ " for i in range(0, len(X_train), batch_size):\n",
834
+ " batch_X = X_train[i:i+batch_size]\n",
835
+ " batch_y = y_train[i:i+batch_size]\n",
836
+ " \n",
837
+ " outputs = model(batch_X)\n",
838
+ " loss = criterion(outputs, batch_y)\n",
839
+ " \n",
840
+ " optimizer.zero_grad()\n",
841
+ " loss.backward()\n",
842
+ " optimizer.step()\n",
843
+ " \n",
844
+ " if (epoch + 1) % 10 == 0:\n",
845
+ " print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}')"
846
+ ]
847
+ },
848
+ {
849
+ "cell_type": "code",
850
+ "execution_count": 18,
851
+ "metadata": {},
852
+ "outputs": [
853
+ {
854
+ "name": "stdout",
855
+ "output_type": "stream",
856
+ "text": [
857
+ "Mean Squared Error: 77202161664.0000\n",
858
+ "Root Mean Squared Error: 277852.7812\n"
859
+ ]
860
+ }
861
+ ],
862
+ "source": [
863
+ "model.eval()\n",
864
+ "with torch.no_grad():\n",
865
+ " y_pred = model(X_test)\n",
866
+ " mse = criterion(y_pred, y_test)\n",
867
+ " rmse = torch.sqrt(mse)\n",
868
+ " print(f'Mean Squared Error: {mse.item():.4f}')\n",
869
+ " print(f'Root Mean Squared Error: {rmse.item():.4f}')"
870
+ ]
871
+ },
872
+ {
873
+ "cell_type": "code",
874
+ "execution_count": 19,
875
+ "metadata": {},
876
+ "outputs": [],
877
+ "source": [
878
+ "torch.save(model.state_dict(), 'dnn_model_hud.pth')"
879
+ ]
880
+ },
881
+ {
882
+ "cell_type": "code",
883
+ "execution_count": 20,
884
+ "metadata": {},
885
+ "outputs": [
886
+ {
887
+ "data": {
888
+ "text/html": [
889
+ "<div>\n",
890
+ "<style scoped>\n",
891
+ " .dataframe tbody tr th:only-of-type {\n",
892
+ " vertical-align: middle;\n",
893
+ " }\n",
894
+ "\n",
895
+ " .dataframe tbody tr th {\n",
896
+ " vertical-align: top;\n",
897
+ " }\n",
898
+ "\n",
899
+ " .dataframe thead th {\n",
900
+ " text-align: right;\n",
901
+ " }\n",
902
+ "</style>\n",
903
+ "<table border=\"1\" class=\"dataframe\">\n",
904
+ " <thead>\n",
905
+ " <tr style=\"text-align: right;\">\n",
906
+ " <th></th>\n",
907
+ " <th>MedInc</th>\n",
908
+ " <th>HouseAge</th>\n",
909
+ " <th>AveRooms</th>\n",
910
+ " <th>AveBedrms</th>\n",
911
+ " <th>Population</th>\n",
912
+ " <th>AveOccup</th>\n",
913
+ " <th>Latitude</th>\n",
914
+ " <th>Longitude</th>\n",
915
+ " </tr>\n",
916
+ " </thead>\n",
917
+ " <tbody>\n",
918
+ " <tr>\n",
919
+ " <th>0</th>\n",
920
+ " <td>8.3252</td>\n",
921
+ " <td>41.0</td>\n",
922
+ " <td>6.984127</td>\n",
923
+ " <td>1.023810</td>\n",
924
+ " <td>322.0</td>\n",
925
+ " <td>2.555556</td>\n",
926
+ " <td>37.88</td>\n",
927
+ " <td>-122.23</td>\n",
928
+ " </tr>\n",
929
+ " <tr>\n",
930
+ " <th>1</th>\n",
931
+ " <td>8.3014</td>\n",
932
+ " <td>21.0</td>\n",
933
+ " <td>6.238137</td>\n",
934
+ " <td>0.971880</td>\n",
935
+ " <td>2401.0</td>\n",
936
+ " <td>2.109842</td>\n",
937
+ " <td>37.86</td>\n",
938
+ " <td>-122.22</td>\n",
939
+ " </tr>\n",
940
+ " <tr>\n",
941
+ " <th>2</th>\n",
942
+ " <td>7.2574</td>\n",
943
+ " <td>52.0</td>\n",
944
+ " <td>8.288136</td>\n",
945
+ " <td>1.073446</td>\n",
946
+ " <td>496.0</td>\n",
947
+ " <td>2.802260</td>\n",
948
+ " <td>37.85</td>\n",
949
+ " <td>-122.24</td>\n",
950
+ " </tr>\n",
951
+ " <tr>\n",
952
+ " <th>3</th>\n",
953
+ " <td>5.6431</td>\n",
954
+ " <td>52.0</td>\n",
955
+ " <td>5.817352</td>\n",
956
+ " <td>1.073059</td>\n",
957
+ " <td>558.0</td>\n",
958
+ " <td>2.547945</td>\n",
959
+ " <td>37.85</td>\n",
960
+ " <td>-122.25</td>\n",
961
+ " </tr>\n",
962
+ " <tr>\n",
963
+ " <th>4</th>\n",
964
+ " <td>3.8462</td>\n",
965
+ " <td>52.0</td>\n",
966
+ " <td>6.281853</td>\n",
967
+ " <td>1.081081</td>\n",
968
+ " <td>565.0</td>\n",
969
+ " <td>2.181467</td>\n",
970
+ " <td>37.85</td>\n",
971
+ " <td>-122.25</td>\n",
972
+ " </tr>\n",
973
+ " </tbody>\n",
974
+ "</table>\n",
975
+ "</div>"
976
+ ],
977
+ "text/plain": [
978
+ " MedInc HouseAge AveRooms AveBedrms Population AveOccup Latitude \\\n",
979
+ "0 8.3252 41.0 6.984127 1.023810 322.0 2.555556 37.88 \n",
980
+ "1 8.3014 21.0 6.238137 0.971880 2401.0 2.109842 37.86 \n",
981
+ "2 7.2574 52.0 8.288136 1.073446 496.0 2.802260 37.85 \n",
982
+ "3 5.6431 52.0 5.817352 1.073059 558.0 2.547945 37.85 \n",
983
+ "4 3.8462 52.0 6.281853 1.081081 565.0 2.181467 37.85 \n",
984
+ "\n",
985
+ " Longitude \n",
986
+ "0 -122.23 \n",
987
+ "1 -122.22 \n",
988
+ "2 -122.24 \n",
989
+ "3 -122.25 \n",
990
+ "4 -122.25 "
991
+ ]
992
+ },
993
+ "execution_count": 20,
994
+ "metadata": {},
995
+ "output_type": "execute_result"
996
+ }
997
+ ],
998
+ "source": [
999
+ "housing = fetch_california_housing()\n",
1000
+ "\n",
1001
+ "X, y = pd.DataFrame(housing.data), pd.DataFrame(housing.target)\n",
1002
+ "X.columns = housing.feature_names\n",
1003
+ "X.head()"
1004
+ ]
1005
+ },
1006
+ {
1007
+ "cell_type": "code",
1008
+ "execution_count": 21,
1009
+ "metadata": {},
1010
+ "outputs": [],
1011
+ "source": [
1012
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)"
1013
+ ]
1014
+ },
1015
+ {
1016
+ "cell_type": "code",
1017
+ "execution_count": 22,
1018
+ "metadata": {},
1019
+ "outputs": [
1020
+ {
1021
+ "name": "stderr",
1022
+ "output_type": "stream",
1023
+ "text": [
1024
+ " 0% (0 of 11) | | Elapsed Time: 0:00:00 ETA: --:--:--\n",
1025
+ " 9% (1 of 11) |## | Elapsed Time: 0:00:36 ETA: 0:06:09\n",
1026
+ " 18% (2 of 11) |#### | Elapsed Time: 0:01:13 ETA: 0:05:24\n",
1027
+ " 27% (3 of 11) |###### | Elapsed Time: 0:01:48 ETA: 0:04:46\n",
1028
+ " 36% (4 of 11) |######### | Elapsed Time: 0:02:25 ETA: 0:04:15\n",
1029
+ " 45% (5 of 11) |########### | Elapsed Time: 0:03:00 ETA: 0:03:30\n",
1030
+ " 54% (6 of 11) |############# | Elapsed Time: 0:03:35 ETA: 0:02:55\n",
1031
+ " 63% (7 of 11) |############### | Elapsed Time: 0:04:13 ETA: 0:02:30\n",
1032
+ " 72% (8 of 11) |################## | Elapsed Time: 0:04:49 ETA: 0:01:48\n",
1033
+ " 81% (9 of 11) |#################### | Elapsed Time: 0:05:29 ETA: 0:01:20\n",
1034
+ " 90% (10 of 11) |##################### | Elapsed Time: 0:06:09 ETA: 0:00:40\n",
1035
+ "100% (11 of 11) |########################| Elapsed Time: 0:06:47 Time: 0:06:47\n"
1036
+ ]
1037
+ },
1038
+ {
1039
+ "name": "stdout",
1040
+ "output_type": "stream",
1041
+ "text": [
1042
+ "Mean Squared Error: 0.3081\n",
1043
+ "Root Mean Squared Error: 0.5550\n"
1044
+ ]
1045
+ }
1046
+ ],
1047
+ "source": [
1048
+ "gam_model = LinearGAM(s(0, n_splines=250) \n",
1049
+ " + s(1, n_splines=250) \n",
1050
+ " + s(2, n_splines=250) \n",
1051
+ " + s(3, n_splines=250) \n",
1052
+ " + s(4, n_splines=250) \n",
1053
+ " + s(5, n_splines=250) \n",
1054
+ " + s(6, n_splines=250) \n",
1055
+ " + s(7, n_splines=250) \n",
1056
+ " )\n",
1057
+ "gam_model.gridsearch(np.array(X_train), y_train)\n",
1058
+ "gam_model.fit(np.array(X_train), y_train)\n",
1059
+ "gam_test_preds = gam_model.predict(X_test)\n",
1060
+ "\n",
1061
+ "mse = mean_squared_error(y_test, gam_test_preds)\n",
1062
+ "print(f\"Mean Squared Error: {mse:.4f}\")\n",
1063
+ "\n",
1064
+ "rmse = np.sqrt(mse)\n",
1065
+ "print(f\"Root Mean Squared Error: {rmse:.4f}\")"
1066
+ ]
1067
+ },
1068
+ {
1069
+ "cell_type": "code",
1070
+ "execution_count": 23,
1071
+ "metadata": {},
1072
+ "outputs": [],
1073
+ "source": [
1074
+ "with open('gam_model_california.pkl', 'wb') as file:\n",
1075
+ " pickle.dump(gam_model, file)"
1076
+ ]
1077
+ },
1078
+ {
1079
+ "cell_type": "code",
1080
+ "execution_count": 24,
1081
+ "metadata": {},
1082
+ "outputs": [],
1083
+ "source": [
1084
+ "X_train = torch.FloatTensor(X_train.values)\n",
1085
+ "y_train = torch.FloatTensor(y_train.values).reshape(-1, 1)\n",
1086
+ "X_test = torch.FloatTensor(X_test.values)\n",
1087
+ "y_test = torch.FloatTensor(y_test.values).reshape(-1, 1)"
1088
+ ]
1089
+ },
1090
+ {
1091
+ "cell_type": "code",
1092
+ "execution_count": 25,
1093
+ "metadata": {},
1094
+ "outputs": [],
1095
+ "source": [
1096
+ "class HousePriceModel(nn.Module):\n",
1097
+ " def __init__(self, input_size):\n",
1098
+ " super(HousePriceModel, self).__init__()\n",
1099
+ " self.model = nn.Sequential(\n",
1100
+ " nn.Linear(input_size, 128),\n",
1101
+ " nn.LeakyReLU(0.2,inplace=True),\n",
1102
+ " nn.Linear(128, 64),\n",
1103
+ " nn.LeakyReLU(0.2,inplace=True),\n",
1104
+ " nn.Linear(64, 32),\n",
1105
+ " nn.LeakyReLU(0.2,inplace=True),\n",
1106
+ " nn.Linear(32, 1)\n",
1107
+ " )\n",
1108
+ "\n",
1109
+ " def forward(self, x):\n",
1110
+ " x = self.model(x)\n",
1111
+ " return x\n",
1112
+ "\n",
1113
+ "model = HousePriceModel(X_train.shape[1])"
1114
+ ]
1115
+ },
1116
+ {
1117
+ "cell_type": "code",
1118
+ "execution_count": 26,
1119
+ "metadata": {},
1120
+ "outputs": [],
1121
+ "source": [
1122
+ "criterion = nn.MSELoss()\n",
1123
+ "optimizer = optim.Adam(model.parameters(), lr=0.0001)"
1124
+ ]
1125
+ },
1126
+ {
1127
+ "cell_type": "code",
1128
+ "execution_count": 27,
1129
+ "metadata": {},
1130
+ "outputs": [
1131
+ {
1132
+ "name": "stdout",
1133
+ "output_type": "stream",
1134
+ "text": [
1135
+ "Epoch [10/100], Loss: 1.0281\n",
1136
+ "Epoch [20/100], Loss: 0.7823\n",
1137
+ "Epoch [30/100], Loss: 0.6930\n",
1138
+ "Epoch [40/100], Loss: 0.7010\n",
1139
+ "Epoch [50/100], Loss: 0.6770\n",
1140
+ "Epoch [60/100], Loss: 0.6713\n",
1141
+ "Epoch [70/100], Loss: 0.6740\n",
1142
+ "Epoch [80/100], Loss: 0.7874\n",
1143
+ "Epoch [90/100], Loss: 0.7111\n",
1144
+ "Epoch [100/100], Loss: 0.6300\n"
1145
+ ]
1146
+ }
1147
+ ],
1148
+ "source": [
1149
+ "num_epochs = 100\n",
1150
+ "batch_size = 32\n",
1151
+ "\n",
1152
+ "for epoch in range(num_epochs):\n",
1153
+ " for i in range(0, len(X_train), batch_size):\n",
1154
+ " batch_X = X_train[i:i+batch_size]\n",
1155
+ " batch_y = y_train[i:i+batch_size]\n",
1156
+ " \n",
1157
+ " outputs = model(batch_X)\n",
1158
+ " loss = criterion(outputs, batch_y)\n",
1159
+ " \n",
1160
+ " optimizer.zero_grad()\n",
1161
+ " loss.backward()\n",
1162
+ " optimizer.step()\n",
1163
+ " \n",
1164
+ " if (epoch + 1) % 10 == 0:\n",
1165
+ " print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}')"
1166
+ ]
1167
+ },
1168
+ {
1169
+ "cell_type": "code",
1170
+ "execution_count": 28,
1171
+ "metadata": {},
1172
+ "outputs": [
1173
+ {
1174
+ "name": "stdout",
1175
+ "output_type": "stream",
1176
+ "text": [
1177
+ "Mean Squared Error: 0.9678\n",
1178
+ "Root Mean Squared Error: 0.9838\n"
1179
+ ]
1180
+ }
1181
+ ],
1182
+ "source": [
1183
+ "model.eval()\n",
1184
+ "with torch.no_grad():\n",
1185
+ " y_pred = model(X_test)\n",
1186
+ " mse = criterion(y_pred, y_test)\n",
1187
+ " rmse = torch.sqrt(mse)\n",
1188
+ " print(f'Mean Squared Error: {mse.item():.4f}')\n",
1189
+ " print(f'Root Mean Squared Error: {rmse.item():.4f}')"
1190
+ ]
1191
+ },
1192
+ {
1193
+ "cell_type": "code",
1194
+ "execution_count": 29,
1195
+ "metadata": {},
1196
+ "outputs": [],
1197
+ "source": [
1198
+ "torch.save(model.state_dict(), 'dnn_model_california.pth')"
1199
+ ]
1200
+ },
1201
+ {
1202
+ "cell_type": "code",
1203
+ "execution_count": 30,
1204
+ "metadata": {},
1205
+ "outputs": [
1206
+ {
1207
+ "data": {
1208
+ "text/html": [
1209
+ "<div>\n",
1210
+ "<style scoped>\n",
1211
+ " .dataframe tbody tr th:only-of-type {\n",
1212
+ " vertical-align: middle;\n",
1213
+ " }\n",
1214
+ "\n",
1215
+ " .dataframe tbody tr th {\n",
1216
+ " vertical-align: top;\n",
1217
+ " }\n",
1218
+ "\n",
1219
+ " .dataframe thead th {\n",
1220
+ " text-align: right;\n",
1221
+ " }\n",
1222
+ "</style>\n",
1223
+ "<table border=\"1\" class=\"dataframe\">\n",
1224
+ " <thead>\n",
1225
+ " <tr style=\"text-align: right;\">\n",
1226
+ " <th></th>\n",
1227
+ " <th>Latitude</th>\n",
1228
+ " <th>Longitude</th>\n",
1229
+ " <th>County</th>\n",
1230
+ " <th>City</th>\n",
1231
+ " <th>Incorportation_date</th>\n",
1232
+ " <th>pop_april_1980</th>\n",
1233
+ " <th>pop_april_1990</th>\n",
1234
+ " <th>pop_april_2000</th>\n",
1235
+ " <th>pop_april_2010</th>\n",
1236
+ " </tr>\n",
1237
+ " </thead>\n",
1238
+ " <tbody>\n",
1239
+ " <tr>\n",
1240
+ " <th>0</th>\n",
1241
+ " <td>34.582769</td>\n",
1242
+ " <td>-117.409214</td>\n",
1243
+ " <td>San Bernardino</td>\n",
1244
+ " <td>Adelanto</td>\n",
1245
+ " <td>1970</td>\n",
1246
+ " <td>2164.0</td>\n",
1247
+ " <td>8517</td>\n",
1248
+ " <td>18130</td>\n",
1249
+ " <td>31765</td>\n",
1250
+ " </tr>\n",
1251
+ " <tr>\n",
1252
+ " <th>1</th>\n",
1253
+ " <td>34.153339</td>\n",
1254
+ " <td>-118.761675</td>\n",
1255
+ " <td>Los Angeles</td>\n",
1256
+ " <td>Agoura Hills</td>\n",
1257
+ " <td>1982</td>\n",
1258
+ " <td>20390.0</td>\n",
1259
+ " <td>20390</td>\n",
1260
+ " <td>20537</td>\n",
1261
+ " <td>20330</td>\n",
1262
+ " </tr>\n",
1263
+ " <tr>\n",
1264
+ " <th>2</th>\n",
1265
+ " <td>37.765206</td>\n",
1266
+ " <td>-122.241636</td>\n",
1267
+ " <td>Alameda</td>\n",
1268
+ " <td>Alameda</td>\n",
1269
+ " <td>1854</td>\n",
1270
+ " <td>63852.0</td>\n",
1271
+ " <td>76459</td>\n",
1272
+ " <td>72259</td>\n",
1273
+ " <td>73812</td>\n",
1274
+ " </tr>\n",
1275
+ " <tr>\n",
1276
+ " <th>3</th>\n",
1277
+ " <td>37.886869</td>\n",
1278
+ " <td>-122.297747</td>\n",
1279
+ " <td>Alameda</td>\n",
1280
+ " <td>Albany</td>\n",
1281
+ " <td>1908</td>\n",
1282
+ " <td>15130.0</td>\n",
1283
+ " <td>16327</td>\n",
1284
+ " <td>16444</td>\n",
1285
+ " <td>18539</td>\n",
1286
+ " </tr>\n",
1287
+ " <tr>\n",
1288
+ " <th>4</th>\n",
1289
+ " <td>34.095286</td>\n",
1290
+ " <td>-118.127014</td>\n",
1291
+ " <td>Los Angeles</td>\n",
1292
+ " <td>Alhambra</td>\n",
1293
+ " <td>1903</td>\n",
1294
+ " <td>64767.0</td>\n",
1295
+ " <td>82106</td>\n",
1296
+ " <td>85804</td>\n",
1297
+ " <td>83089</td>\n",
1298
+ " </tr>\n",
1299
+ " </tbody>\n",
1300
+ "</table>\n",
1301
+ "</div>"
1302
+ ],
1303
+ "text/plain": [
1304
+ " Latitude Longitude County City Incorportation_date \\\n",
1305
+ "0 34.582769 -117.409214 San Bernardino Adelanto 1970 \n",
1306
+ "1 34.153339 -118.761675 Los Angeles Agoura Hills 1982 \n",
1307
+ "2 37.765206 -122.241636 Alameda Alameda 1854 \n",
1308
+ "3 37.886869 -122.297747 Alameda Albany 1908 \n",
1309
+ "4 34.095286 -118.127014 Los Angeles Alhambra 1903 \n",
1310
+ "\n",
1311
+ " pop_april_1980 pop_april_1990 pop_april_2000 pop_april_2010 \n",
1312
+ "0 2164.0 8517 18130 31765 \n",
1313
+ "1 20390.0 20390 20537 20330 \n",
1314
+ "2 63852.0 76459 72259 73812 \n",
1315
+ "3 15130.0 16327 16444 18539 \n",
1316
+ "4 64767.0 82106 85804 83089 "
1317
+ ]
1318
+ },
1319
+ "execution_count": 30,
1320
+ "metadata": {},
1321
+ "output_type": "execute_result"
1322
+ }
1323
+ ],
1324
+ "source": [
1325
+ "df = pd.read_csv('california_cities.csv')\n",
1326
+ "df = df.iloc[:, 1:]\n",
1327
+ "df.head()"
1328
+ ]
1329
+ },
1330
+ {
1331
+ "cell_type": "code",
1332
+ "execution_count": 31,
1333
+ "metadata": {},
1334
+ "outputs": [],
1335
+ "source": [
1336
+ "df = df.groupby(['County']).agg({\n",
1337
+ " 'Latitude': 'mean',\n",
1338
+ " 'Longitude': 'mean',\n",
1339
+ " 'pop_april_1990': 'sum',\n",
1340
+ "})"
1341
+ ]
1342
+ },
1343
+ {
1344
+ "cell_type": "code",
1345
+ "execution_count": 32,
1346
+ "metadata": {},
1347
+ "outputs": [],
1348
+ "source": [
1349
+ "df = df.reset_index()"
1350
+ ]
1351
+ },
1352
+ {
1353
+ "cell_type": "code",
1354
+ "execution_count": 33,
1355
+ "metadata": {},
1356
+ "outputs": [],
1357
+ "source": [
1358
+ "df.to_csv('california_counties.csv')"
1359
+ ]
1360
+ }
1361
+ ],
1362
+ "metadata": {
1363
+ "kernelspec": {
1364
+ "display_name": "cnn_module",
1365
+ "language": "python",
1366
+ "name": "python3"
1367
+ },
1368
+ "language_info": {
1369
+ "codemirror_mode": {
1370
+ "name": "ipython",
1371
+ "version": 3
1372
+ },
1373
+ "file_extension": ".py",
1374
+ "mimetype": "text/x-python",
1375
+ "name": "python",
1376
+ "nbconvert_exporter": "python",
1377
+ "pygments_lexer": "ipython3",
1378
+ "version": "3.6.15"
1379
+ }
1380
+ },
1381
+ "nbformat": 4,
1382
+ "nbformat_minor": 2
1383
+ }
pages/about.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_option_menu import option_menu
3
+
4
+ def show():
5
+ st.markdown("# _Explainable AI for Housing Estimates_")
6
+
7
+ st.markdown("""
8
+ ## Background
9
+
10
+ _This application is designed to demonstrate an understanding of how complex problems can be explained
11
+ using Generalized Additive Models (GAMs) and LIME, and when used in conjunction of one another, can sometimes
12
+ explain even the most complex decision boundaries._
13
+ """)
14
+
15
+ st.markdown("""
16
+ ### Generalized Additive Models
17
+
18
+ > GAMs are an extension of linear regression models that allow for non-linear relationships between the
19
+ features and target. GAMs use "smooth functions of our feature variables, which can take on a great many
20
+ forms, with more detail on what that means in the following section" (Clarke). This is where GAMs differ from
21
+ generalized linear models like linear regression. A GAM is "composed of a sum of smooth functions of features
22
+ instead of or in addition to the standard linear feature contributions" (Clarke). These smooth functions or
23
+ spline functions can create non-linear decision boundaries. Spline functions show the partial dependence of
24
+ each feature on the target variable, enabling a high-level understanding of the model predictions.
25
+ """)
26
+
27
+ st.markdown("""
28
+ ### Local Interpretable Model-agnostic Explanations (LIME)
29
+ - Local - explanation should reflect the behavior of the classifier in the neighborhood of the instance being predicted
30
+ - Interpretable - human is able to make sense of it
31
+ - Model Agnostic - applied to any machine learning model
32
+ - Explanation - that helps interpret the model
33
+ """)
34
+
35
+ st.markdown("""
36
+ > LIME is a powerful tool that explains some predictions created by a neural network.
37
+ However, LIME only explains a local area within the neural network model and does not fully explain the entire decision space of a given model.
38
+ This is an important consideration when using LIME, for example, you are only mapping a subset of the entire decision space of a black box model.
39
+ """)
40
+
41
+ st.markdown("""
42
+ ### Purpose
43
+ > This project aims to provide insights into Generalized Additive Models and LIME and how they can be used to create and explain non-linear solutions
44
+ """)
45
+
46
+ st.markdown("""
47
+ ### Models
48
+ > **Neural Network**: 3 linear layers using pytorch
49
+ > **GAM**: linear gam using pygam
50
+ """)
51
+
52
+ st.markdown("""
53
+ ### Author
54
+ > Created by Keese Phillips
55
+
56
+ ### Contact
57
+ > [keese.phillips@duke.edu](mailto:keese.phillips@duke.edu)
58
+ """)
59
+
60
+ st.markdown("""
61
+ ### References
62
+ > Clark, Michael. “Generalized Additive Models.” Generalized Additive Models, m-clark.github.io/generalized-additive-models/introduction.html. Accessed 2 Dec. 2024.
63
+ """)
64
+
65
+ if __name__ == '__main__':
66
+ st.set_page_config(page_title="Generative Additive Model", page_icon="🚀")
67
+ page = option_menu(
68
+ menu_title=None,
69
+ options=["Home", "About"],
70
+ icons=["house", "book"],
71
+ menu_icon="cast",
72
+ default_index=1,
73
+ orientation="horizontal",
74
+ )
75
+ if page == "Home":
76
+ st.switch_page("pages/main.py")
77
+ elif page == "About":
78
+ show()
79
+
80
+ st.info("This app is for explaining the problem domain using Generalized Additive Models")
pages/main.py ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.optim as optim
4
+ from sklearn.datasets import fetch_california_housing
5
+ from sklearn.model_selection import train_test_split
6
+ import numpy as np
7
+ import pandas as pd
8
+ from sklearn.preprocessing import StandardScaler,OrdinalEncoder
9
+ from sklearn.model_selection import train_test_split
10
+ from sklearn.linear_model import LinearRegression, LogisticRegression
11
+ from sklearn.metrics import classification_report, recall_score, precision_score, accuracy_score
12
+ from sklearn.metrics import mean_squared_error
13
+ import matplotlib.pyplot as plt
14
+ import seaborn as sns
15
+ import zipfile
16
+ from statsmodels.genmod.generalized_linear_model import GLM
17
+ from statsmodels.genmod.families import Gamma
18
+ from statsmodels.genmod.families.links import Log
19
+ from statsmodels.tools import add_constant
20
+ from pygam import LinearGAM, GammaGAM, s, f
21
+ import pickle
22
+ import streamlit.components.v1 as components
23
+ import streamlit as st
24
+ import numpy as np
25
+ import pandas as pd
26
+ import matplotlib.pyplot as plt
27
+ from streamlit_option_menu import option_menu
28
+ from pygam import LinearGAM
29
+ import lime
30
+ from lime import lime_tabular
31
+
32
+
33
+ class HousePriceModel(nn.Module):
34
+ def __init__(self, input_size):
35
+ super(HousePriceModel, self).__init__()
36
+ self.model = nn.Sequential(
37
+ nn.Linear(input_size, 128),
38
+ nn.LeakyReLU(0.2,inplace=True),
39
+ nn.Linear(128, 64),
40
+ nn.LeakyReLU(0.2,inplace=True),
41
+ nn.Linear(64, 32),
42
+ nn.LeakyReLU(0.2,inplace=True),
43
+ nn.Linear(32, 1)
44
+ )
45
+
46
+ def forward(self, x):
47
+ x = self.model(x)
48
+ return x
49
+
50
+
51
+ def lime_component(X, input_data, dnn_model, gam_model, terms, y_min, y_max):
52
+ """
53
+ Generate and display a LIME (Local Interpretable Model-agnostic Explanations) component.
54
+
55
+ :param X: pandas.DataFrame
56
+ The feature matrix used to train the explainer.
57
+ :param input_data: list or numpy.array
58
+ The input data point to explain.
59
+ :param dnn_model: torch.nn.Module
60
+ The trained neural network model.
61
+ :param gam_model: object
62
+ The trained Generalized Additive Model
63
+ :param terms: list
64
+ List of feature names.
65
+ :param y_min: float
66
+ Minimum y-axis value
67
+ :param y_max: float
68
+ Maximum y-axis value
69
+
70
+ :return: None
71
+ """
72
+ def nn_prediction(input_data):
73
+ input_tensor = torch.FloatTensor(input_data)
74
+ dnn_model.eval()
75
+ with torch.no_grad():
76
+ output = dnn_model(input_tensor)
77
+
78
+ return output.cpu().numpy()
79
+
80
+ kernel_width = 3
81
+ explainer = lime.lime_tabular.LimeTabularExplainer(X.values,mode='regression',feature_names=terms, kernel_width=kernel_width)
82
+ exp = explainer.explain_instance(np.array(input_data), nn_prediction, num_features=len(input_data))
83
+
84
+ feature_importance = exp.as_list()
85
+ intercept = exp.intercept[0]
86
+ formula = f"> _**y =** {intercept:.4f}"
87
+ i = 0
88
+ for feature, importance in feature_importance:
89
+ if importance > 0:
90
+ formula += f" + {importance:.4f} * **{terms[i]}**"
91
+ else:
92
+ formula += f" - {abs(importance):.4f} * **{terms[i]}**"
93
+ i += 1
94
+ formula += '_'
95
+ st.markdown(formula)
96
+
97
+ lime_graph = exp.as_pyplot_figure()
98
+ st.pyplot(lime_graph)
99
+
100
+
101
+ def spline_component(X, input_data, dnn_model, gam_model, terms, y_min, y_max):
102
+ """
103
+ Generate the spline functions in a component.
104
+
105
+ :param X: pandas.DataFrame
106
+ The feature matrix used to train the explainer.
107
+ :param input_data: list or numpy.array
108
+ The input data point to explain.
109
+ :param dnn_model: torch.nn.Module
110
+ The trained neural network model.
111
+ :param gam_model: object
112
+ The trained Generalized Additive Model
113
+ :param terms: list
114
+ List of feature names.
115
+ :param y_min: float
116
+ Minimum y-axis value
117
+ :param y_max: float
118
+ Maximum y-axis value
119
+
120
+ :return: None
121
+ """
122
+ col1, col2 = st.columns(2)
123
+
124
+ for i in range(len(terms)):
125
+ XX = gam_model.generate_X_grid(term=i)
126
+ pdep, confi = gam_model.partial_dependence(term=i, X=XX, width=0.95)
127
+ fig, ax = plt.subplots(figsize=(6, 6))
128
+
129
+ # Plot partial dependence
130
+ ax.plot(XX[:, i], pdep, label='Partial Dependence')
131
+ ax.plot(XX[:, i], confi, c='r', ls='--', label='Confidence Interval')
132
+
133
+ # Find y-value corresponding to user input
134
+ user_x = input_data[i]
135
+ user_y = np.interp(user_x, XX[:, i], pdep)
136
+
137
+ # Plot vertical and horizontal lines
138
+ ax.axvline(x=user_x, color='b', linestyle='--', label='Model Input',ymin=0, ymax=(user_y-y_min)/(y_max-y_min))
139
+ ax.axhline(y=user_y, color='b', linestyle='--', xmin=0, xmax=(user_x - XX[0, i]) / (XX[-1, i] - XX[0, i]))
140
+ ax.annotate(f'{user_y:.2f}', (user_x, user_y), textcoords="offset points", xytext=(0,20), ha='center')
141
+
142
+ ax.set_title(f'{terms[i]}')
143
+ ax.set_xlabel(terms[i])
144
+ ax.set_ylabel('Partial Dependence')
145
+ ax.legend(loc='best', fontsize='x-small')
146
+
147
+ # Set consistent y-axis limits
148
+ ax.set_ylim(y_min, y_max)
149
+ plt.tight_layout(pad=1.5)
150
+
151
+ # Alternate between columns
152
+ if i % 2 == 0:
153
+ with col1:
154
+ st.write(f"Spline function: {terms[i]}:")
155
+ st.pyplot(fig)
156
+
157
+ else:
158
+ with col2:
159
+ st.write(f"Spline function: {terms[i]}:")
160
+ st.pyplot(fig)
161
+
162
+ plt.close(fig)
163
+
164
+ def prediction_component(X, input_data, dnn_model, gam_model, terms, y_min, y_max, scale=1):
165
+ """
166
+ Generates the main component for the spline functions and LIME based upon the GAM and
167
+ the neural network.
168
+
169
+ :param X: pandas.DataFrame
170
+ The feature matrix used to train the explainer.
171
+ :param input_data: list or numpy.array
172
+ The input data point to explain.
173
+ :param dnn_model: torch.nn.Module
174
+ The trained neural network model.
175
+ :param gam_model: object
176
+ The trained Generalized Additive Model
177
+ :param terms: list
178
+ List of feature names.
179
+ :param y_min: float
180
+ Minimum y-axis value
181
+ :param y_max: float
182
+ Maximum y-axis value
183
+ :param scale: int
184
+ The scale of the model's dataset's price
185
+
186
+ :return: None
187
+ """
188
+ input_array = np.array(input_data).reshape(1, -1)
189
+
190
+ dnn_prediction = dnn_model(torch.FloatTensor(input_array))[0][0]
191
+ gam_prediction = gam_model.predict(input_array)[0]
192
+
193
+ st.markdown("# Predictions")
194
+ st.write(f"- _General Additive Model Prediction:_ ${gam_prediction*scale:.2f}")
195
+ st.write(f"- _Neural Network Prediction:_ ${dnn_prediction*scale:.2f}")
196
+ st.markdown("----------------")
197
+
198
+ st.markdown("## Spline Functions")
199
+ spline_component(X, input_data, dnn_model, gam_model, terms, y_min, y_max)
200
+ st.markdown("----------------")
201
+ st.markdown("## LIME Explanation for Neural Network")
202
+
203
+ lime_component(X, input_data, dnn_model, gam_model, terms, y_min, y_max)
204
+
205
+
206
+ def show():
207
+ st.markdown("# _Explainable AI for Housing Costs_")
208
+ st.markdown("""
209
+ ## _Models_
210
+ ### California Housing Dataset:
211
+ > This dataset is more concentrated and is far less sparse as the dataset includes a smaller population from 1990 and only in California
212
+ ### HUD Housing Dataset:
213
+ > This dataset is far more sparse and is calculated over the entire country with data from all the different regions of the country
214
+ """)
215
+ st.markdown("----------------")
216
+
217
+ model_versions = ['California Housing Dataset', 'HUD Housing Dataset']
218
+ value = st.selectbox(f"Select model version", model_versions)
219
+ st.markdown("----------------")
220
+
221
+ st.write('Generate model predictions:')
222
+ if value == 'HUD Housing Dataset':
223
+ dnn_model = HousePriceModel(8)
224
+ dnn_model.load_state_dict(torch.load('models/dnn_model_hud.pth'))
225
+ dnn_model.eval()
226
+
227
+ with open('models/gam_model_hud.pkl', 'rb') as file:
228
+ gam_model = pickle.load(file)
229
+
230
+ dnn_mse = 77202161664.0000
231
+ gam_mse = 57308274833.9465
232
+
233
+ input_data = [None] * 8
234
+
235
+ terms = [
236
+ 'City/Suburban Status',
237
+ 'Census Region',
238
+ 'Area median income (average)',
239
+ '# of bedrooms in unit',
240
+ 'Age of the house (years)',
241
+ '# of rooms in unit',
242
+ '# of Persons in Household',
243
+ 'Monthly utility cost'
244
+ ]
245
+
246
+ region_code = {
247
+ 'Northeast': 1,
248
+ 'Midwest': 2,
249
+ 'South': 3,
250
+ 'West': 4,
251
+ }
252
+
253
+ metro_code = {
254
+ 'Central cities of metropolitan areas': 1,
255
+ 'Inside metropolitan area, but not in central city': 2,
256
+ 'Inside metropolitan area, but not in central city - rural': 3,
257
+ 'Outside metropolitan areas, urbanized': 4,
258
+ 'Outside metropolitan areas, rural': 5,
259
+ }
260
+
261
+ with st.sidebar:
262
+ st.title("Model Inputs")
263
+ value = st.selectbox(f"{terms[0]}", metro_code.keys())
264
+ input_data[0] =metro_code[value]
265
+ value = st.selectbox(f"{terms[0]}", region_code.keys())
266
+ input_data[1] =region_code[value]
267
+ value = st.number_input(f"{terms[2]}", value=84200)
268
+ input_data[2] =value
269
+ value = st.number_input(f"{terms[3]}", value=4)
270
+ input_data[3] =value
271
+ value = st.number_input(f"{terms[4]}", value=9)
272
+ input_data[4] =value
273
+ value = st.number_input(f"{terms[5]}", value=8)
274
+ input_data[5] =value
275
+ value = st.number_input(f"{terms[6]}", value=3)
276
+ input_data[6] =value
277
+ value = st.number_input(f"{terms[7]}", value=300)
278
+ input_data[7] =value
279
+
280
+ df = pd.read_csv('data/hud_dataset.csv', index_col=False)
281
+ X, y = df.drop(columns=['VALUE']), df['VALUE']
282
+
283
+ if st.button("Predict"):
284
+ st.markdown("# Model Loss")
285
+ st.write(f"- _Mean Squared Error (Generalized Additive Model):_ {gam_mse:.3f}")
286
+ st.write(f"- _Mean Squared Error (Neural Network Model):_ {dnn_mse:.3f}")
287
+ st.markdown("----------------")
288
+ prediction_component(X, input_data, dnn_model, gam_model, terms, y_min = -500000, y_max = 500000)
289
+
290
+ else:
291
+ dnn_model = HousePriceModel(8)
292
+ dnn_model.load_state_dict(torch.load('models/dnn_model_california.pth'))
293
+ dnn_model.eval()
294
+
295
+ with open('models/gam_model_california.pkl', 'rb') as file:
296
+ gam_model = pickle.load(file)
297
+
298
+ dnn_mse = 0.9678
299
+ gam_mse = 0.3081
300
+
301
+ input_data = [None] * 8
302
+
303
+ terms = [
304
+ 'Median Income',
305
+ 'House Age (years)',
306
+ 'Average Rooms',
307
+ 'Average Bedrooms',
308
+ 'Population (average of census block group per county)',
309
+ 'Average Occupancy',
310
+ 'Latitude',
311
+ 'Longitude'
312
+ ]
313
+
314
+ counties = pd.read_csv('data/california_counties.csv')
315
+ distinct_counties = list(counties['County'].unique())
316
+
317
+ with st.sidebar:
318
+ st.title("Model Inputs")
319
+ county = st.selectbox(f"{terms[0]}", distinct_counties)
320
+ counties = counties[counties['County'] == county]
321
+ county_vals = counties.values[0]
322
+ population = county_vals[4] / 442
323
+ lat = county_vals[2]
324
+ long = county_vals[3]
325
+ value = st.number_input(f"{terms[0]}", value=84200)
326
+ input_data[0] =value/10000
327
+ value = st.number_input(f"{terms[1]}", value=4)
328
+ input_data[1] =value
329
+ value = st.number_input(f"{terms[2]}", value=9)
330
+ input_data[2] =value
331
+ value = st.number_input(f"{terms[3]}", value=8)
332
+ input_data[3] =value
333
+ input_data[4] = population
334
+ value = st.number_input(f"{terms[5]}", value=3)
335
+ input_data[5] =value
336
+ input_data[6] = lat
337
+ input_data[7] = long
338
+
339
+ housing = fetch_california_housing()
340
+ X, y = pd.DataFrame(housing.data), pd.DataFrame(housing.target)
341
+ X.columns = housing.feature_names
342
+
343
+ if st.button("Predict"):
344
+ st.markdown("# Model Loss")
345
+ st.write(f"- _Mean Squared Error (Generalized Additive Model):_ {gam_mse:.3f}")
346
+ st.write(f"- _Mean Squared Error (Neural Network Model):_ {dnn_mse:.3f}")
347
+ st.markdown("----------------")
348
+ prediction_component(X, input_data, dnn_model, gam_model, terms, y_min = -10, y_max = 10, scale=100000)
349
+
350
+ if __name__ == '__main__':
351
+ st.set_page_config(page_title="Generalized Additive Models", page_icon="🚀")
352
+ page = option_menu(
353
+ menu_title=None,
354
+ options=["Home", "About"],
355
+ icons=["house", "book"],
356
+ menu_icon="cast",
357
+ default_index=0,
358
+ orientation="horizontal",
359
+ )
360
+ if page == "Home":
361
+ show()
362
+ elif page == "About":
363
+ st.switch_page("pages/about.py")
364
+
365
+ st.info("This app is for explaining the problem domain using Generalized Additive Models")
requirements.txt ADDED
Binary file (2.67 kB). View file