This file contains 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
var geometry = | |
/* color: #ff0000 */ | |
/* displayProperties: [ | |
{ | |
"type": "rectangle" | |
} | |
] */ | |
ee.Geometry.Polygon( | |
[[[98.64805742984797,2.91896461364908], | |
[98.64944144969965,2.91896461364908], |
This file contains 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
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 |
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.
This file contains 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
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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Parameter | Initial | Optimized | |
---|---|---|---|
WOB | 31236.8 | 73823.0 | |
RPM | 2.0 | 2.0 | |
ROP | 0.0027 | 0.0055 |
This file contains 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 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 |
This file contains 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 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', |
This file contains 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 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 |
This file contains 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
# 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()), |
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.
This file contains 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
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 |
NewerOlder