Ekjaer commited on
Commit
0bf8457
·
1 Parent(s): 9e81ba8

pushing files to the repo from the example!

Browse files
Files changed (2) hide show
  1. README.md +33 -36
  2. init_repo_MLstructureMining.py +9 -1
README.md CHANGED
@@ -146,41 +146,38 @@ The model is trained with below hyperparameters.
146
  <details>
147
  <summary> Click to expand </summary>
148
 
149
- | Hyperparameter | Value |
150
- |---------------------------------|----------------------------------------------------------|
151
- | aggressive_elimination | False |
152
- | cv | 5 |
153
- | error_score | nan |
154
- | estimator__categorical_features | |
155
- | estimator__early_stopping | auto |
156
- | estimator__l2_regularization | 0.0 |
157
- | estimator__learning_rate | 0.1 |
158
- | estimator__loss | auto |
159
- | estimator__max_bins | 255 |
160
- | estimator__max_depth | |
161
- | estimator__max_iter | 100 |
162
- | estimator__max_leaf_nodes | 31 |
163
- | estimator__min_samples_leaf | 20 |
164
- | estimator__monotonic_cst | |
165
- | estimator__n_iter_no_change | 10 |
166
- | estimator__random_state | |
167
- | estimator__scoring | loss |
168
- | estimator__tol | 1e-07 |
169
- | estimator__validation_fraction | 0.1 |
170
- | estimator__verbose | 0 |
171
- | estimator__warm_start | False |
172
- | estimator | HistGradientBoostingClassifier() |
173
- | factor | 3 |
174
- | max_resources | auto |
175
- | min_resources | exhaust |
176
- | n_jobs | -1 |
177
- | param_grid | {'max_leaf_nodes': [5, 10, 15], 'max_depth': [2, 5, 10]} |
178
- | random_state | 42 |
179
- | refit | True |
180
- | resource | n_samples |
181
- | return_train_score | True |
182
- | scoring | |
183
- | verbose | 0 |
184
 
185
  </details>
186
 
@@ -188,7 +185,7 @@ The model is trained with below hyperparameters.
188
 
189
  The model plot is below.
190
 
191
- <style>#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 {color: black;background-color: white;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 pre{padding: 0;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-toggleable {background-color: white;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 label.sk-toggleable__label-arrow:before {content: "▸";float: left;margin-right: 0.25em;color: #696969;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: "▾";}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-estimator:hover {background-color: #d4ebff;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel-item::after {content: "";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-serial::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-item {z-index: 1;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel-item {display: flex;flex-direction: column;position: relative;background-color: white;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-parallel-item:only-child::after {width: 0;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;position: relative;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-label label {font-family: monospace;font-weight: bold;background-color: white;display: inline-block;line-height: 1.2em;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-label-container {position: relative;z-index: 2;text-align: center;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0 div.sk-text-repr-fallback {display: none;}</style><div id="sk-fb87c2a1-e870-4bce-b725-6b0e13c3bba0" class="sk-top-container" style="overflow: auto;"><div class="sk-text-repr-fallback"><pre>HalvingGridSearchCV(estimator=HistGradientBoostingClassifier(), n_jobs=-1,param_grid={&#x27;max_depth&#x27;: [2, 5, 10],&#x27;max_leaf_nodes&#x27;: [5, 10, 15]},random_state=42)</pre><b>Please rerun this cell to show the HTML repr or trust the notebook.</b></div><div class="sk-container" hidden><div class="sk-item sk-dashed-wrapped"><div class="sk-label-container"><div class="sk-label sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="c32330b7-e133-407a-a526-cff8a85d5a1a" type="checkbox" ><label for="c32330b7-e133-407a-a526-cff8a85d5a1a" class="sk-toggleable__label sk-toggleable__label-arrow">HalvingGridSearchCV</label><div class="sk-toggleable__content"><pre>HalvingGridSearchCV(estimator=HistGradientBoostingClassifier(), n_jobs=-1,param_grid={&#x27;max_depth&#x27;: [2, 5, 10],&#x27;max_leaf_nodes&#x27;: [5, 10, 15]},random_state=42)</pre></div></div></div><div class="sk-parallel"><div class="sk-parallel-item"><div class="sk-item"><div class="sk-serial"><div class="sk-item"><div class="sk-estimator sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="6f86c69b-4613-4478-8703-ffd0c308d213" type="checkbox" ><label for="6f86c69b-4613-4478-8703-ffd0c308d213" class="sk-toggleable__label sk-toggleable__label-arrow">HistGradientBoostingClassifier</label><div class="sk-toggleable__content"><pre>HistGradientBoostingClassifier()</pre></div></div></div></div></div></div></div></div></div></div>
192
 
193
  ## Evaluation Results
194
 
 
146
  <details>
147
  <summary> Click to expand </summary>
148
 
149
+ | Hyperparameter | Value |
150
+ |-------------------------|-----------------|
151
+ | objective | binary:logistic |
152
+ | use_label_encoder | True |
153
+ | base_score | 0.5 |
154
+ | booster | gbtree |
155
+ | colsample_bylevel | 1 |
156
+ | colsample_bynode | 1 |
157
+ | colsample_bytree | 1 |
158
+ | enable_categorical | False |
159
+ | gamma | 0 |
160
+ | gpu_id | -1 |
161
+ | importance_type | |
162
+ | interaction_constraints | |
163
+ | learning_rate | 0.300000012 |
164
+ | max_delta_step | 0 |
165
+ | max_depth | 6 |
166
+ | min_child_weight | 1 |
167
+ | missing | nan |
168
+ | monotone_constraints | () |
169
+ | n_estimators | 100 |
170
+ | n_jobs | 8 |
171
+ | num_parallel_tree | 1 |
172
+ | predictor | auto |
173
+ | random_state | 0 |
174
+ | reg_alpha | 0 |
175
+ | reg_lambda | 1 |
176
+ | scale_pos_weight | |
177
+ | subsample | 1 |
178
+ | tree_method | auto |
179
+ | validate_parameters | 1 |
180
+ | verbosity | |
 
 
 
181
 
182
  </details>
183
 
 
185
 
186
  The model plot is below.
187
 
188
+ <style>#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 {color: black;background-color: white;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 pre{padding: 0;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-toggleable {background-color: white;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 label.sk-toggleable__label-arrow:before {content: "▸";float: left;margin-right: 0.25em;color: #696969;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: "▾";}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-estimator:hover {background-color: #d4ebff;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel-item::after {content: "";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-serial::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-item {z-index: 1;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel::before {content: "";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 2em;bottom: 0;left: 50%;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel-item {display: flex;flex-direction: column;position: relative;background-color: white;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-parallel-item:only-child::after {width: 0;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;position: relative;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-label label {font-family: monospace;font-weight: bold;background-color: white;display: inline-block;line-height: 1.2em;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-label-container {position: relative;z-index: 2;text-align: center;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-800ead0c-95d2-4adb-adfc-71adae7c28c0 div.sk-text-repr-fallback {display: none;}</style><div id="sk-800ead0c-95d2-4adb-adfc-71adae7c28c0" class="sk-top-container" style="overflow: auto;"><div class="sk-text-repr-fallback"><pre>XGBClassifier(base_score=0.5, booster=&#x27;gbtree&#x27;, colsample_bylevel=1,colsample_bynode=1, colsample_bytree=1, enable_categorical=False,gamma=0, gpu_id=-1, importance_type=None,interaction_constraints=&#x27;&#x27;, learning_rate=0.300000012,max_delta_step=0, max_depth=6, min_child_weight=1, missing=nan,monotone_constraints=&#x27;()&#x27;, n_estimators=100, n_jobs=8,num_parallel_tree=1, predictor=&#x27;auto&#x27;, random_state=0,reg_alpha=0, reg_lambda=1, scale_pos_weight=None, subsample=1,tree_method=&#x27;auto&#x27;, validate_parameters=1, verbosity=None)</pre><b>Please rerun this cell to show the HTML repr or trust the notebook.</b></div><div class="sk-container" hidden><div class="sk-item"><div class="sk-estimator sk-toggleable"><input class="sk-toggleable__control sk-hidden--visually" id="b4173fad-9393-4606-92e6-246559a01a45" type="checkbox" checked><label for="b4173fad-9393-4606-92e6-246559a01a45" class="sk-toggleable__label sk-toggleable__label-arrow">XGBClassifier</label><div class="sk-toggleable__content"><pre>XGBClassifier(base_score=0.5, booster=&#x27;gbtree&#x27;, colsample_bylevel=1,colsample_bynode=1, colsample_bytree=1, enable_categorical=False,gamma=0, gpu_id=-1, importance_type=None,interaction_constraints=&#x27;&#x27;, learning_rate=0.300000012,max_delta_step=0, max_depth=6, min_child_weight=1, missing=nan,monotone_constraints=&#x27;()&#x27;, n_estimators=100, n_jobs=8,num_parallel_tree=1, predictor=&#x27;auto&#x27;, random_state=0,reg_alpha=0, reg_lambda=1, scale_pos_weight=None, subsample=1,tree_method=&#x27;auto&#x27;, validate_parameters=1, verbosity=None)</pre></div></div></div></div></div>
189
 
190
  ## Evaluation Results
191
 
init_repo_MLstructureMining.py CHANGED
@@ -7,6 +7,8 @@ from uuid import uuid4
7
 
8
  import numpy as np
9
  import xgboost
 
 
10
  import sklearn
11
  from huggingface_hub import HfApi
12
  from sklearn.datasets import load_breast_cancer
@@ -43,7 +45,13 @@ _, pkl_name = mkstemp(prefix="skops-", suffix=".pkl")
43
  with open(pkl_name, mode="bw") as f:
44
  pickle.dump(model, file=f)
45
 
 
 
 
 
46
 
 
 
47
 
48
  local_repo = mkdtemp(prefix="skops-")
49
  hub_utils.init(
@@ -59,7 +67,7 @@ if "__file__" in locals(): # __file__ not defined during docs built
59
  hub_utils.add_files(__file__, dst=local_repo)
60
 
61
  print(os.listdir(local_repo))
62
-
63
  model_card = card.Card(model, metadata=card.metadata_from_config(Path(local_repo)))
64
  model_card.save(Path(local_repo) / "README.md")
65
 
 
7
 
8
  import numpy as np
9
  import xgboost
10
+ from xgboost import XGBClassifier
11
+
12
  import sklearn
13
  from huggingface_hub import HfApi
14
  from sklearn.datasets import load_breast_cancer
 
45
  with open(pkl_name, mode="bw") as f:
46
  pickle.dump(model, file=f)
47
 
48
+ booster = xgboost.Booster({'nthread': 8})
49
+ booster.load_model("xgb_model_bayse_optimization_00000.bin")
50
+
51
+ model = XGBClassifier()
52
 
53
+ # Set the booster
54
+ model._Booster = booster
55
 
56
  local_repo = mkdtemp(prefix="skops-")
57
  hub_utils.init(
 
67
  hub_utils.add_files(__file__, dst=local_repo)
68
 
69
  print(os.listdir(local_repo))
70
+ print(type(model))
71
  model_card = card.Card(model, metadata=card.metadata_from_config(Path(local_repo)))
72
  model_card.save(Path(local_repo) / "README.md")
73