Skip to content

Instantly share code, notes, and snippets.

View yohanesnuwara's full-sized avatar
:octocat:

yohanesnuwara yohanesnuwara

:octocat:
View GitHub Profile
@yohanesnuwara
yohanesnuwara / modis.js
Created February 7, 2024 13:50
GEE Code to Plot NDVI EVI Over an Area
var geometry =
/* color: #ff0000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[98.64805742984797,2.91896461364908],
[98.64944144969965,2.91896461364908],
@yohanesnuwara
yohanesnuwara / Telco_unique_values.csv
Last active January 6, 2022 03:58
Unique values of Telco preprocessed dataset
Column Unique Values Description
SeniorCitizen [0, 1] 0: No older than 65; 1: Older than 65
Partner [0, 1] 0: Single; 1: Married
Dependents [0, 1] 0: Has no children or grandparents; 1: Has any
tenure [1, 2, 8, 34, 45]
PhoneService [0, 1] 0: Not subscribes to home phone service; 1: Has phone service
MultipleLines [0, 1, 2] 0: No phone service at all; 1: Not subscribes to multiple phone lines; 2: Has multiple phone lines
OnlineSecurity [0, 1, 2] 0: No internet service; 1: Not have additional online security; 2: Have additional online security
OnlineBackup [0, 1, 2] 0: No internet service; Not have additional online backup; 2: Have additional online backup
DeviceProtection [0, 1, 2] 0: No internet service; 1: Not have device protection; 2: Have device protection
@yohanesnuwara
yohanesnuwara / Telco_Preprocessed.csv
Last active January 5, 2022 13:37
Telecom churn data preprocessed
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 27 columns, instead of 26. in line 8.
customerID,SeniorCitizen,Partner,Dependents,tenure,PhoneService,MultipleLines,OnlineSecurity,OnlineBackup,DeviceProtection,TechSupport,StreamingTV,StreamingMovies,Contract,PaperlessBilling,MonthlyCharges,TotalCharges,Churn,gender_Female,gender_Male,PaymentMethod_Bank transfer (automatic),PaymentMethod_Credit card (automatic),PaymentMethod_Electronic check,PaymentMethod_Mailed check,InternetService_DSL,InternetService_Fiber optic,InternetService_No
7590-VHVEG,0,1,0,1,0,0,1,2,1,1,1,1,0,1,29.85,29.85,0,1,0,0,0,1,0,1,0,0
5575-GNVDE,0,0,0,34,1,1,2,1,2,1,1,1,1,0,56.95,1889.5,0,0,1,0,0,0,1,1,0,0
3668-QPYBK,0,0,0,2,1,1,2,2,1,1,1,1,0,1,53.85,108.15,1,0,1,0,0,0,1,1,0,0
7795-CFOCW,0,0,0,45,0,0,2,1,2,2,1,1,1,0,42.3,1840.75,0,0,1,1,0,0,0,1,0,0
9237-HQITU,0,0,0,2,1,1,1,1,1,1,1,1,0,1,70.7,151.65,1,1,0,0,0,1,0,0,1,0
9305-CDSKC,0,0,0,8,1,2,1,1,2,1,2,2,0,1,99.65,820.5,1,1,0,0,0,1,0,0,1,0
1452-KIOVK,0,0,1,22,1,2,1,2,1,1,2,1,0,1,89.1,1949.4,0,0,1,0,1,0,0,0,1,0
6713-OKOMC,0,0,0,10,0,0,2,1,1,1,1,1,0,0,29.75,301.9,0,1,0,0,0,0,1,1,0
@yohanesnuwara
yohanesnuwara / snowflake.ipynb
Created December 24, 2021 13:16
snowflake.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yohanesnuwara
yohanesnuwara / optimization_result.csv
Created August 24, 2021 03:57
ROP optimization result
Parameter Initial Optimized
WOB 31236.8 73823.0
RPM 2.0 2.0
ROP 0.0027 0.0055
@yohanesnuwara
yohanesnuwara / optimization4.py
Created August 23, 2021 11:58
Code for optimization 4
import pyswarm as pso
# Define objective function. "pipe" as model
def f(X):
return -pipe.predict(X.reshape(1,-1)) # Minus sign to optimize
# Lower bounds of feature variables in the order of X.columns
lb = np.array([3480, 2e4, 1.5, 0.09, 0.1, 1, 0.001])
# Upper bounds of feature variables in the order of X.columns
@yohanesnuwara
yohanesnuwara / optimization3.py
Created August 23, 2021 08:11
Code for optimization 3
def plot_space(model, WOB, SURF_RPM, constant_inputs):
N_matrix = np.empty((len(WOB), len(SURF_RPM)))
for i in range(len(WOB)):
for j in range(len(SURF_RPM)):
# Unwrap constant variables
Depth, PHIF, VSH, SW, KLOGH = constant_inputs.values()
N = predict(model, Depth, PHIF, VSH, SW, KLOGH, WOB=WOB[i], SURF_RPM=SURF_RPM[j])
N_matrix[i][j] = N
plt.imshow(N_matrix, origin='lower', aspect='auto', cmap='inferno',
@yohanesnuwara
yohanesnuwara / optimization2.py
Created August 22, 2021 13:26
Code for optimization 2
def predict(model, Depth, PHIF, VSH, SW, KLOGH, WOB, SURF_RPM):
# Make a test input
X_test = np.array([Depth, WOB, SURF_RPM, PHIF, VSH, SW, KLOGH])
X_test = X_test.reshape(1,-1)
# Predict on a test input
y_pred = model.predict(X_test)
return y_pred[0]
# Predict on new inputs
@yohanesnuwara
yohanesnuwara / optimization1.py
Created August 22, 2021 13:14
Code for optimization 1
# Separate feature and target
X = df.drop(['ROP_AVG'], axis=1)
y = df['ROP_AVG']
# Train test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,
random_state=10)
# Make pipeline
steps = [('scaler', StandardScaler()),
@yohanesnuwara
yohanesnuwara / Data_ROP_optimization.csv
Created August 22, 2021 09:00
Data for ROP optimization
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 8 columns, instead of 3. in line 9.
Depth,WOB,SURF_RPM,ROP_AVG,PHIF,VSH,SW,KLOGH
3305.0,26217.863999999998,1.3147203,0.004088054,0.08671100549484449,0.07171879464621217,1.0000000001136795,0.0009999999999999998
3310.0,83492.293,1.3286738999999999,0.005159383,0.0952084975856594,0.11654831517334588,1.0000000000000002,0.0010000000000000002
3315.0,97087.882,1.4201163,0.005971469300000001,0.061636098298260736,0.10428323445521293,1.0,0.0009999999999999998
3320.0,54793.206,1.5939306999999998,0.0054191089000000005,0.04349766373664589,0.11003981104314808,1.0,0.0010000000000000002
3325.0,50301.57900000001,1.6532619999999998,0.0054352483,0.03525224077246292,0.1208077056657565,0.9999999999999998,0.0009999999999999998
3330.0,56835.194,1.65745,0.004738274000000001,0.015965128094069806,0.08556492496762315,1.0,0.001
3335.0,37638.028,2.1392382999999997,0.008811767199999999,0.04624312337708843,0.1098589745374595,1.0,0.0010000000000000002
3340.0,37638.028,2.1392382999999997,0.008811767199999999,0.04123656459834146,0.0713682580625008,1.0,0.001
3345.0,44564.583,1.97