This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
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. | |
### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# top 10 states in America | |
'''['California', | |
'Florida', | |
'Georgia', | |
'Illinois', | |
'Massachusetts', | |
'Michigan', | |
'New Jersey', | |
'New York', | |
'Pennsylvania', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 ... ") |
NewerOlder