1
$\begingroup$

I have a data of 2000 (say locations of different fruits grow) and 10000 (say factors responsile for growth of fruits). And I also know that there are 20 different types of fruits in these locations. I want to built a logistic model for this dataset such that if I get a new location then my model should be able to define the type of fruit.

log_reg_model = LogisticRegression(max_iter=500,penalty='l2',solver='newton-cg')
log_reg_model.fit(neighborhoodClass,target)

The shape of neighborhoodClass is (2000, 10000) and the target is an integer array of 20 integer labels of length 2000.

I believe that some of these fruit types are dependent on each other that means If I see a fruit A at location l1 then there is a high chance that I also observe fruit B in nearby location to l1. That means fruit A and fruit B co-habitat in near proximity regions. Is there anyway I can add cross terms in logistic regression models to capture the neighborhood features? So that when I see a new location with different features my model should be able to tell the type of the fruit?

Thanks.

$\endgroup$

1 Answer 1

0
$\begingroup$

Those are typically called interaction terms.

It appears you are using scikit-learn. Interaction terms can be automatically be generated in scikit-learn with sklearn.preprocessing.PolynomialFeatures.

$\endgroup$
1
  • $\begingroup$ That was my thought when I read the title, but I believe that some of these fruit types are dependent on each other that means If I see a fruit A at location l1 then there is a high chance that I also observe fruit B in nearby location to l1 makes me think this is a multi-label problem where predicting one fruit means that we should also predict another fruit to appear with a high probability. $\endgroup$
    – Dave
    Jan 9 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.