Skip to content

Power #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Power #28

wants to merge 2 commits into from

Conversation

Lesh79
Copy link
Collaborator

@Lesh79 Lesh79 commented Oct 31, 2024

Added new Power class for calculating the statistical power of change point detection (CPD) algorithms by analyzing CSV results stored in directories. Additionally, two new methods, to_csv and from_csv, are added to the CPContainer class to enable saving and loading of CPD results in a structured CSV format.

Usage:

# Initialize Power class with directory containing CSVs
power_calc = Power(root_path=Path("path/to/csv/folder"))

# Calculate the power of the CPD algorithm
power_value = power_calc.calculate_power()
print(f"Algorithm power: {power_value}")

@Lesh79 Lesh79 changed the title Add power Power Nov 3, 2024
Copy link
Collaborator

@alexdtat alexdtat left a comment

Choose a reason for hiding this comment

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

In general, as far as I understand it, we do not yet have a common vision of what hypotheses for power estimation should look like. But I think we will fix (with explanations) this option to start with.

@@ -0,0 +1,39 @@
from pathlib import Path
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add here docstring description of class, specifying tested hypotheses.

@staticmethod
def __checking_near_point(container: CPContainer):
"""Checks whether at least one change point is about the expected ones."""
margin = 50
Copy link
Collaborator

Choose a reason for hiding this comment

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

Imo it'd be better to make it a parameter.

return False

for detected in detected_points:
if any(expected - margin <= detected <= expected + margin for expected in expected_points):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems at least this if can be turned into boolean return. You can expand this further if you want, but that would probably degrade readability already. The main thing is to be careful with empty cases.

return False

def calculate_power(self):
"""Calculates the power of the algorithm based on hits about the disorder."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does it mean?

time_sec=mock_data["time_sec"],
)

# Инициализация Power и расчет мощности
Copy link
Collaborator

Choose a reason for hiding this comment

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

In English

with TemporaryDirectory() as temp_dir:
root_path = Path(temp_dir)

# Создание mock-файлов CSV
Copy link
Collaborator

Choose a reason for hiding this comment

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

In English

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