Exception occur when use Generate Interpretation operator with Python Learner
MohammadEsk
New Altair Community Member
I am trying to use Generate Interpretation operator with Python learner but it keeps give me this Exception, I have tried several models in the Python code such as SVM and GausianMixture.
Also the Log shows this warning "Custom Python Learner: The number of regular attributes of the given example set does not fit the number of attributes of the training example set, training: 7, application: 8". Maybe this warnig and IndexOutOfBoundsException are related.
The Apply Model operator works well with the Python Learner, also I am sure that the number of attributes are all the same, and I tried to remove the label to see if there is a difference, but the same error apears when using Generate Interpetation.
What could be the problem is?
Also the Log shows this warning "Custom Python Learner: The number of regular attributes of the given example set does not fit the number of attributes of the training example set, training: 7, application: 8". Maybe this warnig and IndexOutOfBoundsException are related.
The Apply Model operator works well with the Python Learner, also I am sure that the number of attributes are all the same, and I tried to remove the label to see if there is a difference, but the same error apears when using Generate Interpetation.
What could be the problem is?
Tagged:
0
Answers
-
Hi @MohammadEsk,the line failing is the line were we try to find the confidence column after scoring. Does your python script provide confidences or only predictions?Can you maybe provide an example for it? This is either a bug or we need a proper error message here.Cheers,Martin0
-
Hi,just ran this one here and it worked just fine:
<?xml version="1.0" encoding="UTF-8"?><process version="9.10.001"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.10.001" expanded="true" name="Process" origin="GENERATED_TUTORIAL"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="SYSTEM"/><br> <process expanded="true"><br> <operator activated="true" class="retrieve" compatibility="9.10.001" expanded="true" height="68" name="Retrieve Titanic Training" width="90" x="45" y="34"><br> <parameter key="repository_entry" value="//Samples/data/Titanic Training"/><br> </operator><br> <operator activated="true" class="nominal_to_numerical" compatibility="9.10.001" expanded="true" height="103" name="Nominal to Numerical" width="90" x="179" y="34"><br> <parameter key="return_preprocessing_model" value="false"/><br> <parameter key="create_view" value="false"/><br> <parameter key="attribute_filter_type" value="all"/><br> <parameter key="attribute" value=""/><br> <parameter key="attributes" value=""/><br> <parameter key="use_except_expression" value="false"/><br> <parameter key="value_type" value="nominal"/><br> <parameter key="use_value_type_exception" value="false"/><br> <parameter key="except_value_type" value="file_path"/><br> <parameter key="block_type" value="single_value"/><br> <parameter key="use_block_type_exception" value="false"/><br> <parameter key="except_block_type" value="single_value"/><br> <parameter key="invert_selection" value="false"/><br> <parameter key="include_special_attributes" value="false"/><br> <parameter key="coding_type" value="dummy coding"/><br> <parameter key="use_comparison_groups" value="false"/><br> <list key="comparison_groups"/><br> <parameter key="unexpected_value_handling" value="all 0 and warning"/><br> <parameter key="use_underscore_in_name" value="false"/><br> </operator><br> <operator activated="true" class="python_scripting:python_learner" compatibility="9.10.001" expanded="true" height="82" name="Python Learner" width="90" x="313" y="34"><br> <parameter key="editable" value="true"/><br> <parameter key="operator" value="{ "name": "Custom Python Learner", "dropSpecial": true, "capabilities": ["numerical attributes", "binominal label", "polynominal label"], "parameters": [ { "name": "1st_parameter", "description": "By default parameters are of type string\.", "optional": true }, { "name": "2nd_parameter", "description": "This is an example of an mandatory integer parameter with a default value 100\.", "type": "integer", "optional": false, "value": 100 }, { "name": "3rd_parameter", "description": "An example of a categorical parameter type\.", "type": "category", "categories": ["Category A", "Category B", "Category C", "Default Category"], "value": "Default Category" } ] }.from pandas import DataFrame from sklearn\.naive_bayes import GaussianNB # Mandatory training function\. When implementing a supervised learner, the # input data will be split into the feature vector X and the label vector y\. # Parameters are passed in as plain Python dictionary\. def rm_train(X, y, parameters): 	# This example does not make use of the parameter to configure the model\. 	# However, printing the dictionary will show its values in the log\. 	print(parameters) 	# You can return any Python object as model\. Sci-kit learn classifiers such 	# as the Gaussian Naive Bayes are just one example\. 	clf = GaussianNB() 	model = clf\.fit(X, y) 	return model # Mandatory application function\. The input data set X is guaranteed to have # have the same columns and column order as seen during training\. The model is # the of the same type as the model return during training\. def rm_apply(X, model): 	prediction = DataFrame(model\.predict(X)) 	probabilities = DataFrame(model\.predict_proba(X)) 	probabilities\.columns = model\.classes_ 	# The first return value must be a Pandas DataFrame with a single column 	# and of the size as X\. The second return value is optional and can be used 	# to return probabilities (if any)\. 	return prediction, probabilities "/><br> <parameter key="use_default_python" value="true"/><br> <parameter key="package_manager" value="conda (anaconda)"/><br> <parameter key="2nd_parameter" value="100"/><br> <parameter key="3rd_parameter" value="Default Category"/><br> </operator><br> <operator activated="true" class="multiply" compatibility="9.10.001" expanded="true" height="103" name="Multiply" width="90" x="447" y="55"/><br> <operator activated="true" class="filter_example_range" compatibility="9.10.001" expanded="true" height="82" name="Filter Example Range" width="90" x="581" y="85"><br> <parameter key="first_example" value="1"/><br> <parameter key="last_example" value="5"/><br> <parameter key="invert_filter" value="false"/><br> </operator><br> <operator activated="true" class="interpretation:generate_interpretation" compatibility="0.4.001" expanded="true" height="124" name="Generate Interpretation" width="90" x="715" y="34"><br> <parameter key="algorithm" value="LIME"/><br> <parameter key="sample_size" value="100"/><br> <parameter key="redraw_local_samples" value="true"/><br> <parameter key="explanation_algorithm" value="Correlation"/><br> <parameter key="locality" value="0.2"/><br> <parameter key="maximal_explaining_attributes" value="3"/><br> <parameter key="use_local_random_seed" value="false"/><br> <parameter key="local_random_seed" value="1992"/><br> </operator><br> <connect from_op="Retrieve Titanic Training" from_port="output" to_op="Nominal to Numerical" to_port="example set input"/><br> <connect from_op="Nominal to Numerical" from_port="example set output" to_op="Python Learner" to_port="training set"/><br> <connect from_op="Python Learner" from_port="model" to_op="Generate Interpretation" to_port="mod"/><br> <connect from_op="Python Learner" from_port="example set" to_op="Multiply" to_port="input"/><br> <connect from_op="Multiply" from_port="output 1" to_op="Generate Interpretation" to_port="training"/><br> <connect from_op="Multiply" from_port="output 2" to_op="Filter Example Range" to_port="example set input"/><br> <connect from_op="Filter Example Range" from_port="example set output" to_op="Generate Interpretation" to_port="test"/><br> <connect from_op="Generate Interpretation" from_port="example set" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> <description align="left" color="yellow" colored="false" height="64" resized="false" width="289" x="90" y="148">This tutorial process requires the package<br> Scikit-Learn.<br> </description><br> </process><br> </operator><br></process><br><br>
0