-
Notifications
You must be signed in to change notification settings - Fork 25
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
Predictions for new data #39
Comments
Just to provide another example, I have the error |
Hello @MassimilianoGrassiDataScience AutoPrognosis selects a model architecture, and saves that without training the model. You get the architecture, and you can run your own benchmarks on different folds. The main README contains such an example from pathlib import Path
from sklearn.datasets import load_breast_cancer
from autoprognosis.studies.classifiers import ClassifierStudy
from autoprognosis.utils.serialization import load_model_from_file
from autoprognosis.utils.tester import evaluate_estimator
X, Y = load_breast_cancer(return_X_y=True, as_frame=True)
df = X.copy()
df["target"] = Y
workspace = Path("workspace")
study_name = "example"
study = ClassifierStudy(
study_name=study_name,
dataset=df, # pandas DataFrame
target="target", # the label column in the dataset
num_iter=100, # how many trials to do for each candidate
timeout=60, # seconds
classifiers=["logistic_regression", "lda", "qda"],
workspace=workspace,
)
study.run()
output = workspace / study_name / "model.p"
model = load_model_from_file(output)
# <model> contains the optimal architecture, but the model is not trained yet. You need to call fit() to use it.
# This way, we can further benchmark the selected model on the training set.
metrics = evaluate_estimator(model, X, Y)
print(f"model {model.name()} -> {metrics['clf']}")
# Train the model
model.fit(X, Y)
# Predict the probabilities of each class using the model
model.predict_proba(X) As you can see, before the We will improve the error message in the future. Let me know if this fixes your problem. |
Thank you! It works now! |
I was trying Autoprognosis, and I was able to develop the model successfully. Now I want to apply it to new data. I loaded the model following the tutorial and then I (naively?) used
.predict_proba
, but it did not work.With different attempts, including re-developing the model with different data, it always resulted in errors, with different errors for different attempts.
E.g., the latest error is
This QuantileTransformer instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.
. In this case, the model is:{'models': [<autoprognosis.plugins.pipeline.nop_normal_transform_catboost at 0x16f4b31f0>], 'weights': [0.9999999900000002], 'explainer_plugins': [], 'explanations_nepoch': 10000, 'explainers': None}
What should I do between
load_model_from_file(model_path)
and.predict_proba
?Thanks!
The text was updated successfully, but these errors were encountered: