Spaces:
Running
Running
Commit
·
a041ac8
1
Parent(s):
6c65d33
kya pata kya kiyay
Browse files- data/MMR_DATA_CLEAN_LABELLED.csv +0 -0
- data/MMR_DATA_CLEAN_LABELLED_GROUND.xlsx +0 -0
- data/MMR_DATA_ST_EMBEDDINGS.csv +0 -0
- data/MMR_DATA_ST_EMBEDDINGS_ONLY.csv +0 -0
- documentation/paper_drafts/report.txt +100 -7
- notebooks/Snetence_Transformers_embedding.ipynb +0 -0
- notebooks/USE_EMB_FIX.ipynb +0 -0
- notebooks/USE_embedding.ipynb +39 -45
- notebooks/evaluation.ipynb +239 -0
- src/map_slice.html +92 -0
- src/mapslice.py +45 -0
data/MMR_DATA_CLEAN_LABELLED.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
data/MMR_DATA_CLEAN_LABELLED_GROUND.xlsx
ADDED
Binary file (215 kB). View file
|
|
data/MMR_DATA_ST_EMBEDDINGS.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
data/MMR_DATA_ST_EMBEDDINGS_ONLY.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
documentation/paper_drafts/report.txt
CHANGED
@@ -1,8 +1,13 @@
|
|
1 |
-
title - Automated
|
2 |
|
3 |
abstract
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
introduction
|
8 |
|
@@ -10,15 +15,103 @@ literature review
|
|
10 |
|
11 |
methodology
|
12 |
|
13 |
-
1.
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
6. embeddings - TFIDF, USE, Sentence Transformers (3 4 models)
|
|
|
|
|
|
|
|
|
19 |
7. clustering - knee/elbow point
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
8. 3D visual representation
|
|
|
|
|
|
|
|
|
21 |
9. auto labelling and comparison with manual coded values
|
|
|
|
|
22 |
|
23 |
results
|
24 |
|
|
|
1 |
+
title - Automated High Fidelity Functional Map Generation using Text Data Clustering
|
2 |
|
3 |
abstract
|
4 |
|
5 |
+
This study presents a novel methodology for automating the generation of high-fidelity functional maps using text-based clustering of OpenStreetMap data. Functional maps, which visualize the distribution of residential, commercial, industrial, and natural zones within regions, traditionally require extensive manual effort through field surveys, data compilation, and cartographic work. While Geographic Information Systems (GIS) have streamlined this process, significant manual verification is still needed for accuracy.
|
6 |
+
We propose an automated framework that processes OpenStreetMap text data through Natural Language Processing (NLP) techniques to classify regional land use. Our methodology divides target regions into 1km² tiles and analyzes the associated map text data (including building names, shop names, and point-of-interest descriptions) using the Universal Sentence Encoder (USE) for text embedding. These embeddings are then clustered using the K-means algorithm to identify distinct functional zones.
|
7 |
+
To validate our approach, we applied this framework to a 2,500 km² area within the Mumbai Metropolitan Region. The region was first manually labeled to establish ground truth data, against which we compared our automated classifications. Our results demonstrate that this methodology can effectively generate functional maps while significantly reducing manual effort. The framework's scalability makes it particularly valuable for mapping large urban areas, achieving promising accuracy, precision, recall, and F1 scores in distinguishing between residential, commercial, industrial, and natural zones.
|
8 |
+
|
9 |
+
Keywords: functional maps, text embedding, K-means clustering, OpenStreetMap, urban planning, automated mapping
|
10 |
+
|
11 |
|
12 |
introduction
|
13 |
|
|
|
15 |
|
16 |
methodology
|
17 |
|
18 |
+
1. OpenStreetMap Data Collection
|
19 |
+
This study utilizes OpenStreetMap (OSM) as its primary data source. OSM is a collaborative mapping platform that provides comprehensive geographic data through community contributions, functioning similarly to Wikipedia for geographic information. The platform offers detailed spatial data including:
|
20 |
+
|
21 |
+
Building information and classifications
|
22 |
+
Commercial establishments and points of interest
|
23 |
+
Road networks and transportation infrastructure
|
24 |
+
Land use designations
|
25 |
+
Natural features and boundaries
|
26 |
+
|
27 |
+
The data is freely accessible through the OSM API, which provides structured information in a standardized format. OSM's data quality is maintained through community verification processes, making it particularly reliable in densely populated urban areas where contributor activity is high.
|
28 |
+
|
29 |
+
2. Spatial Grid Generation and Region Partitioning
|
30 |
+
To systematically analyze large geographic areas, we developed a grid-based partitioning approach:
|
31 |
+
|
32 |
+
Grid Definition: The target region is overlaid with a uniform grid system, where each cell represents a 1km × 1km area. This granularity was chosen to:
|
33 |
+
|
34 |
+
Capture sufficient detail for meaningful functional analysis
|
35 |
+
Maintain computational efficiency
|
36 |
+
|
37 |
+
Data Association:
|
38 |
+
OSM features falling within each tile's boundaries are extracted
|
39 |
+
Spatial indices are created to optimize the feature-to-tile mapping process
|
40 |
+
Each tile accumulates all relevant text data from its contained features
|
41 |
+
|
42 |
+
This structured approach to data collection and spatial partitioning provides the foundation for subsequent text processing and clustering analyses. The uniform grid system ensures consistent spatial resolution across the study area while facilitating scalable processing of large geographic regions.
|
43 |
+
|
44 |
+
3. Data Preprocessing and Text Analysis
|
45 |
+
|
46 |
+
The raw data extracted from the OpenStreetMap API underwent a comprehensive filtering and preprocessing pipeline to ensure data quality and relevance. Initial filtering was performed using predefined OSM database filters to retain only pertinent geographic features, including buildings, commercial establishments, offices, transportation infrastructure, and recreational areas. This selective approach helped maintain focus on features that contribute meaningfully to functional zone classification while reducing noise in the dataset.
|
47 |
+
Following the initial feature selection, text data from each 1km² tile was aggregated to create consolidated text chunks representing the geographic characteristics of each region. The consolidation process preserved essential geographic nomenclature while maintaining the spatial relationships between features within each tile. To ensure data quality and identify potential anomalies, we conducted extensive exploratory data analysis (EDA) using statistical methods. Box plots were employed to analyze the quartile distribution of text lengths across tiles, enabling the identification of outliers and unusual patterns in the data distribution.
|
48 |
+
Regions lacking text data were subjected to additional verification processes. These void areas were systematically revalidated through cross-referencing with satellite imagery and existing land use data, leading to the identification of natural features such as mangroves and water bodies. This verification process helped distinguish between actual data gaps and legitimate natural areas, improving the overall accuracy of our classification framework.
|
49 |
+
The text preprocessing pipeline incorporated the Natural Language Toolkit (NLTK) for comprehensive text cleaning and normalization. This process included the removal of stopwords, lemmatization of terms, and standardization of text format. The lemmatization process was particularly crucial as it reduced inflected words to their base form, ensuring consistent representation of similar features across different tiles. Additionally, we analyzed the binned distribution of text lengths to establish appropriate thresholds for outlier exclusion, ensuring that the final dataset maintained a balance between comprehensive coverage and data quality.
|
50 |
+
Through this systematic approach to data filtering and preprocessing, we established a robust foundation for subsequent embedding and clustering analyses. The careful attention to data quality and feature relevance during this stage significantly contributed to the effectiveness of our functional zone classification methodology.
|
51 |
+
|
52 |
+
4. Case Study Implementation
|
53 |
+
To validate our methodological framework, we selected the Mumbai Metropolitan Region (MMR) as our primary study area. This region presents an ideal test case due to its diverse urban landscape, encompassing a rich mixture of land use patterns across a substantial geographic area of 2,500 square kilometers.
|
54 |
+
Study Area Selection and Characteristics
|
55 |
+
The MMR serves as an exemplary urban testing ground for our framework due to several key characteristics. The region features a complex tapestry of land use, including high-density commercial districts, extensive residential developments, established industrial zones, and significant natural features such as the Arabian Sea coastline, creeks, and mangrove forests. This diversity provides an optimal environment for testing our classification methodology across various functional zones.
|
56 |
+
The study area was defined as a 50km × 50km square region, centered on the metropolitan core. This delineation was carefully chosen to capture the full spectrum of urban development patterns, from the dense urban core to peripheral areas experiencing rapid transformation. The selected region also includes various stages of urban development, from historical neighborhoods to emerging commercial corridors and industrial estates.
|
57 |
+
Implementation Framework
|
58 |
+
Following our established methodology, we partitioned the study area into 1km × 1km tiles, generating a dataset of 2,500 distinct spatial units. This resolution was selected to:
|
59 |
+
|
60 |
+
Maintain sufficient granularity for meaningful functional analysis
|
61 |
+
Capture local variations in land use patterns
|
62 |
+
Enable efficient computational processing
|
63 |
+
Facilitate practical validation of results
|
64 |
+
|
65 |
+
During the exploratory data analysis phase, we identified and addressed several key considerations specific to the MMR context. Tiles containing no text data were subjected to additional verification, particularly in coastal areas and regions containing large natural features. This process helped distinguish between data gaps and legitimate natural areas, enhancing the accuracy of our classification system.
|
66 |
+
The MMR case study provided an ideal opportunity to test our framework's ability to handle complex urban environments. The region's varied development patterns, mixed land uses, and distinct natural boundaries offered appropriate challenges for validating our automated classification methodology. The results from this implementation served as the foundation for our subsequent accuracy assessments and methodology validation.
|
67 |
+
|
68 |
+
|
69 |
+
5. data description - EDA (elaboarate on the EDA part of the use case)
|
70 |
+
The exploratory data analysis phase revealed crucial insights about the textual characteristics and spatial distribution patterns across the Mumbai Metropolitan Region study area. Our analysis focused on understanding the distribution of text data across tiles and identifying patterns that could influence the classification process.
|
71 |
+
Text Length Distribution Analysis
|
72 |
+
Initial analysis of text length distribution across the 2,500 tiles revealed significant variations in data density. A box plot analysis (Figure X) demonstrated that the majority of tiles (over 75%) contained between 50 and 1100 characters of preprocessed text, with a median length of approximately 192 characters and mean having 592 characters. The distribution exhibited strong positive skewness, indicating the presence of tiles with exceptionally high text content, typically corresponding to densely developed urban areas.
|
73 |
+
The quartile analysis identified several outliers, particularly in the upper range, where some tiles contained more than 1200 characters. These outliers primarily represented central business districts and major commercial zones, characterized by high concentrations of labeled buildings and points of interest. Conversely, tiles with minimal text content (below the lower quartile of 50 characters) often corresponded to natural areas or regions with limited development.
|
74 |
+
|
75 |
+
Void Analysis and Verification
|
76 |
+
Approximately 15% of tiles contained no text data, upon further investigation, it was found that these regions mainly belonged to:
|
77 |
+
|
78 |
+
Water bodies (arabian sea and thane/vasai creek)
|
79 |
+
Protected mangrove areas
|
80 |
+
Undeveloped land parcels
|
81 |
+
|
82 |
+
Text Content Analysis
|
83 |
+
A frequency analysis of key terms and phrases across tiles provided insights into the characteristic vocabulary associated with different functional zones:
|
84 |
+
|
85 |
+
Commercial zones showed high frequencies of terms related to retail, offices, and services
|
86 |
+
Residential areas were characterized by apartment complexes, housing societies, and community facilities
|
87 |
+
Industrial zones displayed consistent patterns of manufacturing, warehouse, and logistics-related terminology
|
88 |
+
Natural areas were identified through references to parks, forests, and water bodies
|
89 |
+
|
90 |
+
Preprocessing Impact Assessment
|
91 |
+
The effect of text preprocessing steps was quantified through comparative analysis. Lemmatization reduced the unique token count by approximately 5%, while stopword removal decreased the total token count by 28%. These reductions improved the signal-to-noise ratio in the data while preserving essential semantic information for classification.
|
92 |
+
This exploratory analysis provided essential insights that informed subsequent choices in our embedding and clustering methodology, particularly in handling outliers and setting appropriate thresholds for classification.
|
93 |
+
|
94 |
+
|
95 |
6. embeddings - TFIDF, USE, Sentence Transformers (3 4 models)
|
96 |
+
Text embedding is a technique that converts words, sentences, or documents into numerical vectors (sequences of numbers) that capture their semantic meaning. These vectors allow machines to understand and compare text mathematically - similar texts will have similar vector representations. This is fundamental for many NLP applications like search, recommendation systems, and text classification.
|
97 |
+
Text embeddings transform text into numerical representations to capture semantic meaning. Traditional methods like TF-IDF (Term Frequency-Inverse Document Frequency) create sparse vectors based on word frequency, but they fail to understand context. In contrast, transformer-based embeddings generate dense, context-aware representations using deep learning. Notable models include Universal Sentence Encoder (USE) by Google, which provides efficient sentence embeddings for NLP tasks, and Sentence-Transformers (all-MiniLM-L6-v2).
|
98 |
+
For the purpose of generating text embedding, three mehtods were chosen - tfidf, USE and sentence transformer.
|
99 |
+
|
100 |
7. clustering - knee/elbow point
|
101 |
+
K-Means – A popular centroid-based method that partitions embeddings into M clusters by minimizing intra-cluster variance. Efficient for large datasets but assumes clusters are spherical.
|
102 |
+
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) – Groups embeddings based on density, identifying arbitrary-shaped clusters while marking outliers. Works well for non-uniform distributions but requires fine-tuning of hyperparameters.
|
103 |
+
HDBSCAN (Hierarchical DBSCAN) – An improvement over DBSCAN that adapts to varying density levels, making it effective for embeddings with different cluster densities.
|
104 |
+
|
105 |
+
the elbow point detection method was used to identify the optimal k value in KMeans clustring. The Elbow Method is a technique for determining the optimal number of clusters (K) in K-Means clustering by analyzing the within-cluster sum of squares (WCSS), which measures how tightly data points are grouped within each cluster. As K increases, WCSS decreases because clusters become smaller and more refined. However, beyond a certain point, adding more clusters results in minimal improvement while increasing model complexity. By plotting WCSS against different values of K, an "elbow" shape typically appears, where the curve sharply bends before flattening out. The optimal K is chosen at this elbow point, as it represents the best balance between compact clusters and computational efficiency.
|
106 |
+
|
107 |
8. 3D visual representation
|
108 |
+
t-SNE (t-Distributed Stochastic Neighbor Embedding) is a dimensionality reduction technique commonly used for visualizing high-dimensional data in a lower-dimensional space (typically 2D or 3D). It preserves the local structure of data by converting pairwise similarities into probabilities, ensuring that similar points in high-dimensional space remain close in the lower-dimensional representation.
|
109 |
+
UMAP (Uniform Manifold Approximation and Projection) is a non-linear dimensionality reduction technique designed for preserving both the local and global structure of high-dimensional data while being computationally efficient. Unlike t-SNE, which focuses primarily on local neighborhood preservation, UMAP constructs a graph-based representation of the data and optimizes a low-dimensional embedding using a probabilistic framework.
|
110 |
+
these two methods were used to visualise the embeddings and the clusters generated to evaluate the quality of the differnt embedding approaches.
|
111 |
+
|
112 |
9. auto labelling and comparison with manual coded values
|
113 |
+
the clusters generates were used to label the data points into groups. 10% samples from each cluster were manually evaluated based on their text content, to map the cluster to either comm, res, indus or nat. this method effectively genrates a classification frameowrk for unalbelled data based on clustring.
|
114 |
+
these auto generated labels were then comapred with the manually coded ground truth values, to identify the accuracy and other metrics as a classification framework.
|
115 |
|
116 |
results
|
117 |
|
notebooks/Snetence_Transformers_embedding.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/USE_EMB_FIX.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/USE_embedding.ipynb
CHANGED
@@ -2,9 +2,18 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
"source": [
|
9 |
"import numpy as numpy\n",
|
10 |
"import pandas as pd\n",
|
@@ -20,7 +29,7 @@
|
|
20 |
},
|
21 |
{
|
22 |
"cell_type": "code",
|
23 |
-
"execution_count":
|
24 |
"metadata": {},
|
25 |
"outputs": [],
|
26 |
"source": [
|
@@ -32,7 +41,7 @@
|
|
32 |
},
|
33 |
{
|
34 |
"cell_type": "code",
|
35 |
-
"execution_count":
|
36 |
"metadata": {},
|
37 |
"outputs": [
|
38 |
{
|
@@ -124,7 +133,7 @@
|
|
124 |
"14 Uran Naval Base is a Landuse: Military; "
|
125 |
]
|
126 |
},
|
127 |
-
"execution_count":
|
128 |
"metadata": {},
|
129 |
"output_type": "execute_result"
|
130 |
}
|
@@ -137,14 +146,14 @@
|
|
137 |
},
|
138 |
{
|
139 |
"cell_type": "code",
|
140 |
-
"execution_count":
|
141 |
"metadata": {},
|
142 |
"outputs": [
|
143 |
{
|
144 |
"name": "stdout",
|
145 |
"output_type": "stream",
|
146 |
"text": [
|
147 |
-
"Dataset size:
|
148 |
]
|
149 |
}
|
150 |
],
|
@@ -154,16 +163,16 @@
|
|
154 |
},
|
155 |
{
|
156 |
"cell_type": "code",
|
157 |
-
"execution_count":
|
158 |
"metadata": {},
|
159 |
"outputs": [
|
160 |
{
|
161 |
"data": {
|
162 |
"text/plain": [
|
163 |
-
"(
|
164 |
]
|
165 |
},
|
166 |
-
"execution_count":
|
167 |
"metadata": {},
|
168 |
"output_type": "execute_result"
|
169 |
}
|
@@ -175,39 +184,24 @@
|
|
175 |
},
|
176 |
{
|
177 |
"cell_type": "code",
|
178 |
-
"execution_count":
|
179 |
"metadata": {},
|
180 |
"outputs": [
|
181 |
{
|
182 |
-
"
|
183 |
-
"
|
184 |
-
"
|
185 |
-
|
186 |
-
"\
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
"
|
191 |
-
|
192 |
-
|
193 |
-
"
|
194 |
-
"\n"
|
195 |
-
|
196 |
-
},
|
197 |
-
{
|
198 |
-
"name": "stdout",
|
199 |
-
"output_type": "stream",
|
200 |
-
"text": [
|
201 |
-
"WARNING:tensorflow:From c:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\module_v2.py:126: The name tf.saved_model.load_v2 is deprecated. Please use tf.compat.v2.saved_model.load instead.\n",
|
202 |
-
"\n"
|
203 |
-
]
|
204 |
-
},
|
205 |
-
{
|
206 |
-
"name": "stderr",
|
207 |
-
"output_type": "stream",
|
208 |
-
"text": [
|
209 |
-
"WARNING:tensorflow:From c:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\module_v2.py:126: The name tf.saved_model.load_v2 is deprecated. Please use tf.compat.v2.saved_model.load instead.\n",
|
210 |
-
"\n"
|
211 |
]
|
212 |
}
|
213 |
],
|
@@ -218,7 +212,7 @@
|
|
218 |
},
|
219 |
{
|
220 |
"cell_type": "code",
|
221 |
-
"execution_count":
|
222 |
"metadata": {},
|
223 |
"outputs": [],
|
224 |
"source": [
|
@@ -233,7 +227,7 @@
|
|
233 |
},
|
234 |
{
|
235 |
"cell_type": "code",
|
236 |
-
"execution_count":
|
237 |
"metadata": {},
|
238 |
"outputs": [],
|
239 |
"source": [
|
@@ -243,7 +237,7 @@
|
|
243 |
},
|
244 |
{
|
245 |
"cell_type": "code",
|
246 |
-
"execution_count":
|
247 |
"metadata": {},
|
248 |
"outputs": [
|
249 |
{
|
@@ -263,7 +257,7 @@
|
|
263 |
},
|
264 |
{
|
265 |
"cell_type": "code",
|
266 |
-
"execution_count":
|
267 |
"metadata": {},
|
268 |
"outputs": [
|
269 |
{
|
@@ -472,7 +466,7 @@
|
|
472 |
},
|
473 |
{
|
474 |
"cell_type": "code",
|
475 |
-
"execution_count":
|
476 |
"metadata": {},
|
477 |
"outputs": [
|
478 |
{
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"WARNING:tensorflow:From c:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tf_keras\\src\\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.\n",
|
13 |
+
"\n"
|
14 |
+
]
|
15 |
+
}
|
16 |
+
],
|
17 |
"source": [
|
18 |
"import numpy as numpy\n",
|
19 |
"import pandas as pd\n",
|
|
|
29 |
},
|
30 |
{
|
31 |
"cell_type": "code",
|
32 |
+
"execution_count": 2,
|
33 |
"metadata": {},
|
34 |
"outputs": [],
|
35 |
"source": [
|
|
|
41 |
},
|
42 |
{
|
43 |
"cell_type": "code",
|
44 |
+
"execution_count": 3,
|
45 |
"metadata": {},
|
46 |
"outputs": [
|
47 |
{
|
|
|
133 |
"14 Uran Naval Base is a Landuse: Military; "
|
134 |
]
|
135 |
},
|
136 |
+
"execution_count": 3,
|
137 |
"metadata": {},
|
138 |
"output_type": "execute_result"
|
139 |
}
|
|
|
146 |
},
|
147 |
{
|
148 |
"cell_type": "code",
|
149 |
+
"execution_count": 4,
|
150 |
"metadata": {},
|
151 |
"outputs": [
|
152 |
{
|
153 |
"name": "stdout",
|
154 |
"output_type": "stream",
|
155 |
"text": [
|
156 |
+
"Dataset size: 814\n"
|
157 |
]
|
158 |
}
|
159 |
],
|
|
|
163 |
},
|
164 |
{
|
165 |
"cell_type": "code",
|
166 |
+
"execution_count": 5,
|
167 |
"metadata": {},
|
168 |
"outputs": [
|
169 |
{
|
170 |
"data": {
|
171 |
"text/plain": [
|
172 |
+
"(814,)"
|
173 |
]
|
174 |
},
|
175 |
+
"execution_count": 5,
|
176 |
"metadata": {},
|
177 |
"output_type": "execute_result"
|
178 |
}
|
|
|
184 |
},
|
185 |
{
|
186 |
"cell_type": "code",
|
187 |
+
"execution_count": 7,
|
188 |
"metadata": {},
|
189 |
"outputs": [
|
190 |
{
|
191 |
+
"ename": "KeyboardInterrupt",
|
192 |
+
"evalue": "",
|
193 |
+
"output_type": "error",
|
194 |
+
"traceback": [
|
195 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
196 |
+
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
197 |
+
"Cell \u001b[1;32mIn[7], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m module_url \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://tfhub.dev/google/universal-sentence-encoder/4\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m----> 2\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mhub\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmodule_url\u001b[49m\u001b[43m)\u001b[49m\n",
|
198 |
+
"File \u001b[1;32mc:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\module_v2.py:100\u001b[0m, in \u001b[0;36mload\u001b[1;34m(handle, tags, options)\u001b[0m\n\u001b[0;32m 98\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(handle, \u001b[38;5;28mstr\u001b[39m):\n\u001b[0;32m 99\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mExpected a string, got \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m%\u001b[39m handle)\n\u001b[1;32m--> 100\u001b[0m module_path \u001b[38;5;241m=\u001b[39m \u001b[43mresolve\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 101\u001b[0m is_hub_module_v1 \u001b[38;5;241m=\u001b[39m tf\u001b[38;5;241m.\u001b[39mio\u001b[38;5;241m.\u001b[39mgfile\u001b[38;5;241m.\u001b[39mexists(_get_module_proto_path(module_path))\n\u001b[0;32m 102\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m tags \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m is_hub_module_v1:\n",
|
199 |
+
"File \u001b[1;32mc:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\module_v2.py:55\u001b[0m, in \u001b[0;36mresolve\u001b[1;34m(handle)\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mresolve\u001b[39m(handle):\n\u001b[0;32m 32\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Resolves a module handle into a path.\u001b[39;00m\n\u001b[0;32m 33\u001b[0m \n\u001b[0;32m 34\u001b[0m \u001b[38;5;124;03m This function works both for plain TF2 SavedModels and the legacy TF1 Hub\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 53\u001b[0m \u001b[38;5;124;03m A string representing the Module path.\u001b[39;00m\n\u001b[0;32m 54\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m---> 55\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mregistry\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mresolver\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m)\u001b[49m\n",
|
200 |
+
"File \u001b[1;32mc:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\registry.py:49\u001b[0m, in \u001b[0;36mMultiImplRegister.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 47\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m impl \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mreversed\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_impls):\n\u001b[0;32m 48\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m impl\u001b[38;5;241m.\u001b[39mis_supported(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m---> 49\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mimpl\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 50\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 51\u001b[0m fails\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;28mtype\u001b[39m(impl)\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m)\n",
|
201 |
+
"File \u001b[1;32mc:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\compressed_module_resolver.py:81\u001b[0m, in \u001b[0;36mHttpCompressedFileResolver.__call__\u001b[1;34m(self, handle)\u001b[0m\n\u001b[0;32m 77\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_call_urlopen(request)\n\u001b[0;32m 78\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m resolver\u001b[38;5;241m.\u001b[39mDownloadManager(handle)\u001b[38;5;241m.\u001b[39mdownload_and_uncompress(\n\u001b[0;32m 79\u001b[0m response, tmp_dir)\n\u001b[1;32m---> 81\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mresolver\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43matomic_download\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdownload\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodule_dir\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 82\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_lock_file_timeout_sec\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
|
202 |
+
"File \u001b[1;32mc:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\resolver.py:411\u001b[0m, in \u001b[0;36matomic_download\u001b[1;34m(handle, download_fn, module_dir, lock_file_timeout_sec)\u001b[0m\n\u001b[0;32m 408\u001b[0m \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[0;32m 410\u001b[0m \u001b[38;5;66;03m# Wait for lock file to disappear.\u001b[39;00m\n\u001b[1;32m--> 411\u001b[0m \u001b[43m_wait_for_lock_to_disappear\u001b[49m\u001b[43m(\u001b[49m\u001b[43mhandle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlock_file\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlock_file_timeout_sec\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 412\u001b[0m \u001b[38;5;66;03m# At this point we either deleted a lock or a lock got removed by the\u001b[39;00m\n\u001b[0;32m 413\u001b[0m \u001b[38;5;66;03m# owner or another process. Perform one more iteration of the while-loop,\u001b[39;00m\n\u001b[0;32m 414\u001b[0m \u001b[38;5;66;03m# we would either terminate due tf.compat.v1.gfile.Exists(module_dir) or\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 417\u001b[0m \n\u001b[0;32m 418\u001b[0m \u001b[38;5;66;03m# Lock file acquired.\u001b[39;00m\n\u001b[0;32m 419\u001b[0m logging\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDownloading TF-Hub Module \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m, handle)\n",
|
203 |
+
"File \u001b[1;32mc:\\Users\\Akhil PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\tensorflow_hub\\resolver.py:336\u001b[0m, in \u001b[0;36m_wait_for_lock_to_disappear\u001b[1;34m(handle, lock_file, lock_file_timeout_sec)\u001b[0m\n\u001b[0;32m 334\u001b[0m \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[0;32m 335\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m--> 336\u001b[0m \u001b[43mtime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msleep\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m5\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
204 |
+
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
]
|
206 |
}
|
207 |
],
|
|
|
212 |
},
|
213 |
{
|
214 |
"cell_type": "code",
|
215 |
+
"execution_count": null,
|
216 |
"metadata": {},
|
217 |
"outputs": [],
|
218 |
"source": [
|
|
|
227 |
},
|
228 |
{
|
229 |
"cell_type": "code",
|
230 |
+
"execution_count": null,
|
231 |
"metadata": {},
|
232 |
"outputs": [],
|
233 |
"source": [
|
|
|
237 |
},
|
238 |
{
|
239 |
"cell_type": "code",
|
240 |
+
"execution_count": null,
|
241 |
"metadata": {},
|
242 |
"outputs": [
|
243 |
{
|
|
|
257 |
},
|
258 |
{
|
259 |
"cell_type": "code",
|
260 |
+
"execution_count": null,
|
261 |
"metadata": {},
|
262 |
"outputs": [
|
263 |
{
|
|
|
466 |
},
|
467 |
{
|
468 |
"cell_type": "code",
|
469 |
+
"execution_count": null,
|
470 |
"metadata": {},
|
471 |
"outputs": [
|
472 |
{
|
notebooks/evaluation.ipynb
ADDED
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"import numpy as np\n",
|
11 |
+
"import matplotlib.pyplot as plt\n",
|
12 |
+
"\n",
|
13 |
+
"from sklearn.metrics import classification_report, accuracy_score, confusion_matrix, precision_score, recall_score, f1_score"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"cell_type": "code",
|
18 |
+
"execution_count": 11,
|
19 |
+
"metadata": {},
|
20 |
+
"outputs": [
|
21 |
+
{
|
22 |
+
"data": {
|
23 |
+
"text/html": [
|
24 |
+
"<div>\n",
|
25 |
+
"<style scoped>\n",
|
26 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
27 |
+
" vertical-align: middle;\n",
|
28 |
+
" }\n",
|
29 |
+
"\n",
|
30 |
+
" .dataframe tbody tr th {\n",
|
31 |
+
" vertical-align: top;\n",
|
32 |
+
" }\n",
|
33 |
+
"\n",
|
34 |
+
" .dataframe thead th {\n",
|
35 |
+
" text-align: right;\n",
|
36 |
+
" }\n",
|
37 |
+
"</style>\n",
|
38 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
39 |
+
" <thead>\n",
|
40 |
+
" <tr style=\"text-align: right;\">\n",
|
41 |
+
" <th></th>\n",
|
42 |
+
" <th>row</th>\n",
|
43 |
+
" <th>col</th>\n",
|
44 |
+
" <th>latitude</th>\n",
|
45 |
+
" <th>longitude</th>\n",
|
46 |
+
" <th>Map Data</th>\n",
|
47 |
+
" <th>label</th>\n",
|
48 |
+
" <th>label_ground</th>\n",
|
49 |
+
" </tr>\n",
|
50 |
+
" </thead>\n",
|
51 |
+
" <tbody>\n",
|
52 |
+
" <tr>\n",
|
53 |
+
" <th>0</th>\n",
|
54 |
+
" <td>0</td>\n",
|
55 |
+
" <td>1</td>\n",
|
56 |
+
" <td>18.89433</td>\n",
|
57 |
+
" <td>72.794102</td>\n",
|
58 |
+
" <td>Prongs Reef is a Natural;</td>\n",
|
59 |
+
" <td>2</td>\n",
|
60 |
+
" <td>2</td>\n",
|
61 |
+
" </tr>\n",
|
62 |
+
" <tr>\n",
|
63 |
+
" <th>1</th>\n",
|
64 |
+
" <td>0</td>\n",
|
65 |
+
" <td>2</td>\n",
|
66 |
+
" <td>18.89433</td>\n",
|
67 |
+
" <td>72.803607</td>\n",
|
68 |
+
" <td>United Services Club Golf Course is a Leisure ...</td>\n",
|
69 |
+
" <td>2</td>\n",
|
70 |
+
" <td>2</td>\n",
|
71 |
+
" </tr>\n",
|
72 |
+
" <tr>\n",
|
73 |
+
" <th>2</th>\n",
|
74 |
+
" <td>0</td>\n",
|
75 |
+
" <td>3</td>\n",
|
76 |
+
" <td>18.89433</td>\n",
|
77 |
+
" <td>72.813112</td>\n",
|
78 |
+
" <td>Indian Meterological Department is a Commercia...</td>\n",
|
79 |
+
" <td>4</td>\n",
|
80 |
+
" <td>4</td>\n",
|
81 |
+
" </tr>\n",
|
82 |
+
" <tr>\n",
|
83 |
+
" <th>3</th>\n",
|
84 |
+
" <td>0</td>\n",
|
85 |
+
" <td>13</td>\n",
|
86 |
+
" <td>18.89433</td>\n",
|
87 |
+
" <td>72.908163</td>\n",
|
88 |
+
" <td>Uran Naval Base is a Landuse: Military;</td>\n",
|
89 |
+
" <td>3</td>\n",
|
90 |
+
" <td>3</td>\n",
|
91 |
+
" </tr>\n",
|
92 |
+
" <tr>\n",
|
93 |
+
" <th>4</th>\n",
|
94 |
+
" <td>0</td>\n",
|
95 |
+
" <td>14</td>\n",
|
96 |
+
" <td>18.89433</td>\n",
|
97 |
+
" <td>72.917668</td>\n",
|
98 |
+
" <td>Uran Naval Base is a Landuse: Military;</td>\n",
|
99 |
+
" <td>3</td>\n",
|
100 |
+
" <td>3</td>\n",
|
101 |
+
" </tr>\n",
|
102 |
+
" </tbody>\n",
|
103 |
+
"</table>\n",
|
104 |
+
"</div>"
|
105 |
+
],
|
106 |
+
"text/plain": [
|
107 |
+
" row col latitude longitude \\\n",
|
108 |
+
"0 0 1 18.89433 72.794102 \n",
|
109 |
+
"1 0 2 18.89433 72.803607 \n",
|
110 |
+
"2 0 3 18.89433 72.813112 \n",
|
111 |
+
"3 0 13 18.89433 72.908163 \n",
|
112 |
+
"4 0 14 18.89433 72.917668 \n",
|
113 |
+
"\n",
|
114 |
+
" Map Data label label_ground \n",
|
115 |
+
"0 Prongs Reef is a Natural; 2 2 \n",
|
116 |
+
"1 United Services Club Golf Course is a Leisure ... 2 2 \n",
|
117 |
+
"2 Indian Meterological Department is a Commercia... 4 4 \n",
|
118 |
+
"3 Uran Naval Base is a Landuse: Military; 3 3 \n",
|
119 |
+
"4 Uran Naval Base is a Landuse: Military; 3 3 "
|
120 |
+
]
|
121 |
+
},
|
122 |
+
"execution_count": 11,
|
123 |
+
"metadata": {},
|
124 |
+
"output_type": "execute_result"
|
125 |
+
}
|
126 |
+
],
|
127 |
+
"source": [
|
128 |
+
"df = pd.read_excel(r'C:\\Users\\Akhil PC\\Documents\\projects\\research\\Marauders-Map\\data\\MMR_DATA_CLEAN_LABELLED_GROUND.xlsx')\n",
|
129 |
+
"df.head()"
|
130 |
+
]
|
131 |
+
},
|
132 |
+
{
|
133 |
+
"cell_type": "code",
|
134 |
+
"execution_count": 12,
|
135 |
+
"metadata": {},
|
136 |
+
"outputs": [],
|
137 |
+
"source": [
|
138 |
+
"y_pred = df['label']\n",
|
139 |
+
"y_true = df['label_ground']\n",
|
140 |
+
"\n",
|
141 |
+
"if y_pred.shape != y_true.shape:\n",
|
142 |
+
" print(\"Error: The shape of the prediction and true labels do not match.\")\n",
|
143 |
+
" exit(1)"
|
144 |
+
]
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"cell_type": "code",
|
148 |
+
"execution_count": 13,
|
149 |
+
"metadata": {},
|
150 |
+
"outputs": [
|
151 |
+
{
|
152 |
+
"name": "stdout",
|
153 |
+
"output_type": "stream",
|
154 |
+
"text": [
|
155 |
+
"Accuracy: 0.9705159705159705\n",
|
156 |
+
"Precision: 0.9706854194661688\n",
|
157 |
+
"Recall: 0.9705159705159705\n",
|
158 |
+
"F1 Score: 0.9704914288808899\n"
|
159 |
+
]
|
160 |
+
}
|
161 |
+
],
|
162 |
+
"source": [
|
163 |
+
"## accuracy, precision, recall, f1 score\n",
|
164 |
+
"\n",
|
165 |
+
"accuracy = accuracy_score(y_true, y_pred)\n",
|
166 |
+
"precision = precision_score(y_true, y_pred, average='weighted')\n",
|
167 |
+
"recall = recall_score(y_true, y_pred, average='weighted')\n",
|
168 |
+
"f1 = f1_score(y_true, y_pred, average='weighted')\n",
|
169 |
+
"\n",
|
170 |
+
"print(\"Accuracy: \", accuracy)\n",
|
171 |
+
"print(\"Precision: \", precision)\n",
|
172 |
+
"print(\"Recall: \", recall)\n",
|
173 |
+
"print(\"F1 Score: \", f1)"
|
174 |
+
]
|
175 |
+
},
|
176 |
+
{
|
177 |
+
"cell_type": "code",
|
178 |
+
"execution_count": 17,
|
179 |
+
"metadata": {},
|
180 |
+
"outputs": [
|
181 |
+
{
|
182 |
+
"data": {
|
183 |
+
"text/plain": [
|
184 |
+
"<matplotlib.image.AxesImage at 0x1c9fb0476b0>"
|
185 |
+
]
|
186 |
+
},
|
187 |
+
"execution_count": 17,
|
188 |
+
"metadata": {},
|
189 |
+
"output_type": "execute_result"
|
190 |
+
},
|
191 |
+
{
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Q0AqYQGgFRCA0AqoQEgldAAkEpoAEglNACkEhoAUgkNAKmEBoBUQgNAKqEBYPKEZteuXbFkyZJob28vt1WrVsW7776bNx0AzRWarq6ueP7552NgYCCOHDkS9913X2zYsCFOnjyZNyEAU9qMq3nw+vXrL7n93HPPlaucw4cPx+233369ZwOg2ULzl8bGxuLNN9+MkZGR8hDarxkdHS23iyqVyu99SgCa4WKA48ePx6xZs6KtrS2eeOKJ2L9/fyxevPhXH9/f3x8dHR0TW3d397XODEAjh2bRokVx7Nix+Pzzz+PJJ5+M3t7e+Oqrr3718X19fTE0NDSxDQ4OXuvMADTyobPW1tZYuHBh+edly5bFl19+GTt27Ijdu3f/4uOLlU+xAdCcrvl1NOPj45ecgwGA372iKQ6DrVu3Lnp6emJ4eDj27t0bBw8ejPfff/9q/hoAmshVhebs2bPxyCOPxPfff1+e2C9evFlE5sEHH8ybEIDmCc2rr76aNwkADcl7nQGQSmgASCU0AKQSGgBSCQ0AqYQGgFRCA0AqoQEgldAAkEpoAEglNACkEhoAUgkNAKmEBoBUQgNAKqEBIJXQAJBKaABIJTQApBIaAFIJDQCphAaAVEIDQCqhASCV0ACQSmgASCU0AKQSGgBSCQ0AqYQGgFRCA0AqoQEgldAAkEpoAEglNACkEhoAUgkNAKmEBoBUM6LGqtVq+XF4uFLrp25qM6b7mYLGVx07X+8RmnJ/V//3+/qkCc3w8HD58e//7tZaPzUASd/XOzo6fvW/t1Qvl6LrbHx8PE6fPh2zZ8+OlpaWmCoqlUp0d3fH4OBgtLe313ucpmCf1559XnuVKbzPi3wUkens7Ixp06ZNnhVNMUxXV1dMVcUXwlT7Ypjq7PPas89rr32K7vPfWslc5MA9AKmEBoBUQnOF2traYtu2beVHasM+rz37vPbammCf1/xiAACaixUNAKmEBoBUQgNAKqEBIJXQAJBKaABIJTQApBIaACLT/wDbpWJbXYS9aAAAAABJRU5ErkJggg==",
|
194 |
+
"text/plain": [
|
195 |
+
"<Figure size 480x480 with 1 Axes>"
|
196 |
+
]
|
197 |
+
},
|
198 |
+
"metadata": {},
|
199 |
+
"output_type": "display_data"
|
200 |
+
}
|
201 |
+
],
|
202 |
+
"source": [
|
203 |
+
"## confusion matrix\n",
|
204 |
+
"\n",
|
205 |
+
"conf_matrix = confusion_matrix(y_true, y_pred)\n",
|
206 |
+
"\n",
|
207 |
+
"plt.matshow(conf_matrix, cmap='Blues')"
|
208 |
+
]
|
209 |
+
},
|
210 |
+
{
|
211 |
+
"cell_type": "code",
|
212 |
+
"execution_count": null,
|
213 |
+
"metadata": {},
|
214 |
+
"outputs": [],
|
215 |
+
"source": []
|
216 |
+
}
|
217 |
+
],
|
218 |
+
"metadata": {
|
219 |
+
"kernelspec": {
|
220 |
+
"display_name": "Python 3",
|
221 |
+
"language": "python",
|
222 |
+
"name": "python3"
|
223 |
+
},
|
224 |
+
"language_info": {
|
225 |
+
"codemirror_mode": {
|
226 |
+
"name": "ipython",
|
227 |
+
"version": 3
|
228 |
+
},
|
229 |
+
"file_extension": ".py",
|
230 |
+
"mimetype": "text/x-python",
|
231 |
+
"name": "python",
|
232 |
+
"nbconvert_exporter": "python",
|
233 |
+
"pygments_lexer": "ipython3",
|
234 |
+
"version": "3.12.0"
|
235 |
+
}
|
236 |
+
},
|
237 |
+
"nbformat": 4,
|
238 |
+
"nbformat_minor": 2
|
239 |
+
}
|
src/map_slice.html
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
|
5 |
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
6 |
+
|
7 |
+
<script>
|
8 |
+
L_NO_TOUCH = false;
|
9 |
+
L_DISABLE_3D = false;
|
10 |
+
</script>
|
11 |
+
|
12 |
+
<style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>
|
13 |
+
<style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>
|
14 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>
|
15 |
+
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
16 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
17 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>
|
18 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>
|
19 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"/>
|
20 |
+
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css"/>
|
21 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css"/>
|
22 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>
|
23 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>
|
24 |
+
|
25 |
+
<meta name="viewport" content="width=device-width,
|
26 |
+
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
27 |
+
<style>
|
28 |
+
#map_3fb1c91a19eaea7a0cc92fdc6aa05510 {
|
29 |
+
position: relative;
|
30 |
+
width: 100.0%;
|
31 |
+
height: 100.0%;
|
32 |
+
left: 0.0%;
|
33 |
+
top: 0.0%;
|
34 |
+
}
|
35 |
+
.leaflet-container { font-size: 1rem; }
|
36 |
+
</style>
|
37 |
+
|
38 |
+
</head>
|
39 |
+
<body>
|
40 |
+
|
41 |
+
|
42 |
+
<div class="folium-map" id="map_3fb1c91a19eaea7a0cc92fdc6aa05510" ></div>
|
43 |
+
|
44 |
+
</body>
|
45 |
+
<script>
|
46 |
+
|
47 |
+
|
48 |
+
var map_3fb1c91a19eaea7a0cc92fdc6aa05510 = L.map(
|
49 |
+
"map_3fb1c91a19eaea7a0cc92fdc6aa05510",
|
50 |
+
{
|
51 |
+
center: [19.04721441397017, 72.94618401786974],
|
52 |
+
crs: L.CRS.EPSG3857,
|
53 |
+
...{
|
54 |
+
"zoom": 12,
|
55 |
+
"zoomControl": true,
|
56 |
+
"preferCanvas": false,
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
);
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
var tile_layer_ca6a7e1da1b1e99f61c2e94424fed6cf = L.tileLayer(
|
67 |
+
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
68 |
+
{
|
69 |
+
"minZoom": 0,
|
70 |
+
"maxZoom": 19,
|
71 |
+
"maxNativeZoom": 19,
|
72 |
+
"noWrap": false,
|
73 |
+
"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors",
|
74 |
+
"subdomains": "abc",
|
75 |
+
"detectRetina": false,
|
76 |
+
"tms": false,
|
77 |
+
"opacity": 1,
|
78 |
+
}
|
79 |
+
|
80 |
+
);
|
81 |
+
|
82 |
+
|
83 |
+
tile_layer_ca6a7e1da1b1e99f61c2e94424fed6cf.addTo(map_3fb1c91a19eaea7a0cc92fdc6aa05510);
|
84 |
+
|
85 |
+
|
86 |
+
var rectangle_3f015643e8201922d4eaf484aa326e44 = L.rectangle(
|
87 |
+
[[18.889833, 72.779844], [19.20459582794034, 73.11252403573947]],
|
88 |
+
{"bubblingMouseEvents": true, "color": "blue", "dashArray": null, "dashOffset": null, "fill": true, "fillColor": "blue", "fillOpacity": 0.2, "fillRule": "evenodd", "lineCap": "round", "lineJoin": "round", "noClip": false, "opacity": 1.0, "smoothFactor": 1.0, "stroke": true, "weight": 3}
|
89 |
+
).addTo(map_3fb1c91a19eaea7a0cc92fdc6aa05510);
|
90 |
+
|
91 |
+
</script>
|
92 |
+
</html>
|
src/mapslice.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import folium
|
2 |
+
from math import radians, cos, sin, sqrt, atan2
|
3 |
+
|
4 |
+
def haversine(lat, lon, distance_km):
|
5 |
+
# Earth's radius in km
|
6 |
+
R = 6371.0
|
7 |
+
|
8 |
+
# Approximate bounding box (assuming small area, ignoring curvature)
|
9 |
+
d_lat = distance_km / R
|
10 |
+
d_lon = distance_km / (R * cos(radians(lat)))
|
11 |
+
|
12 |
+
# Top-right coordinates
|
13 |
+
new_lat = lat + (d_lat * (180 / 3.14159))
|
14 |
+
new_lon = lon + (d_lon * (180 / 3.14159))
|
15 |
+
|
16 |
+
return new_lat, new_lon
|
17 |
+
|
18 |
+
def generate_map(bottom_left_lat, bottom_left_lon, distance_km):
|
19 |
+
top_right_lat, top_right_lon = haversine(bottom_left_lat, bottom_left_lon, distance_km)
|
20 |
+
|
21 |
+
# Center of map (approx midpoint)
|
22 |
+
center_lat = (bottom_left_lat + top_right_lat) / 2
|
23 |
+
center_lon = (bottom_left_lon + top_right_lon) / 2
|
24 |
+
|
25 |
+
# Create a folium map
|
26 |
+
map_slice = folium.Map(location=[center_lat, center_lon], zoom_start=12)
|
27 |
+
|
28 |
+
# Draw a bounding box
|
29 |
+
folium.Rectangle(
|
30 |
+
bounds=[(bottom_left_lat, bottom_left_lon), (top_right_lat, top_right_lon)],
|
31 |
+
color="blue",
|
32 |
+
fill=True,
|
33 |
+
fill_opacity=0.2
|
34 |
+
).add_to(map_slice)
|
35 |
+
|
36 |
+
# Save map to file
|
37 |
+
map_slice.save("map_slice.html")
|
38 |
+
print("Map saved as 'map_slice.html'. Open it in a browser.")
|
39 |
+
|
40 |
+
if __name__ == "__main__":
|
41 |
+
lat = float(input("Enter bottom-left latitude: "))
|
42 |
+
lon = float(input("Enter bottom-left longitude: "))
|
43 |
+
distance_km = float(input("Enter distance (km): "))
|
44 |
+
|
45 |
+
generate_map(lat, lon, distance_km)
|