Skip to content

Comments

Rc 1.0 update#9

Draft
ihosten wants to merge 20 commits intomainfrom
rc-1.0_update
Draft

Rc 1.0 update#9
ihosten wants to merge 20 commits intomainfrom
rc-1.0_update

Conversation

@ihosten
Copy link
Collaborator

@ihosten ihosten commented Jul 21, 2025

  • implementation of lt1 identification method based on standard increment
  • implementation of lt1 identification method based on standard increment starting from the lowest registered lactate measurement
  • start of implementation of the log-log method --> still in the works

@ihosten ihosten changed the base branch from main to rc-1.0 July 21, 2025 12:14
@dierickxsimon dierickxsimon self-requested a review July 21, 2025 12:44
pw_fit = piecewise_regression.Fit(self.X, self.y, n_breakpoints=2)
pw_results = pw_fit.get_results()

if "breakpoint1" not in pw_results.get("estimates", {}):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also a good idea to add "breakpoint2"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with elif

self.y_raw_for_plot = y

# Ensure working on copies
self.X = np.asarray(copy.deepcopy(X))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need. is already implemented in the base class. np.array returns a copy of the data and not a reference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified (also for loglog, lt1_si_lowest, lt1_si, lt2 breakpoint



class LT1_loglog(BaseModel):
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class does not contain logic for the log log method

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modified the loglog and seems to work and give an acceptable outcome but peerreview is absolutely needed on this one!!!!!!

self,
X: ArrayLike,
y: ArrayLike,
si: float = 0.5,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si is not used inside this function

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for other classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved

si: the standard increment, defaults to 0.5

threshold_above_baseline (float, optional): Threshold above baseline
for filtering in the "modified" implementation. Defaults to 0.5.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no modified implementation inside this class

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solved

if si > 0 :
X, y = copy.deepcopy(X), copy.deepcopy(y)
y_lt1 = y[0] + si
self.y_lt1 = y_lt1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to add the lactate threshold as a instance based variable but should probably be defined in the base class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just a naming to keep the function easy to read, it uses the predefined working of the base class

else:
raise ValueError(f"Impossible lactate change to find LT1: {si}")

self.X = X
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

from lactopy.plots.lt2_breakpoint_plot import LT2_breakpoint_Plot


class LT2_breakpoint(BaseModel):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not needed already implemented in the LT1_LT2 breakpoint class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, was just a seperate extra can be deleted if we want, might be usefull for only determining 1 of the tresholds

Plot the lt1_loglog model fit.
"""
ax = super().plot_fit()
ax.set_title("LT1 Log-Log Model Fit")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need seprate titles for different plots. if so we should implement this in the base class and not in the all childeren to avoid tight coupling with maptlot lib

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^might be interesting yes

ax.set_title("LT1 Log-Log Model Fit")
return ax

def plot_predictions(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a rather reoccuring function in differen classes. i think we should add this logic in the base class

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

@dierickxsimon dierickxsimon marked this pull request as draft July 23, 2025 18:16
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the quickstart notebook is for the docs only change it for docs. if you want to create some test notebooks create one in notebooks/trash/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapted

@ihosten ihosten requested a review from dierickxsimon July 30, 2025 18:01
@ihosten ihosten marked this pull request as ready for review July 30, 2025 18:55
@dierickxsimon
Copy link
Owner

dierickxsimon commented Jul 31, 2025

just some general toughts we need to fix before we can merge this update:

  • make docstring accesible in de mkdocs
  • pytests
  • uncoupling with matplotlib is quick fixed (only tight coupling in base class) but should eventually be moved to a seprete graph builder. but we will moves this to a later update.
  • we should think about the return object of the prediction class to make it more clear wether the prediction is about the lt1 or lt2. in the lt1_lt2_breakpoint is now done with a named tuple but we should think about a more general solultion. (issue [FEAT] return object of prediction #12 )
  • personallyt im not that big of a fan of having lt1_lt2_breakpoint and a lt1_breakpoint class it think the lt1_breakpoint is not needed.
  • lt1_lt2_breakpoint and all other classes that use breakpoint should overwrite the base fit class. And change the plots so that the piecewise fitting is plotted and not the the general fitting methods.
  • the obla and the lt_1_si classes can also be merged to one
  • we should also think about custom exceptions for failed fittings that are special to the lactate models. so users can used these to use differen models. (can be done in an other PR) [FEAT] Custom exceptions #13

@dierickxsimon dierickxsimon marked this pull request as draft July 31, 2025 12:11
Base automatically changed from rc-1.0 to main October 29, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants