HathawayLiu
commited on
Delete housing_dataset.py
Browse files- housing_dataset.py +0 -163
housing_dataset.py
DELETED
@@ -1,163 +0,0 @@
|
|
1 |
-
#
|
2 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3 |
-
# you may not use this file except in compliance with the License.
|
4 |
-
# You may obtain a copy of the License at
|
5 |
-
#
|
6 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7 |
-
#
|
8 |
-
# Unless required by applicable law or agreed to in writing, software
|
9 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11 |
-
# See the License for the specific language governing permissions and
|
12 |
-
# limitations under the License.
|
13 |
-
# T0: Address all TODOs and remove all explanatory comments
|
14 |
-
""" TO: Add a description here.
|
15 |
-
"""
|
16 |
-
|
17 |
-
|
18 |
-
import csv
|
19 |
-
import json
|
20 |
-
import os
|
21 |
-
from typing import List
|
22 |
-
import datasets
|
23 |
-
import logging
|
24 |
-
import pandas as pd
|
25 |
-
import torch
|
26 |
-
|
27 |
-
# TODO: Add BibTeX citation
|
28 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
29 |
-
_CITATION = """
|
30 |
-
@InProceedings{huggingface:dataset,
|
31 |
-
title = {A great new dataset},
|
32 |
-
author={huggingface, Inc.
|
33 |
-
},
|
34 |
-
year={2020}
|
35 |
-
}
|
36 |
-
"""
|
37 |
-
|
38 |
-
# TODO: Add description of the dataset here
|
39 |
-
# You can copy an official description
|
40 |
-
_DESCRIPTION = """
|
41 |
-
This typical dataset contains all the building permits issued or in progress
|
42 |
-
within the city of Seattle starting from 1990 to recent, and this dataset is
|
43 |
-
still updating as time flows. Information includes permit records urls,
|
44 |
-
detailed address, and building costs etc.
|
45 |
-
"""
|
46 |
-
|
47 |
-
# TODO: Add a link to an official homepage for the dataset here
|
48 |
-
_HOMEPAGE = "https://data.seattle.gov/Permitting/Building-Permits/76t5-zqzr/about_data"
|
49 |
-
|
50 |
-
# TODO: Add the licence for the dataset here if you can find it
|
51 |
-
_LICENSE = " http://www.seattle.gov/sdci"
|
52 |
-
|
53 |
-
# TODO: Add link to the official dataset URLs here
|
54 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
55 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
56 |
-
_URL = "https://data.seattle.gov/Permitting/Building-Permits/76t5-zqzr/about_data"
|
57 |
-
_URLS = {
|
58 |
-
"data": _URL
|
59 |
-
}
|
60 |
-
|
61 |
-
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
62 |
-
class HousingDataset(datasets.GeneratorBasedBuilder):
|
63 |
-
"""This dataset contains all building permits issued or in progress within
|
64 |
-
the city of Seattle. It includes the original columns in the datasets, with
|
65 |
-
new added columns for corresponding neighborhood district and parking lot
|
66 |
-
near by each housing."""
|
67 |
-
|
68 |
-
_URLS = _URLS
|
69 |
-
VERSION = datasets.Version("1.1.0")
|
70 |
-
|
71 |
-
def _info(self):
|
72 |
-
return datasets.DatasetInfo(
|
73 |
-
description=_DESCRIPTION,
|
74 |
-
features=datasets.Features(
|
75 |
-
{
|
76 |
-
# columns from original dataset
|
77 |
-
"permitnum": datasets.Value("string"),
|
78 |
-
"permitclass": datasets.Value("string"),
|
79 |
-
"permitclassmapped": datasets.Value("string"),
|
80 |
-
"permittypemapped": datasets.Value("string"),
|
81 |
-
"permittypedesc": datasets.Value("string"),
|
82 |
-
"description": datasets.Value("string"),
|
83 |
-
"housingunits": datasets.Value("int64"),
|
84 |
-
"housingunitsremoved": datasets.Value("int64"),
|
85 |
-
"housingunitsadded": datasets.Value("int64"),
|
86 |
-
"estprojectcost": datasets.Value("float32"),
|
87 |
-
"applieddate": datasets.Value("string"),
|
88 |
-
"issueddate": datasets.Value("string"),
|
89 |
-
"expiresdate": datasets.Value("string"),
|
90 |
-
"completeddate": datasets.Value("string"),
|
91 |
-
"statuscurrent": datasets.Value("string"),
|
92 |
-
"relatedmup": datasets.Value("string"),
|
93 |
-
"originaladdress1": datasets.Value("string"),
|
94 |
-
"originalcity": datasets.Value("string"),
|
95 |
-
"originalstate": datasets.Value("string"),
|
96 |
-
"originalzip": datasets.Value("int64"),
|
97 |
-
"contractorcompanyname": datasets.Value("string"),
|
98 |
-
"link": datasets.Value("string"),
|
99 |
-
"latitude": datasets.Value("float32"),
|
100 |
-
"longitude": datasets.Value("float32"),
|
101 |
-
"location1": datasets.Value("string"),
|
102 |
-
# new added columns below
|
103 |
-
"neighbordistrict": datasets.Value("string")
|
104 |
-
}
|
105 |
-
),
|
106 |
-
# No default supervised_keys (as we have to pass both question
|
107 |
-
# and context as input).
|
108 |
-
supervised_keys=None,
|
109 |
-
homepage=_HOMEPAGE,
|
110 |
-
citation=_CITATION,
|
111 |
-
)
|
112 |
-
|
113 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
114 |
-
urls = {
|
115 |
-
"housing_data" : "https://github.com/HathawayLiu/Housing_dataset/raw/main/Building_Permits_Cleaned.csv"
|
116 |
-
}
|
117 |
-
downloaded_files = dl_manager.download_and_extract(urls)
|
118 |
-
|
119 |
-
return [
|
120 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs=downloaded_files)
|
121 |
-
]
|
122 |
-
|
123 |
-
def _generate_examples(self, housing_data):
|
124 |
-
"""This function returns the examples in the raw (text) form."""
|
125 |
-
housing_df = pd.read_csv(housing_data)
|
126 |
-
|
127 |
-
housing_df['EstProjectCost'] = housing_df["EstProjectCost"].replace('NA', 0)
|
128 |
-
housing_df.dropna(subset = ['Latitude'], inplace = True)
|
129 |
-
housing_df.dropna(subset = ['OriginalZip'], inplace = True)
|
130 |
-
|
131 |
-
housing_df['Latitude'] = housing_df['Latitude'].astype(float)
|
132 |
-
housing_df['Longitude'] = housing_df['Longitude'].astype(float)
|
133 |
-
|
134 |
-
# Iterating through each row to generate examples
|
135 |
-
for index, row in housing_df.iterrows():
|
136 |
-
yield index, {
|
137 |
-
"permitnum": row.get("PermitNum", ""),
|
138 |
-
"permitclass": row.get("PermitClass", ""),
|
139 |
-
"permitclassmapped": row.get("PermitClassMapped", ""),
|
140 |
-
"permittypemapped": row.get("PermitTypeMapped", ""),
|
141 |
-
"permittypedesc": row.get("PermitTypeDesc", ""),
|
142 |
-
"description": row.get("Description", ""),
|
143 |
-
"housingunits": int(row.get("HousingUnits", "")),
|
144 |
-
"housingunitsremoved": int(row.get("HousingUnitsRemoved", "")),
|
145 |
-
"housingunitsadded": int(row.get("HousingUnitsAdded", "")),
|
146 |
-
"estprojectcost": float(row.get("EstProjectCost", "")),
|
147 |
-
"applieddate": str(row.get("AppliedDate", "")),
|
148 |
-
"issueddate": str(row.get("IssuedDate", "")),
|
149 |
-
"expiresdate": str(row.get("ExpiresDate", "")),
|
150 |
-
"completeddate": str(row.get("CompletedDate", "")),
|
151 |
-
"statuscurrent": row.get("StatusCurrent", ""),
|
152 |
-
"relatedmup": row.get("RelatedMup", ""),
|
153 |
-
"originaladdress1": row.get("OriginalAddress1", ""),
|
154 |
-
"originalcity": row.get("OriginalCity", ""),
|
155 |
-
"originalstate": row.get("OriginalState", ""),
|
156 |
-
"originalzip": int(row.get("OriginalZip", "")),
|
157 |
-
"contractorcompanyname": row.get("ContractorCompanyName", ""),
|
158 |
-
"link": row.get("Link", ""),
|
159 |
-
"latitude": row["Latitude"],
|
160 |
-
"longitude": row["Longitude"],
|
161 |
-
"location1": str(row["Latitude"]) + ", " + str(row["Longitude"]),
|
162 |
-
"neighbordistrict": row.get("NeighborDistrict", "")
|
163 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|