Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions dask/Apppendix-A.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# coding: utf-8

# In[ ]:



# In[1]:
Expand All @@ -25,6 +25,3 @@
from dask.distributed import progress
futs = client.map(sleep, range(0, 100))
progress(futs)


# In[ ]:
72 changes: 36 additions & 36 deletions dask/Dask-Ch10_porting.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/env python
# coding: utf-8

# In[ ]:



# !pip install dask-yarn


# In[ ]:



# !conda install -c conda-forge dask-yarn
# import sys
# sys.version


# In[ ]:



#tag::ex_yarn_deployment[]
Expand All @@ -37,10 +37,10 @@
#end::ex_yarn_deployment[]


# In[ ]:


# In[ ]:




#tag::ex_slurm_deployment[]
Expand All @@ -63,10 +63,10 @@
#end::ex_slurm_deployment[]


# In[ ]:


# In[ ]:




#tag::ex_s3_minio_rw[]
Expand Down Expand Up @@ -98,24 +98,24 @@
#end::ex_s3_minio_rw[]


# In[ ]:


# In[ ]:




# !pip install fugue
# ! pip install antlr==4.10.1
# !pip install antlr4-python3-runtime==4.10.1


# In[ ]:


# In[ ]:


# In[ ]:





# !pip install fugue
Expand All @@ -124,19 +124,19 @@
# !conda install aiohttp


# In[ ]:


# In[ ]:


# In[ ]:





from fugue import transform


# In[ ]:



from fugue_notebook import setup
Expand All @@ -146,23 +146,23 @@
pass


# In[ ]:


# In[ ]:




import dask.dataframe as dd


# In[ ]:



url = 'https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2018-01.parquet'
df = dd.read_parquet(url)


# In[ ]:



#tag::ex_fugue_SQL[]
Expand All @@ -181,10 +181,10 @@
#end::ex_fugue_SQL[]


# In[ ]:


# In[ ]:




from fugue_notebook import setup
Expand All @@ -193,7 +193,7 @@
df = dd.read_parquet(url)


# In[ ]:



get_ipython().run_cell_magic(
Expand All @@ -202,10 +202,10 @@
'tempdf = SELECT VendorID, AVG(total_amount) AS average_fare FROM df GROUP BY VendorID\n\nSELECT *\nFROM tempdf\nORDER BY average_fare DESC\nLIMIT 5\nPRINT')


# In[ ]:


# In[ ]:




#tag::ex_postgres_dataframe[]
Expand All @@ -214,7 +214,7 @@
#end::ex_postgres_dataframe[]


# In[ ]:



#tag::ex_basic_logging[]
Expand All @@ -226,13 +226,13 @@
#end::ex_basic_logging[]


# In[ ]:


# In[ ]:


# In[ ]:





import numpy as np
Expand All @@ -243,7 +243,7 @@
from dask.distributed import Client, LocalCluster


# In[ ]:



# just sanity closing older client
Expand All @@ -252,7 +252,7 @@
client = Client(cluster) # Connect to distributed cluster and override default


# In[ ]:



#tag::ex_distributed_logging[]
Expand Down Expand Up @@ -291,16 +291,16 @@ def compute_softmax(partition, axis=0):
#end::ex_distributed_logging[]


# In[ ]:


# In[ ]:




# client.get_worker_logs()


# In[ ]:



# plain version of the function
Expand All @@ -324,10 +324,10 @@ def compute_softmax(x, axis=0):
scores_df.apply(compute_softmax, axis=1, meta=object).compute()


# In[ ]:


# In[ ]:




client.close()
27 changes: 12 additions & 15 deletions dask/Dask-Ch11_ML.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
# !pip install xgboost


# In[ ]:


# In[ ]:




# In[4]:
Expand Down Expand Up @@ -140,7 +140,7 @@
#end::ex_plot_distances


# In[ ]:



# In[19]:
Expand All @@ -151,7 +151,7 @@
df['trip_distance'].values.compute_chunk_sizes()


# In[ ]:



# In[20]:
Expand Down Expand Up @@ -211,7 +211,7 @@
plt.show()


# In[ ]:



# In[25]:
Expand All @@ -220,7 +220,7 @@
df['log_trip_duration'] = np.log(df['trip_duration'])


# In[ ]:



plt.hist(df['log_trip_duration'], bins=100)
Expand All @@ -230,7 +230,7 @@
sns.distplot(df["log_trip_duration"], bins=100)


# In[ ]:



# In[30]:
Expand Down Expand Up @@ -436,7 +436,7 @@
plt.show()


# In[ ]:



train_final = train.drop(['VendorID',
Expand Down Expand Up @@ -473,7 +473,7 @@
# In[2]:


# In[ ]:



# Just like standard xgb Dmatrix, but note that we are explicitly passing
Expand Down Expand Up @@ -523,7 +523,7 @@ def load_model(path):
# In[63]:


# In[ ]:

#tag::Dask_DataFrame_map_partition_inference[]
import dask.dataframe as dd
import dask.bag as db
Expand All @@ -546,10 +546,10 @@ def partition_operation(df):
#end::Dask_DataFrame_map_partition_inference


# In[ ]:


# In[ ]:




#tag::batched_operations[]
Expand Down Expand Up @@ -584,6 +584,3 @@ def handle_partition(df):
results = ddf.map_partitions(handle_partition)
results.compute()
#end::batched_operations


# In[ ]:
Loading