Graph Litmus Test¶
This is a very simple example to proove, that the GCN components are actually working.
In [1]:
Copied!
from Networkx_Dataset import get_random_graphs, plot_nx_edge_count
from photonai.base import Hyperpipe, PipelineElement
from sklearn.model_selection import KFold
import networkx as nx
import numpy as np
from Networkx_Dataset import get_random_graphs, plot_nx_edge_count
from photonai.base import Hyperpipe, PipelineElement
from sklearn.model_selection import KFold
import networkx as nx
import numpy as np
Create a sample dataset:
In [2]:
Copied!
# create dataset
sparse_graphs = get_random_graphs(500, 20, 0.2)
dense_graphs = get_random_graphs(500, 20, 0.4)
graphs = sparse_graphs + dense_graphs
graphs = np.stack([nx.to_numpy_array(g) for g in graphs])
graphs = np.repeat(graphs[:, :, :, np.newaxis], 2, axis=3)
# create labels
sparse_labels = [0] * 500
dense_labels = [1] * 500
labels = sparse_labels + dense_labels
# create dataset
sparse_graphs = get_random_graphs(500, 20, 0.2)
dense_graphs = get_random_graphs(500, 20, 0.4)
graphs = sparse_graphs + dense_graphs
graphs = np.stack([nx.to_numpy_array(g) for g in graphs])
graphs = np.repeat(graphs[:, :, :, np.newaxis], 2, axis=3)
# create labels
sparse_labels = [0] * 500
dense_labels = [1] * 500
labels = sparse_labels + dense_labels
Visualize the edge count of the graphs (we created two groups):
In [3]:
Copied!
plot_nx_edge_count(sparse_graphs, dense_graphs)
plot_nx_edge_count(sparse_graphs, dense_graphs)
Setup the PHOTONAI Pipeline
In [4]:
Copied!
my_pipe = Hyperpipe('basic_gcn_pipe',
inner_cv=KFold(n_splits=5),
outer_cv=KFold(n_splits=5),
optimizer='sk_opt',
optimizer_params={'n_configurations': 25},
metrics=['accuracy', 'balanced_accuracy', 'recall', 'precision'],
best_config_metric='accuracy')
my_pipe.add(PipelineElement('GraphConstructorThreshold', threshold=0.95))
my_pipe.add(PipelineElement('GCNClassifier', feature_axis=0))
my_pipe = Hyperpipe('basic_gcn_pipe',
inner_cv=KFold(n_splits=5),
outer_cv=KFold(n_splits=5),
optimizer='sk_opt',
optimizer_params={'n_configurations': 25},
metrics=['accuracy', 'balanced_accuracy', 'recall', 'precision'],
best_config_metric='accuracy')
my_pipe.add(PipelineElement('GraphConstructorThreshold', threshold=0.95))
my_pipe.add(PipelineElement('GCNClassifier', feature_axis=0))
Fit the Pipeline to our data:
In [5]:
Copied!
my_pipe.fit(graphs, labels)
my_pipe.fit(graphs, labels)
===================================================================================================== PHOTONAI ANALYSIS: basic_gcn_pipe ===================================================================================================== Found 2 target classes: [0 1] ***************************************************************************************************** Outer Cross validation Fold 1 ***************************************************************************************************** Did not find any hyperparameter to convert into skopt space.
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/photonai/optimization/scikit_optimize/sk_opt.py:169: UserWarning: Did not find any hyperparameter to convert into skopt space. warnings.warn(msg) 100%|██████████| 200/200 [00:37<00:00, 5.35it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:36<00:00, 5.47it/s] 100%|██████████| 200/200 [00:34<00:00, 5.81it/s] 100%|██████████| 200/200 [00:35<00:00, 5.64it/s] 100%|██████████| 200/200 [00:34<00:00, 5.73it/s]
----------------------------------------------------------------------------------------------------- BEST_CONFIG ----------------------------------------------------------------------------------------------------- {} ----------------------------------------------------------------------------------------------------- VALIDATION PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 0.9991 | 1.0000 | | balanced_accuracy | 0.9985 | nan | | recall | 0.9994 | 0.8000 | | precision | 0.9992 | 0.8000 | +-------------------+-------------------+------------------+
100%|██████████| 200/200 [00:43<00:00, 4.60it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result))
----------------------------------------------------------------------------------------------------- TEST PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 1.0000 | 1.0000 | | balanced_accuracy | 1.0000 | nan | | recall | 1.0000 | 0.0000 | | precision | 1.0000 | 0.0000 | +-------------------+-------------------+------------------+ ***************************************************************************************************** Outer Cross validation Fold 2 ***************************************************************************************************** Did not find any hyperparameter to convert into skopt space.
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/photonai/optimization/scikit_optimize/sk_opt.py:169: UserWarning: Did not find any hyperparameter to convert into skopt space. warnings.warn(msg) 100%|██████████| 200/200 [00:35<00:00, 5.59it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:36<00:00, 5.46it/s] 100%|██████████| 200/200 [00:34<00:00, 5.78it/s] 100%|██████████| 200/200 [00:35<00:00, 5.67it/s] 100%|██████████| 200/200 [00:34<00:00, 5.83it/s]
----------------------------------------------------------------------------------------------------- BEST_CONFIG ----------------------------------------------------------------------------------------------------- {} ----------------------------------------------------------------------------------------------------- VALIDATION PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 1.0000 | 1.0000 | | balanced_accuracy | 1.0000 | nan | | recall | 1.0000 | 0.8000 | | precision | 1.0000 | 0.8000 | +-------------------+-------------------+------------------+
100%|██████████| 200/200 [00:43<00:00, 4.63it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result))
----------------------------------------------------------------------------------------------------- TEST PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 0.9975 | 1.0000 | | balanced_accuracy | 0.9980 | nan | | recall | 0.9960 | 0.0000 | | precision | 1.0000 | 0.0000 | +-------------------+-------------------+------------------+ ***************************************************************************************************** Outer Cross validation Fold 3 ***************************************************************************************************** Did not find any hyperparameter to convert into skopt space.
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/photonai/optimization/scikit_optimize/sk_opt.py:169: UserWarning: Did not find any hyperparameter to convert into skopt space. warnings.warn(msg) 100%|██████████| 200/200 [00:34<00:00, 5.76it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:34<00:00, 5.83it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:34<00:00, 5.81it/s] 100%|██████████| 200/200 [00:33<00:00, 5.90it/s] 100%|██████████| 200/200 [00:33<00:00, 5.91it/s]
----------------------------------------------------------------------------------------------------- BEST_CONFIG ----------------------------------------------------------------------------------------------------- {} ----------------------------------------------------------------------------------------------------- VALIDATION PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 0.9987 | 0.9975 | | balanced_accuracy | 0.9986 | nan | | recall | 0.9973 | 0.5988 | | precision | 1.0000 | 0.6000 | +-------------------+-------------------+------------------+
100%|██████████| 200/200 [00:42<00:00, 4.67it/s]
----------------------------------------------------------------------------------------------------- TEST PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 0.9975 | 1.0000 | | balanced_accuracy | 0.9975 | 1.0000 | | recall | 1.0000 | 1.0000 | | precision | 0.9950 | 1.0000 | +-------------------+-------------------+------------------+ ***************************************************************************************************** Outer Cross validation Fold 4 ***************************************************************************************************** Did not find any hyperparameter to convert into skopt space.
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/photonai/optimization/scikit_optimize/sk_opt.py:169: UserWarning: Did not find any hyperparameter to convert into skopt space. warnings.warn(msg) 100%|██████████| 200/200 [00:34<00:00, 5.78it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:34<00:00, 5.79it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:35<00:00, 5.71it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:33<00:00, 5.92it/s] 100%|██████████| 200/200 [00:33<00:00, 5.89it/s]
----------------------------------------------------------------------------------------------------- BEST_CONFIG ----------------------------------------------------------------------------------------------------- {} ----------------------------------------------------------------------------------------------------- VALIDATION PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 1.0000 | 1.0000 | | balanced_accuracy | 1.0000 | nan | | recall | 1.0000 | 0.4000 | | precision | 1.0000 | 0.4000 | +-------------------+-------------------+------------------+
100%|██████████| 200/200 [00:42<00:00, 4.75it/s]
----------------------------------------------------------------------------------------------------- TEST PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 1.0000 | 1.0000 | | balanced_accuracy | 1.0000 | nan | | recall | 1.0000 | 1.0000 | | precision | 1.0000 | 1.0000 | +-------------------+-------------------+------------------+ ***************************************************************************************************** Outer Cross validation Fold 5 ***************************************************************************************************** Did not find any hyperparameter to convert into skopt space.
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/photonai/optimization/scikit_optimize/sk_opt.py:169: UserWarning: Did not find any hyperparameter to convert into skopt space. warnings.warn(msg) 100%|██████████| 200/200 [00:34<00:00, 5.79it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:34<00:00, 5.83it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:33<00:00, 5.95it/s] /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Recall is ill-defined and being set to 0.0 due to no true samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/metrics/_classification.py:1334: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. Use `zero_division` parameter to control this behavior. _warn_prf(average, modifier, msg_start, len(result)) 100%|██████████| 200/200 [00:33<00:00, 6.00it/s] 100%|██████████| 200/200 [00:33<00:00, 6.04it/s]
----------------------------------------------------------------------------------------------------- BEST_CONFIG ----------------------------------------------------------------------------------------------------- {} ----------------------------------------------------------------------------------------------------- VALIDATION PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 0.9991 | 0.9963 | | balanced_accuracy | 0.9991 | nan | | recall | 1.0000 | 0.3987 | | precision | 0.9980 | 0.4000 | +-------------------+-------------------+------------------+
100%|██████████| 200/200 [00:42<00:00, 4.74it/s]
----------------------------------------------------------------------------------------------------- TEST PERFORMANCE ----------------------------------------------------------------------------------------------------- +-------------------+-------------------+------------------+ | METRIC | PERFORMANCE TRAIN | PERFORMANCE TEST | +-------------------+-------------------+------------------+ | accuracy | 0.9988 | 1.0000 | | balanced_accuracy | 0.9990 | nan | | recall | 1.0000 | 1.0000 | | precision | 0.9967 | 1.0000 | +-------------------+-------------------+------------------+ ***************************************************************************************************** Finished all outer fold computations.
100%|██████████| 200/200 [00:53<00:00, 3.72it/s]
***************************************************************************************************** ANALYSIS INFORMATION ================================================================================ Project Folder: /home/runner/work/photonai_graph/photonai_graph/documentation/docs/examples/basic_gcn_pipe_results_2023-02-17_16-12-10, Computation Time: 2023-02-17 16:12:10.018930 - 2023-02-17 16:30:48.986392 Duration: 0:18:38.967462 Optimized for: accuracy Hyperparameter Optimizer: sk_opt DUMMY RESULTS ======================================================================================= +-------------------+--+ | PERFORMANCE DUMMY | | +-------------------+--+ +-------------------+--+ AVERAGE PERFORMANCE ACROSS OUTER FOLDS ============================================================== +-------------------+---------------+--------------+-----------+----------+ | Metric Name | Training Mean | Training Std | Test Mean | Test Std | +-------------------+---------------+--------------+-----------+----------+ | accuracy | 0.99875 | 0.001118 | 1.0 | 0.0 | | balanced_accuracy | 0.9989 | 0.00102 | nan | nan | | recall | 0.9992 | 0.0016 | 0.6 | 0.489898 | | precision | 0.998341 | 0.002099 | 0.6 | 0.489898 | +-------------------+---------------+--------------+-----------+----------+ BEST HYPERPARAMETER CONFIGURATION =================================================================== {} +--------+----------+-------------------+--------+-----------+----------------------------+ | fold # | accuracy | balanced_accuracy | recall | precision | Best Hyperparameter Config | +--------+----------+-------------------+--------+-----------+----------------------------+ | 1* | 1.0000 | nan | 0.0000 | 0.0000 | {} | | 2 | 1.0000 | nan | 0.0000 | 0.0000 | {} | | 3 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | {} | | 4 | 1.0000 | nan | 1.0000 | 1.0000 | {} | | 5 | 1.0000 | nan | 1.0000 | 1.0000 | {} | +--------+----------+-------------------+--------+-----------+----------------------------+ PHOTONAI 2.3.0 ====================================================================================== Your results are stored in /home/runner/work/photonai_graph/photonai_graph/documentation/docs/examples/basic_gcn_pipe_results_2023-02-17_16-12-10 Go to https://explorer.photon-ai.com and upload your photonai_results.json for convenient result visualization! For more info and documentation visit https://www.photon-ai.com
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/IPython/core/formatters.py:972, in MimeBundleFormatter.__call__(self, obj, include, exclude) 969 method = get_real_method(obj, self.print_method) 971 if method is not None: --> 972 return method(include=include, exclude=exclude) 973 return None 974 else: File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/base.py:631, in BaseEstimator._repr_mimebundle_(self, **kwargs) 629 output = {"text/plain": repr(self)} 630 if get_config()["display"] == "diagram": --> 631 output["text/html"] = estimator_html_repr(self) 632 return output File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/utils/_estimator_html_repr.py:417, in estimator_html_repr(estimator) 403 fallback_msg = ( 404 "In a Jupyter environment, please rerun this cell to show the HTML" 405 " representation or trust the notebook. <br />On GitHub, the" 406 " HTML representation is unable to render, please try loading this page" 407 " with nbviewer.org." 408 ) 409 out.write( 410 f"<style>{style_with_id}</style>" 411 f'<div id="{container_id}" class="sk-top-container">' (...) 415 '<div class="sk-container" hidden>' 416 ) --> 417 _write_estimator_html( 418 out, 419 estimator, 420 estimator.__class__.__name__, 421 estimator_str, 422 first_call=True, 423 ) 424 out.write("</div></div>") 426 html_output = out.getvalue() File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/utils/_estimator_html_repr.py:151, in _write_estimator_html(out, estimator, estimator_label, estimator_label_details, first_call) 149 """Write estimator to html in serial, parallel, or by itself (single).""" 150 if first_call: --> 151 est_block = _get_visual_block(estimator) 152 else: 153 with config_context(print_changed_only=True): File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/utils/_estimator_html_repr.py:127, in _get_visual_block(estimator) 123 # check if estimator looks like a meta estimator wraps estimators 124 if hasattr(estimator, "get_params"): 125 estimators = [ 126 (key, est) --> 127 for key, est in estimator.get_params(deep=False).items() 128 if hasattr(est, "get_params") and hasattr(est, "fit") 129 ] 130 if estimators: 131 return _VisualBlock( 132 "parallel", 133 [est for _, est in estimators], 134 names=[f"{key}: {est.__class__.__name__}" for key, est in estimators], 135 name_details=[str(est) for _, est in estimators], 136 ) File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/base.py:211, in BaseEstimator.get_params(self, deep) 209 out = dict() 210 for key in self._get_param_names(): --> 211 value = getattr(self, key) 212 if deep and hasattr(value, "get_params") and not isinstance(value, type): 213 deep_items = value.get_params().items() AttributeError: 'Hyperpipe' object has no attribute 'best_config_metric'
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/IPython/core/formatters.py:342, in BaseFormatter.__call__(self, obj) 340 method = get_real_method(obj, self.print_method) 341 if method is not None: --> 342 return method() 343 return None 344 else: File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/base.py:625, in BaseEstimator._repr_html_inner(self) 620 def _repr_html_inner(self): 621 """This function is returned by the @property `_repr_html_` to make 622 `hasattr(estimator, "_repr_html_") return `True` or `False` depending 623 on `get_config()["display"]`. 624 """ --> 625 return estimator_html_repr(self) File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/utils/_estimator_html_repr.py:417, in estimator_html_repr(estimator) 403 fallback_msg = ( 404 "In a Jupyter environment, please rerun this cell to show the HTML" 405 " representation or trust the notebook. <br />On GitHub, the" 406 " HTML representation is unable to render, please try loading this page" 407 " with nbviewer.org." 408 ) 409 out.write( 410 f"<style>{style_with_id}</style>" 411 f'<div id="{container_id}" class="sk-top-container">' (...) 415 '<div class="sk-container" hidden>' 416 ) --> 417 _write_estimator_html( 418 out, 419 estimator, 420 estimator.__class__.__name__, 421 estimator_str, 422 first_call=True, 423 ) 424 out.write("</div></div>") 426 html_output = out.getvalue() File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/utils/_estimator_html_repr.py:151, in _write_estimator_html(out, estimator, estimator_label, estimator_label_details, first_call) 149 """Write estimator to html in serial, parallel, or by itself (single).""" 150 if first_call: --> 151 est_block = _get_visual_block(estimator) 152 else: 153 with config_context(print_changed_only=True): File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/utils/_estimator_html_repr.py:127, in _get_visual_block(estimator) 123 # check if estimator looks like a meta estimator wraps estimators 124 if hasattr(estimator, "get_params"): 125 estimators = [ 126 (key, est) --> 127 for key, est in estimator.get_params(deep=False).items() 128 if hasattr(est, "get_params") and hasattr(est, "fit") 129 ] 130 if estimators: 131 return _VisualBlock( 132 "parallel", 133 [est for _, est in estimators], 134 names=[f"{key}: {est.__class__.__name__}" for key, est in estimators], 135 name_details=[str(est) for _, est in estimators], 136 ) File /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/sklearn/base.py:211, in BaseEstimator.get_params(self, deep) 209 out = dict() 210 for key in self._get_param_names(): --> 211 value = getattr(self, key) 212 if deep and hasattr(value, "get_params") and not isinstance(value, type): 213 deep_items = value.get_params().items() AttributeError: 'Hyperpipe' object has no attribute 'best_config_metric'
Out[5]:
Hyperpipe(name='basic_gcn_pipe')
As we can see, the task is solved with an accuracy of nearly 1, test passed.