Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GradientBoostingClassifier converter predicted probabilities don't match with Scikit predicitons. #184

Closed
prabhat00155 opened this issue Jun 14, 2019 · 0 comments
Projects

Comments

@prabhat00155
Copy link
Contributor

data = load_iris()
X = data.data
y = data.target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=42)
model = GradientBoostingClassifier(loss='deviance', learning_rate=0.21, n_estimators=10, subsample=1.0,
criterion='friedman_mse', min_samples_split=2, min_samples_leaf=1,
min_weight_fraction_leaf=0.0, max_depth=3, min_impurity_decrease=0.0,
min_impurity_split=None, init=None, random_state=None, max_features=None,
verbose=0, max_leaf_nodes=None, warm_start=False, presort='auto',
validation_fraction=0.1, n_iter_no_change=None, tol=0.0001).fit(X_train, y_train)

onnx_model = convert_sklearn(model, 'lr', [('input', FloatTensorType(X_test.shape))])
save_model(onnx_model, 'lr1.onnx')
sess = InferenceSession('lr1.onnx')
res = sess.run(None, input_feed={'input': X_test.astype(np.float32)})

r1 = np.mean(np.isclose(model.predict_proba(X_test)[:10], list(map(lambda x:
list(map(lambda y: x[y], x)), res[1][:10])), atol=1e-4))
r2 = np.mean(res[0] == model.predict(X_test))
print(f'{r1} {r2}')

Result: 0.03333333333333333 1.0

@xadupre xadupre added this to To do in Mismatches Jul 22, 2019
@xadupre xadupre moved this from To do to Done in Mismatches Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Mismatches
  
Done
Development

No branches or pull requests

1 participant