How to Find Height and Weight from a Data Set Using Simple Linear Regression in Weka?
Share
Condition for Finding Height and Weight using Simple Linear Regression in Weka
Description: Linear regression is used to predict one variable based on another by finding the best-fit relationship between them. The model is trained using existing data, and once trained, it can predict a value for a new input. In this case, it predicts height based on the given weight.
Evaluation evaluation = new Evaluation(dataset);
int numFolds = Math.min(dataset.numInstances(), 10);
evaluation.crossValidateModel(model, dataset, numFolds, new Random(1));
System.out.println(evaluation.toSummaryString());
double[] newInstanceValues = new double[dataset.numAttributes()];
newInstanceValues[0] = 172; // Example height
newInstanceValues[dataset.classIndex()] = 0; // Placeholder value for weight
Instance instance = new DenseInstance(1.0, newInstanceValues);
instance.setDataset(dataset);