Skip to content

Instantly share code, notes, and snippets.

Avatar

ABHISHEK SHARMA abhishek-shrm

  • New Delhi, India
View GitHub Profile
View rfc_vs_dt-1.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import f1_score
from sklearn.model_selection import train_test_split
# Importing dataset
df=pd.read_csv('dataset.csv')
df.head()
View folium-tutorial-9.py
# Creating feature groups
f1=folium.FeatureGroup("Vehicle 1")
f2=folium.FeatureGroup("Vehicle 2")
f3=folium.FeatureGroup("Vehicle 3")
# Adding lines to the different feature groups
line_1=folium.vector_layers.PolyLine(coords_1,popup='<b>Path of Vehicle_1</b>',tooltip='Vehicle_1',color='blue',weight=10).add_to(f1)
line_2=folium.vector_layers.PolyLine(coords_2,popup='<b>Path of Vehicle_2</b>',tooltip='Vehicle_2',color='red',weight=10).add_to(f2)
line_3=folium.vector_layers.PolyLine(coords_3,popup='<b>Path of Vehicle_3</b>',tooltip='Vehicle_3',color='green',weight=10).add_to(f3)
View IR-W2V-21.py
# Combining corpus and queries for training
combined_training=pd.concat([training_corpus.rename(columns={'lemmatized':'text'})['text'],\
training_queries.rename(columns={'cleaned':'text'})['text']])\
.sample(frac=1).reset_index(drop=True)
View folium-tutorial-4.py
fig2=Figure(width=550,height=350)
m2=folium.Map(location=[28.644800, 77.216721])
fig2.add_child(m2)
folium.TileLayer('Stamen Terrain').add_to(m2)
folium.TileLayer('Stamen Toner').add_to(m2)
folium.TileLayer('Stamen Water Color').add_to(m2)
folium.TileLayer('cartodbpositron').add_to(m2)
folium.TileLayer('cartodbdark_matter').add_to(m2)
folium.LayerControl().add_to(m2)
m2
View keyword-extraction-textrank-20.py
# Evaluating on test set
test_precision,test_recall,test_Fmeasure=evaluate_micro_average(df_test['keys'].values,df_test['pred_keys'])
print('Precision=>',test_precision)
print('Recall=>',test_recall)
print('F-measure=>',test_Fmeasure)
View folium-tutorial-42.py
from folium.plugins import HeatMapWithTime
fig7=Figure(width=850,height=550)
m7=folium.Map(location=[40.712776, -74.005974],zoom_start=10)
fig7.add_child(m7)
View eta_on_text_data-16.py
# Creating Document Term Matrix
from sklearn.feature_extraction.text
import CountVectorizer
cv=CountVectorizer(analyzer='word')
data=cv.fit_transform(df_grouped['lemmatized'])
df_dtm = pd.DataFrame(data.toarray(), columns=cv.get_feature_names())
df_dtm.index=df_grouped.index
df_dtm.head(3)
View keplergl-01.py
import pandas as pd
df=pd.read_csv('kepler.gl-data/nyctrips/data.csv')
print('Shape=>',df.shape)
df.head()
View keyword-extraction-textrank-19.py
# Evaluating on validation set
val_precision,val_recall,val_Fmeasure=evaluate_micro_average(df_val['keys'].values,df_val['pred_keys'])
print('Precision=>',val_precision)
print('Recall=>',val_recall)
print('F-measure=>',val_Fmeasure)
View keyword-extraction-textrank-18.py
def evaluate_micro_average(actual_keys,predicted_keys):
# Combining actual keywords
ground_truth=[]
for i in actual_keys:
ground_truth.extend(i)
# Combining extracted keywords
extracted_keywords=[]
for i in predicted_keys:
extracted_keywords.extend(i)