andrewssobral
commited on
Commit
•
c1e1349
1
Parent(s):
2caa1ed
Improve scripts
Browse files- .gitignore +1 -0
- scikit-learn/adaboost_regressor/train.py +1 -1
- scikit-learn/bayesian_ridge/train.py +1 -1
- scikit-learn/convert2onnx.py +11 -10
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
scikit-learn/catboost_regressor/catboost_info
|
scikit-learn/adaboost_regressor/train.py
CHANGED
@@ -17,7 +17,7 @@ X, y = dataset.data, dataset.target
|
|
17 |
# Split the dataset into training and testing sets
|
18 |
X_train, _, y_train, _ = train_test_split(X, y, test_size=0.25, random_state=random_seed)
|
19 |
|
20 |
-
# Create and train
|
21 |
model = AdaBoostRegressor(n_estimators=100, random_state=random_seed)
|
22 |
model.fit(X_train, y_train)
|
23 |
|
|
|
17 |
# Split the dataset into training and testing sets
|
18 |
X_train, _, y_train, _ = train_test_split(X, y, test_size=0.25, random_state=random_seed)
|
19 |
|
20 |
+
# Create and train model
|
21 |
model = AdaBoostRegressor(n_estimators=100, random_state=random_seed)
|
22 |
model.fit(X_train, y_train)
|
23 |
|
scikit-learn/bayesian_ridge/train.py
CHANGED
@@ -17,7 +17,7 @@ X, y = dataset.data, dataset.target
|
|
17 |
# Split the dataset into training and testing sets
|
18 |
X_train, _, y_train, _ = train_test_split(X, y, test_size=0.25, random_state=random_seed)
|
19 |
|
20 |
-
# Create and train
|
21 |
model = BayesianRidge()
|
22 |
model.fit(X_train, y_train)
|
23 |
|
|
|
17 |
# Split the dataset into training and testing sets
|
18 |
X_train, _, y_train, _ = train_test_split(X, y, test_size=0.25, random_state=random_seed)
|
19 |
|
20 |
+
# Create and train model
|
21 |
model = BayesianRidge()
|
22 |
model.fit(X_train, y_train)
|
23 |
|
scikit-learn/convert2onnx.py
CHANGED
@@ -31,18 +31,19 @@ def prepare_onnx_conversion_params(X, target_opset, model):
|
|
31 |
|
32 |
|
33 |
def convert2onnx(model, initial_type, options, target_opset, onnx_filename):
|
34 |
-
# try:
|
35 |
-
# model.save_model(onnx_filename, format="onnx")
|
36 |
-
# print("Model saved in ONNX format successfully.")
|
37 |
-
# except Exception as e:
|
38 |
-
# print("Error occurred while saving model in ONNX format:", e)
|
39 |
try:
|
40 |
-
|
41 |
-
|
42 |
-
f.write(onnx_model.SerializeToString())
|
43 |
-
print("Model converted to ONNX format and saved successfully.")
|
44 |
except Exception as e:
|
45 |
-
print("Error occurred while
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
"""
|
48 |
python convert2onnx.py california adaboost_regressor.joblib adaboost_regressor.onnx
|
|
|
31 |
|
32 |
|
33 |
def convert2onnx(model, initial_type, options, target_opset, onnx_filename):
|
|
|
|
|
|
|
|
|
|
|
34 |
try:
|
35 |
+
model.save_model(onnx_filename, format="onnx")
|
36 |
+
print("Model saved in ONNX format successfully.")
|
|
|
|
|
37 |
except Exception as e:
|
38 |
+
print("Error occurred while saving model in ONNX format:", e)
|
39 |
+
print("Trying a second method...")
|
40 |
+
try:
|
41 |
+
onnx_model = convert_sklearn(model, initial_types=initial_type, options=options, target_opset=target_opset)
|
42 |
+
with open(onnx_filename, "wb") as f:
|
43 |
+
f.write(onnx_model.SerializeToString())
|
44 |
+
print("Model converted to ONNX format and saved successfully.")
|
45 |
+
except Exception as e:
|
46 |
+
print("Error occurred while converting model to ONNX format:", e)
|
47 |
|
48 |
"""
|
49 |
python convert2onnx.py california adaboost_regressor.joblib adaboost_regressor.onnx
|