'pyweka warning on a model
my question is why i receive this warning:
java.beans.IntrospectionException: Method not found: isNumToSelect
java.desktop/java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:110)
java.desktop/java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:74)
weka.core.PropertyPath.find(PropertyPath.java:386)
weka.core.SetupGenerator.setup(SetupGenerator.java:499)
weka.classifiers.meta.multisearch.DefaultEvaluationTask.doRun(DefaultEvaluationTask.java:83)
weka.classifiers.meta.multisearch.AbstractEvaluationTask.call(AbstractEvaluationTask.java:113)
weka.classifiers.meta.multisearch.AbstractEvaluationTask.call(AbstractEvaluationTask.java:34)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java.base/java.lang.Thread.run(Thread.java:829)
at java.desktop/java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:110)
at java.desktop/java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:74)
at weka.core.PropertyPath.find(PropertyPath.java:386)
at weka.core.SetupGenerator.setup(SetupGenerator.java:499)
at weka.classifiers.meta.multisearch.DefaultEvaluationTask.doRun(DefaultEvaluationTask.java:83)
at weka.classifiers.meta.multisearch.AbstractEvaluationTask.call(AbstractEvaluationTask.java:113)
at weka.classifiers.meta.multisearch.AbstractEvaluationTask.call(AbstractEvaluationTask.java:34)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Don't know how to solve it the model execute correctly but prints that warning a lot of times during so much time before the solution.
Edit:
This is my code:
base_model_3 = Classifier(classname="weka.classifiers.trees.ADTree",
options=["-B", "10", "-E", "-3", "-S", "1"])
CostS_cls_model_3 = SingleClassifierEnhancer(classname="weka.classifiers.meta.CostSensitiveClassifier",
options =["-cost-matrix", "[0.0 2.0; 1.0 0.0]", "-S", "1"])
CostS_cls_model_3.classifier = base_model_3
ROS = Filter(classname="weka.filters.supervised.instance.Resample", options = ["-B","1","-Z","165"])
fc_model_3_ROS = FilteredClassifier(options=["-S","1"])
fc_model_3_ROS.filter = ROS
fc_model_3_ROS.classifier = CostS_cls_model_3
bagging_cls_model_3 = SingleClassifierEnhancer(classname="weka.classifiers.meta.Bagging",
options=["-P", "100", "-S", "1", "-num-slots", "1", "-I", "100"])
bagging_cls_model_3.classifier = fc_model_3_ROS
AttS_cls_model_3 = AttributeSelectedClassifier()
AttS_cls_model_3.search = from_commandline('weka.attributeSelection.Ranker -T -1.7976931348623157E308 -N 61', classname=get_classname(ASSearch))
AttS_cls_model_3.evaluator = from_commandline('weka.attributeSelection.InfoGainAttributeEval', classname=get_classname(ASEvaluation))
AttS_cls_model_3.classifier = bagging_cls_model_3
multisearch_cls_model_3 = MultiSearch(options = ["-S", "1","-class-label","1"])
multisearch_cls_model_3.evaluation = "FM"
multisearch_cls_model_3.search = ["-sample-size", "100", "-initial-folds", "2", "-subsequent-folds", "10",
"-initial-test-set", ".", "-subsequent-test-set", ".", "-num-slots", "1"]
mparam_model_3 = MathParameter()
mparam_model_3.prop = "numToSelect"
mparam_model_3.minimum = 5.0
mparam_model_3.maximum = 134.0
mparam_model_3.step = 1.0
mparam_model_3.base = 10.0
mparam_model_3.expression = "I"
multisearch_cls_model_3.parameters = [mparam_model_3]
multisearch_cls_model_3.classifier = AttS_cls_model_3
MissingValues = Filter(classname="weka.filters.unsupervised.attribute.ReplaceMissingValues")
fc_model_3_MV = FilteredClassifier(options=["-S","1"])
fc_model_3_MV.filter = MissingValues
fc_model_3_MV.classifier = multisearch_cls_model_3
Maybe i can't use "numToSelect" is there a list of the multisearch properties?
Also i have a question, with the sklearn-weka-plugin, exist any way to use RandomizedSearchCV or GridSearch(from sklearn) for a good combination of params on a Bagging Model with ADTrees as Base Estimator
something like that:
Base_CostS= WekaEstimator(classifier = base_model_1, classname="weka.classifiers.meta.CostSensitiveClassifier",
options =["-cost-matrix", "[0.0 1.0; 1.0 0.0]", "-S", "1", "-W", "weka.classifiers.trees.ADTree"],
nominal_input_vars=[2,3,4], # which attributes need to be treated as nominal
nominal_output_var=True) # class is nominal as well
bagging_model = BaggingClassifier(base_estimator = Base_CostS, n_estimators = 100, n_jobs = None, random_state = 1)
param_distributions_BG = {
'n_estimators': [10, 50, 75, 100],
'max_samples' : [0.2, 0.5, 1.0],
'bootstrap' : [True, False],
'base__iterations' : [10,15,20],
'base__Expand_Nodes' : ["-3", "-2", "-1", "1"]
}
# Búsqueda por validación cruzada
# ==============================================================================
grid_r = RandomizedSearchCV(
estimator = bagging_model,
param_distributions = param_distributions_BG,
n_iter = 50,
scoring = {'Precision':'precision_macro',
'Recall':'recall_macro',
'F1_Score':'f1_macro'},
cv = RepeatedKFold(n_splits = 5, n_repeats = 5),
verbose = 0,
random_state = 1,
return_train_score = True,
refit = refit_aux
)
I don't know if is possible to do something like that or I must do something different, also i wanted to see the "feature_importances_" but i think that the bagging models dont have that, the intention for this "feature_importances_" is to analize it with SHAP
Solution 1:[1]
MultiSearch uses property the path that you defined (the .prop property of a parameter object) to find the object in the nested Java objects to apply a parameter to, it does not need/have a predefined list of properties it can optimize. Depending on how you nest your classifiers, filters, attribute selection, you have to adjust this path.
In your setup, you have the following nesting:
MultiSearch
|
+- AttributeSelectedClassifier
|
+- Ranker
|
+- InfoGainAttributeEval
Any property path will get applied to the classifier that you have specified for MultiSearch. If you use numToSelect then MultiSearch will look in your AttributeSelectedClassifier for this Java property. Since this is a property of the Ranker object, it can't find it. The Ranker object itself is accessible via the search property inside the AttributeSelectedClassifier. In other words, you need to use search.numToSelect as your property path.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fracpete |
