Skip to content

Instantly share code, notes, and snippets.

View alinazhanguwo's full-sized avatar

Alina Zhang alinazhanguwo

View GitHub Profile
# Encourage lander to use as little fuel as possible
# i.e. 0.85, or 0.32
fuel_conservation = fuel_remaining / total_fuel
if distance_to_goal is decreasing:
if speed < threshold:
if position is on landing pad:
# Land successfully; give a big reward
landing_reward = 100
# Multiply percentage of remaining fuel
import plotly.graph_objects as go
fig = go.Figure(data=go.Scattergeo(
lat = df['latitude'],
lon = df['longitude'],
text = df['_id'],
marker = dict(
size = 8,
opacity = 0.7,
reversescale = True,
def get_matches_df(sparse_matrix, name_vector, top=100):
non_zeros = sparse_matrix.nonzero()
sparserows = non_zeros[0]
sparsecols = non_zeros[1]
if top:
nr_matches = top
else:
nr_matches = sparsecols.size
from scipy.sparse import csr_matrix
!pip install sparse_dot_topn
import sparse_dot_topn.sparse_dot_topn as ct
def awesome_cossim_top(A, B, ntop, lower_bound=0):
# force A and B as a CSR matrix.
# If they have already been CSR, there is no overhead
A = A.tocsr()
B = B.tocsr()
M, _ = A.shape
STOPWORDS = stopwords.words('english')
STOPWORDS = set(STOPWORDS)
def text_prepare(text, STOPWORDS):
"""
text: a string
return: a clean string
"""
REPLACE_BY_SPACE_RE = re.compile('[\n\"\'/(){}\[\]\|@,;#]')
###
This season reminds me of the day I met you! You are my best colleague. Thank you!
###
We have surely come a long way! Happy Christmas my friend.
###
Christmas Wishes for Colleagues
###
You have worked very hard this year. You really deserve to have a wonderful Christmas. Merry Christmas my colleague.
###
It has always been a pleasure working with you! I wish you a Merry Christmas!
###
It feels great working with someone as knowledgeable as you and yet so humble. I wish you a Merry Christmas!
@alinazhanguwo
alinazhanguwo / DeltaOfTwoDates.py
Last active September 26, 2020 02:22
compute the delta between two consecutive dates in number of Deaths for top 10 states in America
# top 10 states in America
'''['California',
'Florida',
'Georgia',
'Illinois',
'Massachusetts',
'Michigan',
'New Jersey',
'New York',
'Pennsylvania',
@alinazhanguwo
alinazhanguwo / NumberOfDeathsCovid.py
Last active October 15, 2020 18:39
Number of deaths and confirmed cases in top 10 states of America (2020-09-13)
fig1, (ax1, ax2) = plt.subplots(1,2, figsize=(12,8), sharey=False)
fig1.tight_layout()
fig1.subplots_adjust(top=0.86)
sns.set_color_codes("pastel")
sns.barplot(x="Deaths", y="Province/State", data=bar_plot_df, label="num of Deaths", color="b", ax=ax1)
ax1.legend(ncol=2, loc="lower left", frameon=True)
ax1.set(xlim=(0, 33323), ylabel="", xlabel="Num of Deaths by states")
sns.despine(left=True, bottom=True,ax=ax1)
# set up the parameters
n_init = 12
max_iter = 225
tol = 0.0001
random_state = 42
n_jobs = -1
t0 = dt.now()
print("========= Start training ... ")