<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhinavkgupta</title>
    <description>The latest articles on DEV Community by Abhinavkgupta (@akg1301).</description>
    <link>https://dev.to/akg1301</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F604352%2F1aa4ad96-e7e4-4092-9046-c2f3c716898c.png</url>
      <title>DEV Community: Abhinavkgupta</title>
      <link>https://dev.to/akg1301</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akg1301"/>
    <language>en</language>
    <item>
      <title>XharkTank - Buildout</title>
      <dc:creator>Abhinavkgupta</dc:creator>
      <pubDate>Fri, 15 Apr 2022 08:51:23 +0000</pubDate>
      <link>https://dev.to/akg1301/xharktank-buildout-17aj</link>
      <guid>https://dev.to/akg1301/xharktank-buildout-17aj</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello Developers, I recently participated in Crio-Launch 2022 Challenge-Stage 1 organized by &lt;a href="https://www.crio.do/"&gt;Crio.do&lt;/a&gt;. I am going to share my learning experience&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What are Tech Internship?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Externships in technology are experiential learning opportunities that are comparable to internships but are shorter and part-time, and are delivered in collaboration with technology firms. Externships with Crio Launch are a terrific way to address real-world problems in a real-world tech startup context and gain crucial skills that will help you progress your dev career.&lt;/p&gt;

&lt;p&gt;So, the first day began with an orientation in which they described the structure of the programme and how anyone could easily and pleasantly get started with it. The curriculum is separated into two phases, and at each step, some students are chosen and advance to the next stage of the programme.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 1&lt;/strong&gt;: Everyone who had been selected for the programme could participate in this stage, which lasted two weeks. HTTP, REST API, Linux, and Git were among the topics to be addressed during the course of two weeks. In addition, certain cloud principles and AWS were to be taught.and as a bonus, we were to be introduced to Backend Development where we would built a backend for Xharktank-Buildout. The students who successfully complete the Stage 1 were graduated and considered to participate in the Stage 2 of the program.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Sharktank is a panel of possible investors known as "Sharks" who listen to entrepreneurs propose ideas for new businesses or products. These self-made multi-millionaires evaluate the business plans and items presented before deciding whether to invest their own money to advertise and advise each contestant.&lt;/p&gt;

&lt;h1&gt;
  
  
  Xharktank
&lt;/h1&gt;

&lt;p&gt;Create a XharkTank backend where aspiring entrepreneurs can pitch ideas for a business or product they want to develop by providing their name, title, and business idea, the investment amount they expect to be fulfilled, and the percentage of equity they are willing to give away to potential investors. Investors must be able to access a list of all pitches and provide feedback/comment with a counter offer based on their interests.&lt;/p&gt;

&lt;p&gt;I will be in charge of implementing the GET/POST APIs needed for the backend to function properly. The figure below represents the high-level architecture of the Full Stack Application.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--diUuIMhN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwztcb1u48bvj94862z0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--diUuIMhN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gwztcb1u48bvj94862z0.jpg" alt="Image description" width="816" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Features
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Pitch your Idea &lt;/li&gt;
&lt;li&gt;Invest in Pitches &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Node.js&lt;/strong&gt; is a JavaScript runtime built on Chrome's V8 JavaScript engine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Express&lt;/strong&gt; is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MongoDB&lt;/strong&gt; is an open-source document database and leading NoSQL database.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Technology Used  🛠️&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;a) Node js&lt;br&gt;&lt;br&gt;
b) Express js&lt;br&gt;&lt;br&gt;
c) Mongodb&lt;br&gt;&lt;br&gt;
d) Mongoose&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;It was a highly enlightening and rewarding learning experience throughout the entire project production process. I was able to create a project view. Throughout the process, I learned about several new methodologies for XharkTank. Also, as a result of this project, I ended up creating my blog, which I never expected to do.&lt;/p&gt;

&lt;p&gt;I'm delighted to report that I've finally finished the deployment phase and am merging my backend with the given frontend. Please provide feedback.&lt;br&gt;
Tech Stack Used: Node js, Express Js, Mongodb, Mongoose&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pitch your Idea here: &lt;a href="https://xharktank.crio.do/pitches/?author=abhinavkgupta2001&amp;amp;url=https://xharktank-abhinav.herokuapp.com/"&gt;https://xharktank.crio.do/pitches/?author=abhinavkgupta2001&amp;amp;url=https://xharktank-abhinav.herokuapp.com/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QlGXxqE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj71o3gipbob63m2wwfc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QlGXxqE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj71o3gipbob63m2wwfc.jpg" alt="Image description" width="880" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Invest in Pitches here: &lt;a href="https://xharktank.crio.do/invest/?author=abhinavkgupta2001&amp;amp;url=https%3A%2F%2Fxharktank-abhinav.herokuapp.com"&gt;https://xharktank.crio.do/invest/?author=abhinavkgupta2001&amp;amp;url=https%3A%2F%2Fxharktank-abhinav.herokuapp.com&lt;/a&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ip5oLWTm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/200o0quuu7nr8n1w61c9.jpg" alt="Image description" width="880" height="407"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Thankyou&lt;/em&gt;&lt;/p&gt;

</description>
      <category>criolaunch</category>
      <category>externship</category>
      <category>developer</category>
      <category>crio</category>
    </item>
    <item>
      <title>Exploratory Data Analysis On Geolocational Data</title>
      <dc:creator>Abhinavkgupta</dc:creator>
      <pubDate>Sat, 27 Mar 2021 17:11:19 +0000</pubDate>
      <link>https://dev.to/akg1301/exploratory-data-analysis-on-geolocational-data-270j</link>
      <guid>https://dev.to/akg1301/exploratory-data-analysis-on-geolocational-data-270j</guid>
      <description>&lt;p&gt;Exploratory data Analysis is used by Data Scientist to analyse and summarize their main characteristics, often data visualisation method.&lt;/p&gt;

&lt;p&gt;As a part of Crio #ibelieveindoing program, I tried some Data analysis on the Geolocational Data using Python.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Indroduction&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;This project involves the use of K-Means Clustering to find the best accommodation for students in Bangalore (or any other city of your choice) by classifying accommodation for incoming students on the basis of their preferences on amenities, budget and proximity to the location.&lt;/p&gt;

&lt;p&gt;Implementing the project will take you through the daily life of a data science engineer - from data preparation on real-life datasets, to visualising the data and running machine learning algorithms, to presenting the results.&lt;/p&gt;

&lt;p&gt;Food delivery apps aside, managers of restaurant chains and hotels can also leverage this information. For example, if a manager of a restaurant already knows the demographic of his current customers, they’d ideally want to open at a location where this demographic is at its highest concentration, ensuring short commute times to the location and more customers served.If potential hotel locations are being evaluated, a site that caters to a wide variety of tastes would be ideal, since one would want every guest to have something to their liking.&lt;/p&gt;

&lt;p&gt;This project is a good start for beginners and a refresher for professionals who have dabbled in python / ML before. The methodology can be applied to any location of one's choosing, so feel free to innovate!&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Clustering&lt;/strong&gt; is the task of grouping the elements such that observations of same group are more similar to each other than those in other group.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Affinity Propagation&lt;/strong&gt; is a graph-based algorithm that assigns each observation to its nearest exemplar. Basically, all the observations “vote” for which other observations they want to be associated with, which results in a partitioning of the whole dataset into a large number of uneven clusters. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Geolocational Analysis&lt;/strong&gt; is the analysis that processes Satellite images, GPS coordinates and Street addresses and apply  to geographic models.&lt;/p&gt;

&lt;p&gt;so let's start, I need to import the following packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
import pandas as pd
## for plotting
import matplotlib.pyplot as plt
import seaborn as sns
## for geospatial
import folium
import geopy
## for machine learning
from sklearn import preprocessing, cluster
import scipy
## for deep learning
import minisom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fetch the data we need and set up your environment before you move on to data analysis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pandas.io.json import json_normalize
import folium
from geopy.geocoders import Nominatim 
import requests
CLIENT_ID = "CLient ID" # your Foursquare ID
CLIENT_SECRET = "Client Secret key" # your Foursquare Secret
VERSION = '20200316'
LIMIT = 10000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set up your query in such a way that you can check for residential locations in a fixed radius around a point of your choosing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;url = 'https://api.foursquare.com/v2/venues/explore?&amp;amp;client_id={}&amp;amp;client_secret={}&amp;amp;v={}&amp;amp;ll={},{}&amp;amp;radius={}&amp;amp;limit={}'.format(
    CLIENT_ID, 
    CLIENT_SECRET, 
    VERSION, 
    17.448372, 78.526957,
    30000, 
    LIMIT)

results = requests.get(url).json()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;parse the response data into a usable dataframe.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;venues = results['response']['groups'][0]['items']
nearby_venues = json_normalize(venues)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need a count of grocery stores, restaurants, gyms etc. around each residential location. Form another query to get all these locations (fixed in a short distance around each residential location) and hit the endpoint again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resta=[]
oth=[]
for lat,long in zip(nearby_venues['venue.location.lat'],nearby_venues['venue.location.lng']):
    url = 'https://api.foursquare.com/v2/venues/explore?&amp;amp;client_id={}&amp;amp;client_secret={}&amp;amp;v={}&amp;amp;ll={},{}&amp;amp;radius={}&amp;amp;limit={}'.format(
      CLIENT_ID, 
      CLIENT_SECRET, 
      VERSION, 
      lat,long,
      1000, 
      100)
    res = requests.get(url).json()
    venue = res['response']['groups'][0]['items']
    nearby_venue = json_normalize(venue)
    df=nearby_venue['venue.categories']

    g=[]
    for i in range(0,df.size):
      g.append(df[i][0]['icon']['prefix'].find('food'))
    co=0
    for i in g:
      if i&amp;gt;1:
        co+=1
    resta.append(co)
    oth.append(len(g)-co)

nearby_venues['restaurant']=resta
nearby_venues['others']=oth
nearby_venues
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Drop the irrelevant values, handle the NaN values(if any) and summarise the results into a dataframe. &lt;/p&gt;

&lt;p&gt;In order to define the right k, I shall use the Elbow Method: plotting the variance as a function of the number of clusters and picking the k that flats the curve.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;f=['venue.location.lat','venue.location.lng']
X = nearby_venues[f]
max_k = 10
## iterations
distortions = [] 
for i in range(1, max_k+1):
    if len(X) &amp;gt;= i:
       model = cluster.KMeans(n_clusters=i, init='k-means++', max_iter=300, n_init=10, random_state=0)
       model.fit(X)
       distortions.append(model.inertia_)
## best k: the lowest derivative
k = [i*100 for i in np.diff(distortions,2)].index(min([i*100 for i 
     in np.diff(distortions,2)]))
## plot
fig, ax = plt.subplots()
ax.plot(range(1, len(distortions)+1), distortions)
ax.axvline(k, ls='--', color="red", label="k = "+str(k))
ax.set(title='The Elbow Method', xlabel='Number of clusters', 
       ylabel="Distortion")
ax.legend()
ax.grid(True)
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I am going to create the map with folium, a really convenient package that allows us to plot interactive maps without needing to load a shapefile. Each store shall be identified by a point with size proportional to its current staff and color based on its cost. I’m also going to add a small piece of HTML code to the default map to display the legend.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x, y = "lat", "long"
color = "restaurant"
size = "others"
popup = "venue.location.formattedAddress"
data = n.copy()

## create color column
lst_colors=["red","green","orange"]
lst_elements = sorted(list(n[color].unique()))

## create size column (scaled)
scaler = preprocessing.MinMaxScaler(feature_range=(3,15))
data["size"] = scaler.fit_transform(
               data[size].values.reshape(-1,1)).reshape(-1)

## initialize the map with the starting location
map_ = folium.Map(location=location, tiles="cartodbpositron",
                  zoom_start=11)
## add points
data.apply(lambda row: folium.CircleMarker(
           location=[row[x],row[y]],popup=row[popup],
           radius=row["size"]).add_to(map_), axis=1)
## add html legend


## plot the map
map_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can try with k = 6 so that the K-Means algorithm will find 6 theoretical centroids. In addition, I will identify the real centroids too (the closest observation to the cluster center).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k = 6
model = cluster.KMeans(n_clusters=k, init='k-means++')
X = n[["lat","long"]]
## clustering
dtf_X = X.copy()
dtf_X["cluster"] = model.fit_predict(X)
## find real centroids
closest, distances = scipy.cluster.vq.vq(model.cluster_centers_, 
                     dtf_X.drop("cluster", axis=1).values)
dtf_X["centroids"] = 0
for i in closest:
    dtf_X["centroids"].iloc[i] = 1
## add clustering info to the original dataset
n[["cluster","centroids"]] = dtf_X[["cluster","centroids"]]
n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added two columns to the dataset: “cluster” indicating what cluster the observation belongs to, and “centroids” that is 1 if an observation is also the centroid (the closest to the center) and 0 otherwise. Let’s plot it out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## plot
fig, ax = plt.subplots()
sns.scatterplot(x="lat", y="long", data=n, 
                palette=sns.color_palette("bright",k),
                hue='cluster', size="centroids", size_order=[1,0],
                legend="brief", ax=ax).set_title('Clustering (k='+str(k)+')')
th_centroids = model.cluster_centers_
ax.scatter(th_centroids[:,0], th_centroids[:,1], s=50, c='black', 
           marker="x")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Affinity Propagation&lt;/strong&gt; is quite convenient when you can’t specify the number of clusters, and it’s suited for geospatial data as it works well with non-flat geometry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model = cluster.AffinityPropagation()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Independently from the algorithm you used to cluster the data, now you have a dataset with two more columns (“cluster”, “centroids”). We can use that to visualize the clusters on the map, and this time I’m going to display the centroids as well using a marker.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;x, y = "lat", "long"
color = "cluster"
size = "restaurant"
popup = "venue.location.formattedAddress"
marker = "centroids"
data = n.copy()
## create color column
lst_elements = sorted(list(n[color].unique()))
lst_colors = ['#%06X' % np.random.randint(0, 0xFFFFFF) for i in 
              range(len(lst_elements))]
data["color"] = data[color].apply(lambda x: 
                lst_colors[lst_elements.index(x)])
## create size column (scaled)
scaler = preprocessing.MinMaxScaler(feature_range=(3,15))
data["size"] = scaler.fit_transform(
               data[size].values.reshape(-1,1)).reshape(-1)
## initialize the map with the starting location
map_ = folium.Map(location=location, tiles="cartodbpositron",
                  zoom_start=11)
## add points
data.apply(lambda row: folium.CircleMarker(
           location=[row[x],row[y]], 
           color=row["color"], fill=True,popup=row[popup],
           radius=row["size"]).add_to(map_), axis=1)
## add html legend
legend_html = """&amp;lt;div style="position:fixed; bottom:10px; left:10px; border:2px solid black; z-index:9999; font-size:14px;"&amp;gt;&amp;amp;nbsp;&amp;lt;b&amp;gt;"""+color+""":&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;"""
for i in lst_elements:
     legend_html = legend_html+"""&amp;amp;nbsp;&amp;lt;i class="fa fa-circle 
     fa-1x" style="color:"""+lst_colors[lst_elements.index(i)]+""""&amp;gt;
     &amp;lt;/i&amp;gt;&amp;amp;nbsp;"""+str(i)+"""&amp;lt;br&amp;gt;"""
legend_html = legend_html+"""&amp;lt;/div&amp;gt;"""
map_.get_root().html.add_child(folium.Element(legend_html))
## add centroids marker
lst_elements = sorted(list(n[marker].unique()))
data[data[marker]==1].apply(lambda row: 
           folium.Marker(location=[row[x],row[y]], 
           draggable=False,  popup=row[popup] ,       
           icon=folium.Icon(color="black")).add_to(map_), axis=1)
## plot the map
map_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;It was very insightful and great learning journey through entire project creation. I was able to built a view of the project. In the entire process I learnt about many new methods that used in Exploratory Data Analysis. Also through this project I landed up writing my first blog which I had never thought.&lt;br&gt;
I am sharing my code repo and web-app link below:&lt;br&gt;
Github: &lt;br&gt;
Link:&lt;a href="https://github.com/AKG1301/Exploratory-Data-Analysis-on-Geolocational-Data"&gt;https://github.com/AKG1301/Exploratory-Data-Analysis-on-Geolocational-Data&lt;/a&gt;&lt;br&gt;
Welcome for any suggestion and review.&lt;/p&gt;

&lt;p&gt;A huge thanks to @Crio Team, @Som, &lt;a class="mentioned-user" href="https://dev.to/ajay"&gt;@ajay&lt;/a&gt;
 for bring up such projects ideas for beginners and designed it is so simple that a even a non-coder like me could understand and begin from basics.&lt;/p&gt;

</description>
      <category>python</category>
      <category>crio</category>
      <category>ibelieveindoing</category>
    </item>
  </channel>
</rss>
