Skip to content

Instantly share code, notes, and snippets.

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)
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
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)
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
View loading_imagery.py
df = spark.read.raster(catalog,
catalog_col_names=['B01', 'B02'],
) \
.withColumnRenamed('B01', 'red') \
.withColumnRenamed('B02', 'nir')
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',
)
@parulnith
parulnith / README-Template.md
Last active Jun 7, 2019 — forked from PurpleBooth/README-Template.md
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

View exploring_boston.py
,CRIM,ZN,INDUS,CHAS,NOX,RM,AGE,DIS,RAD,TAX,PTRATIO,B,LSTAT
0,0.00632,18,2.31,0,0.538,6.575,65.2,4.09,1,296,15.3,396.9,4.98
1,0.02731,0,7.07,0,0.469,6.421,78.9,4.9671,2,242,17.8,396.9,9.14
2,0.02729,0,7.07,0,0.469,7.185,61.1,4.9671,2,242,17.8,392.83,4.03
3,0.03237,0,2.18,0,0.458,6.998,45.8,6.0622,3,222,18.7,394.63,2.94
4,0.06905,0,2.18,0,0.458,7.147,54.2,6.0622,3,222,18.7,396.9,5.33
View wine_data_correlation.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 5 columns, instead of 1. in line 1.
fixed acidity,volatile acidity,citric acid,residual,sugar chlorides free sulfur dioxide total sulfur dioxide density pH sulphates alcohol quality
1 -0.0226973 0.289181 0.0890207 0.0230856 -0.0493959 0.0910698 0.265331 -0.425858 -0.017143 -0.120881 -0.113663
-0.0226973 1 -0.149472 0.0642861 0.0705116 -0.0970119 0.0892605 0.0271138 -0.0319154 -0.0357281 0.0677179 -0.194723
0.289181 -0.149472 1 0.0942116 0.114364 0.0940772 0.121131 0.149503 -0.163748 0.0623309 -0.0757287 -0.00920909
0.0890207 0.0642861 0.0942116 1 0.0886845 0.299098 0.401439 0.838966 -0.194133 -0.0266644 -0.450631 -0.0975768
0.0230856 0.0705116 0.114364 0.0886845 1 0.101392 0.19891 0.257211 -0.0904395 0.0167629 -0.360189 -0.209934
-0.0493959 -0.0970119 0.0940772 0.299098 0.101392 1 0.615501 0.29421 -0.000617796 0.0592172 -0.250104 0.00815807
0.0910698 0.0892605 0.121131 0.401439 0.19891 0.615501 1 0.529881 0.00232097 0.134562 -0.448892 -0.174737
0.265331 0.0271138 0.149503 0.838966 0.257211 0.29421 0.529881 1 -0.0935915 0.0744931 -0.780138 -0.30
You can’t perform that action at this time.