KNN Classification
Shubha
New Altair Community Member
Hi,
I run the below code given in the sample XML files (04_NearestNeighbours.XML) for the KNN Classification.
Why are the results not displayed?
Thanks,
Shubha
I run the below code given in the sample XML files (04_NearestNeighbours.XML) for the KNN Classification.
<operator name="Root" class="Process" expanded="yes">But the result I get is a blank KNNClassification model with the contents,
<description text="This learner uses a simple nearest neighbors classifier. This instance based classifiers just uses the other instances closest to the instance at hand in order to determine a prediction."/>
<operator name="ArffExampleSource" class="ArffExampleSource">
<parameter key="data_file" value="../data/iris.arff"/>
<parameter key="label_attribute" value="class"/>
</operator>
<operator name="NearestNeighbors" class="NearestNeighbors">
<parameter key="keep_example_set" value="true"/>
<parameter key="k" value="3"/>
</operator>
</operator>
and an id attribute added into the Exampleset.
KNNClassification
KNNClassification (prediction model for label class)
Why are the results not displayed?
Thanks,
Shubha
0
Answers
-
You created a model, but did not apply it to the dataset. Applying the model is what generates predictions. You need to add a ModelApplier node after creating the model. ry this instead:
<operator name="Root" class="Process" expanded="yes">
<description text="This learner uses a simple nearest neighbors classifier. This instance based classifiers just uses the other instances closest to the instance at hand in order to determine a prediction."/>
<operator name="ArffExampleSource" class="ArffExampleSource">
<parameter key="data_file" value="../data/iris.arff"/>
<parameter key="label_attribute" value="class"/>
</operator>
<operator name="NearestNeighbors" class="NearestNeighbors">
<parameter key="keep_example_set" value="true"/>
<parameter key="k" value="3"/>
</operator>
<operator name="ModelApplier" class="ModelApplier">
<list key="application_parameters">
</list>
</operator>
</operator>0 -
Thank you very much Keith... It helped.
I have one single question... Dont we get any 'values' like estimate values or any any distance values in the model? Because i just see the below in the model.
Thanks,ShubhaKNNClassification
KNNClassification (prediction model for label class)0 -
KNN is a "lazy" learner. It doesn't compute anything when it builds the model. It just saves the examples as reference points so that the nearest neighbors can be computed later when applied to other data. There are no distance computations, and the coordinates of the examples in the multidimensional space are just the attribute values of the examples.
In other words, there really isn't anything to show when the model is created, since all the heavy lifting is done at prediction time.
0