def regressionPrediction(self, transformedInstance: Instance, selectedAttributes: List[bool], coefficients: List[float]): result = 0 column = 0 for j in range(transformedInstance.numAttributes()): if self.m_ClassIndex != j and selectedAttributes[j]: result += coefficients[column] * transformedInstance.value(j) column += 1 result += coefficients[column] return result
def convertInstance(self,instance:Instance): inst=instance hasMissing=instance.hasMissingValue() if hasMissing: vals=[0]*self.getInputFormat().numAttributes() for j in range(instance.numAttributes()): if instance.isMissing(j) and self.getInputFormat().classIndex()!=j \ and (self.getInputFormat().attribute(j).isNominal() or self.getInputFormat().attribute(j).isNumeric()): vals[j]=self.m_ModesAndMeans[j] else: vals[j]=instance.value(j) inst=Instance(instance.weight(),vals) inst.setDataset(instance.dataset()) self.push(inst,not hasMissing)