3 ms·
I am probably missing the point from lack of understanding of Linear Regression, but in the first example the Prolog code doesn't make sure the gradients are th
by jodrellblank 4y ago
I am probably missing the point from lack of understanding of Linear Regression, but in the first example the Prolog code doesn't make sure the gradients are the same, which means the Python code must be spitting out segments only within each linear grpah section. So isn't the Python code doing the actually hard work of separating the sections and the Prolog code doing a lot of work to find the cutoff points?
If so, would sorting the segments by start position first make it much easier? Start at the far left, go right merging the overlapping ones until there's one which doesn't overlap?
(Please don't name the graph axes X,Y and then use (X,Y) in the code for things which aren't X,Y data points - anything wrong with sticking to (I1, I2)? Why use "R" for span length? And what's "A"? And nitpick "(I1, I2)" is not a tuple in Prolog, it's a term and "I1-I2" is a more idiomatic and fewer parens term which can be used in the same way. It's what the imported pairs library uses, for example - https://www.swi-prolog.org/pldoc/doc/_SWI_/library/pairs.pl https://www.swi-prolog.org/pldoc/doc/_SWI_/library/pairs.pl )
- usgroup 4y agoThe first example —- with the linear regression —- is a toy problem which sets up the second example. I.e. the method works for both. You could solve the toy problem in much simpler ways in isolation but it wouldn’t help explain the second example.