<jupyter_start><jupyter_text>[DON'T EDIT]<jupyter_code>columns_data=['PODES_landform', 'alos_slope', 'alos_dsm', 'wet_mean',
       'green_mean', 'bright_mean', 'ARVI_mean', 'SAVI_mean', 'NDBI_mean',
       'mNDWI_mean', 'NDWI_mean', 'mNDVI_mean', 'NDVI_mean', 'wet_p50',
       'green_p50', 'bright_p50', 'ARVI_p50', 'SAVI_p50', 'NDBI_p50',
       'mNDWI_p50', 'NDWI_p50', 'mNDVI_p50', 'NDVI_p50', 'S2_B12mean',
       'S2_B11mean', 'S2_B8mean', 'S2_B4mean', 'S2_B3mean', 'S2_B2mean',
       'S2_B12med', 'S2_B11med', 'S2_B8med', 'S2_B4med', 'S2_B3med',
       'S2_B2med']<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>file_name='kerangka-spasial/ml_learning/train_data/'+train_no_outlier
data_=pd.read_csv(file_name,sep=';').dropna()
pivot_=data_.pivot_table(index='TRAIN_CLASS',values='x',aggfunc='count').reset_index().rename(columns={'x':'SAMPLE SIZE'})
pivot_['TRAIN_CLASS']=pivot_['TRAIN_CLASS'].astype(str)
fig = px.bar(pivot_, x="TRAIN_CLASS", y="SAMPLE SIZE", title="Sample Size")
fig.show()
X=data_[columns_data]
y=data_[['TRAIN_CLASS']]
train_x, valid_x, train_y, valid_y = train_test_split(X, y, test_size=0.2,stratify=y)
valid_y.TRAIN_CLASS.value_counts()<jupyter_output><empty_output><jupyter_text>Recursive Feature Elimination Use the RFE algorithms for feature selection with base catboost classifiers model<jupyter_code>feature_select=rfe_cat(train_x,train_y,valid_x,valid_y,14)<jupyter_output>Start Recursive Feature Elimination<jupyter_text>HyperParameter Tuning with Optuna Tuning Parameter that would be used as model. This code take a long time<jupyter_code>best_params=tune_study(train_x,train_y,valid_x,valid_y,feature_select)<jupyter_output>[32m[I 2021-10-13 07:01:49,538][0m A new study created in memory with name: no-name-40448d4c-f7d4-47e9-accd-80d34a131d3c[0m
[32m[I 2021-10-13 07:02:02,280][0m Trial 0 finished with value: 0.8641597814065447 and parameters: {'learning_rate': 0.013591611174496147, 'depth': 7, 'l2_leaf_reg': 0.0009966493462028915, 'colsample_bylevel': 0.03806047508395215, 'boosting_type': 'Plain', 'auto_class_weights': 'SqrtBalanced', 'bootstrap_type': 'Bayesian', 'bagging_temperature': 8.648550495198306}. Best is trial 0 with value: 0.8641597814065447.[0m
[32m[I 2021-10-13 07:03:24,253][0m Trial 1 finished with value: 0.9374579836488626 and parameters: {'learning_rate': 0.043380580627361186, 'depth': 12, 'l2_leaf_reg': 0.00019687577521012645, 'colsample_bylevel': 0.09533303487365898, 'boosting_type': 'Plain', 'auto_class_weights': 'Balanced', 'bootstrap_type': 'Bernoulli', 'subsample': 0.283884548395833}. Best is trial 1 with value: 0.9374579836488626.[0m
[32m[I 2021-10-13 07:03:32,575][0m Tri[...]<jupyter_text>Export the result<jupyter_code>config_model={'features':feature_select,'params':best_params}
file_name = 'kerangka-spasial/ml_learning/model_result/'+model_param_feature
with open(file_name, 'wb') as handle:
    pickle.dump(config_model, handle, protocol=pickle.HIGHEST_PROTOCOL)
# os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = r'petabps-7c4331c6fd2d.json'
# client = storage.Client()
# bucket = client.get_bucket('kerangka-spasial')
# file_name='kerangka-spasial/ml_learning/model_result/'+model_param_feature

# bucket.blob(file_name).upload_from_filename(model_param_feature)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15143288084464554, 'fraction_numerical': 0.11613876319758673, 'mean_word_length': 9.109756097560975, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '345293', 'license': 'MIT', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1360, 'n_words': 196, 'path': '05_RepoFor LandCOver Agg Census/04_Feature Elimination and Tuning Hyper Parameter.ipynb', 'repo_name': 'achmfirmansyah/sweet_project', 'size': '3315'}