Skip to content
{{ message }}

Instantly share code, notes, and snippets.

Parul Pandeyparulnith

Last active Jan 17, 2021
Untitled9.ipynb
View Music_genre_classification.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Last active Jan 8, 2021
Using matplotlib's FuncAnimation to do a basic animation of a sine wave moving across the screen:
View Moving Sine Wave.py
 import numpy as np from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation plt.style.use('seaborn-pastel') fig = plt.figure() ax = plt.axes(xlim=(0, 4), ylim=(-2, 2)) line, = ax.plot([], [], lw=3)
Created Oct 1, 2020
View evaluate.py
 %matplotlib inline from sklearn.metrics import roc_curve, precision_recall_curve, auc import matplotlib.pyplot as plt import numpy as np def get_auc(labels, scores): fpr, tpr, thresholds = roc_curve(labels, scores) auc_score = auc(fpr, tpr)
Last active Jul 17, 2020
Creating a growing coil with matplotlib
View coil.py
 import matplotlib.pyplot as plt import matplotlib.animation as animation import numpy as np plt.style.use('dark_background') fig = plt.figure() ax = plt.axes(xlim=(-50, 50), ylim=(-50, 50)) line, = ax.plot([], [], lw=2)
Created Jun 30, 2020
View data.py
 df = pd.read_csv("diabetes.csv") df.head() Pregnancies Glucose BloodPressure SkinThickness Insulin BMI DiabetesPedigreeFunction Age Outcome 0 6 148 72 35 0 33.6 0.627 50 1 1 1 85 66 29 0 26.6 0.351 31 0 2 8 183 64 0 0 23.3 0.672 32 1 3 1 89 66 23 94 28.1 0.167 21 0 4 0 137 40 35 168 43.1 2.288 33 1
Last active May 29, 2020
View live_graph.py
 #importing libraries import matplotlib.pyplot as plt import matplotlib.animation as animation fig = plt.figure() #creating a subplot ax1 = fig.add_subplot(1,1,1) def animate(i):
Last active Feb 18, 2020
View Activating.py
 links = result.json()[u"analytic"]["_links"] self_link = links["_self"] activation_link = links["activate"] # Request activation of the 'analytic' asset: activate_result = \ requests.get( activation_link, auth=HTTPBasicAuth(PLANET_API_KEY, '')
Last active Feb 6, 2020
View Query_MODIS_Imagery.py
 start = '2018-07-01' end = '2019-08-31' catalog = earth_ondemand.read_catalog( geo="POINT(88.92 21.88)", # Coordinates of Sunderban National Park start_datetime=start, end_datetime=end, collections='mcd43a4', )
Last active Feb 6, 2020
View timeseries.py
 time_series = df.groupBy(F.year('datetime').alias('year'), F.weekofyear('datetime').alias('week')) \ .agg(rf_agg_mean('ndvi').alias('mean_ndvi')) ts_pd = time_series.toPandas() #Visualizing using matplotlib ts_pd.sort_values(['year', 'week'], inplace=True) # Create a compact label of year and week number yyyy_ww ts_pd['year_week'] = ts_pd.apply(lambda r:'{0:g}_{1:02g}'.format(r.year, r.week), axis=1)
Created Feb 6, 2020
View spark_dataframe.py
 df.select('red', 'nir', 'datetime', 'id', rf_extent('red').alias('extent'), rf_crs('red').alias('crs')) \ .filter(rf_no_data_cells(rf_with_no_data('red', 0)) < 800) # show tiles that have lots of valid data
You can’t perform that action at this time.