# Linear and logistic regression - Reply 3

**URL:** <https://swi-prolog.discourse.group/t/linear-and-logistic-regression-reply-3/7071>\
**Category:** Split Topic\
**Created:** [December 15, 2023, 1:15pm UTC](https://swi-prolog.discourse.group/t/linear-and-logistic-regression-reply-3/7071 "2023-12-15T13:15:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![emiruz](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/emiruz/32/4495_2.png) [@emiruz](https://swi-prolog.discourse.group/u/emiruz)\
**Post date:** [December 15, 2023, 1:15pm UTC](https://swi-prolog.discourse.group/t/linear-and-logistic-regression-reply-3/7071/1 "2023-12-15T13:15:20Z")

</div>

@friguzzi

Another option is to use Python’s sklearn via Janus which also offers many other common data science algorithms.

---

<div class="post-metadata">

**Author:** ![felix.weitkaemper](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/felix.weitkaemper/32/7760_2.png) [@felix.weitkaemper](https://swi-prolog.discourse.group/u/felix.weitkaemper)\
**Post date:** [December 17, 2023, 9:27am UTC](https://swi-prolog.discourse.group/t/linear-and-logistic-regression-reply-3/7071/2 "2023-12-17T09:27:38Z")

</div>

Of course it is. I think it’s helpful to have a Prolog implementation though, as one can tinker with it very easily to try things out (in my case, experimenting with combinations of logistic and noisy-or regression).  
Using the Prolog matrix library will always restrict scalability, so locally I usually replace the matrix library with a C implementation called via the FLI (that I had set up before there was Janus).  
The pure Prolog version runs on SWISH though, which is a big plus.

---

<div class="post-metadata">

**Author:** ![emiruz](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/emiruz/32/4495_2.png) [@emiruz](https://swi-prolog.discourse.group/u/emiruz)\
**Post date:** [December 17, 2023, 3:52pm UTC](https://swi-prolog.discourse.group/t/linear-and-logistic-regression-reply-3/7071/3 "2023-12-17T15:52:49Z")

</div>

Would you mind saying a bit about what you use noisy-or for in the context of Prolog?

---

<div class="post-metadata">

**Author:** ![felix.weitkaemper](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/felix.weitkaemper/32/7760_2.png) [@felix.weitkaemper](https://swi-prolog.discourse.group/u/felix.weitkaemper)\
**Post date:** [December 17, 2023, 10:09pm UTC](https://swi-prolog.discourse.group/t/linear-and-logistic-regression-reply-3/7071/4 "2023-12-17T22:09:46Z")

</div>

Sure! It’s not exactly about Prolog though, rather about _probabilistic_ logic programming.  
In a probabilistic logic program, every (grounding of a) clause fires with a certain probability. So if you have clauses

```prolog
0.2 :: alarm :- earthquake.
0.5 :: alarm :- burglary

```

that express that a burglary is 50% likely to trigger an alarm and an earthquake is 20% likely to trigger it, then in a situation of a burglary during an earthquake the probability of an alarm is 0.6, which is computed by considering both events to be independent. This is the “noisy-or” of 0.2 and 0.5.  
Learning and inference for such probabilistic logic programs is implemented in Prolog by Fabrizio Riguzzi’s cplint suite.  
Now I am currently working in a hybrid domain of both Boolean and continuous variables for an application, and one way (of several) of adapting this framework is by making the probability annotation of a clause a function of the continuous body atom. The logistic function is an obvious way to do that, so that leads me to fitting such a mixed noisy-or-logistic regression.
