Add AR Calculator Module
Prompt
Add an AR (Auto-Regressive) calculator module to the existing TimeseriesAnalysisProject GitHub repository, ensuring it is implemented similarly to the existing MA (Moving Average) module without introducing any new dependencies. Your task is to extend the project by creating an AR calculator that fits seamlessly with the current codebase, follows the established coding style and conventions, and integrates into the analysis workflow like the existing MA calculator. # Steps 1. **Review Existing MA Module:** - Examine the current MA calculator code within the project to fully understand its structure, methods, and integration points. - Note how input data is handled, parameters are configured, and outputs are generated. 2. **Implement AR Calculator Class/Module:** - Using the same style and architectural patterns as the MA module, implement the AR calculator. - Ensure you only use already existing dependencies in the project (likely numpy, pandas, standard libraries). - The AR calculator should be able to take time series data and calculate auto-regressive values based on a chosen lag parameter. 3. **Integrate AR Calculator:** - Add the AR calculator to the same place(s) in the project where the MA calculator is referenced and invoked. - Modify or extend any interface (e.g., command line options, configuration files) that should allow users to select AR calculation, mirroring how MA is selected. 4. **Add Testing/Validation:** - Create or extend unit tests similar to those for MA to verify the correctness of your AR implementation. - Test with sample datasets to ensure AR behaves as expected. 5. **Documentation:** - Add comments and docstrings in your AR calculator code consistent with existing project style. - Optionally update README or related documentation to mention the new AR calculator feature. # Output Format Provide detailed step-by-step instructions combined with complete code snippets for the AR calculator and integration changes. Code should be clearly commented and formatted to match the existing project style. # Examples If the MA calculator class looks like this: ```python class MovingAverageCalculator: def __init__(self, window_size): self.window_size = window_size def calculate(self, series): return series.rolling(window=self.window_size).mean() ``` Then the AR calculator could be analogous, for example: ```python class AutoRegressiveCalculator: def __init__(self, lag): self.lag = lag def calculate(self, series): # Implementation details here without new dependencies pass ``` Replace `pass` with the suitable AR calculation logic using pandas or numpy. # Notes - Do not add any new external libraries. - Maintain consistency with the existing project structure. - Assume you have access to current project code for reference and modification. - Follow best practices for Python coding style and documentation. Execute the task with clear guidance and code samples enabling the addition of a working AR calculator similar to the MA module in the TimeseriesAnalysisProject repository.
Related Coding Prompts
Write Code
As a seasoned programmer, your task is to write code in [programming language] to [perform action]. The code should be efficient, well-structured, and optimized for performance. Make sure to follow best practices and industry standards while implementing the necessary algorithms and logic to achieve the desired functionality. Test the code thoroughly to ensure it functions as intended and meets all requirements. Additionally, document the code properly for future reference and maintenance.
Debug Code
Act as a seasoned programmer with over 20 years of commercial experience. Analyze the provided [piece of code] that is causing a specific [error]. Your task involves diagnosing the root cause of the error, understanding the context and functionality intended by the code, and proposing a solution to fix the issue. Your analysis should include a step-by-step walkthrough of the code, identification of any bugs or logical mistakes, and a detailed explanation of how to resolve them. Additionally, suggest any improvements or optimizations to enhance the performance, readability, or maintainability of the code based on your extensive experience. Ensure that your solution adheres to best practices in software development and is compatible with the current development environment where the code is being executed.
Do Code Review
As a seasoned programmer with over 20 years of commercial experience, your task is to perform a comprehensive code review on the provided [piece of code]. Your review should meticulously evaluate the code's efficiency, readability, and maintainability. You are expected to identify any potential bugs, security vulnerabilities, or performance issues and suggest specific improvements or optimizations. Additionally, assess the code's adherence to industry standards and best practices. Your feedback should be constructive and detailed, offering clear explanations and recommendations for changes. Where applicable, provide examples or references to support your suggestions. Your goal is to ensure that the code not only functions as intended but also meets high standards of quality and can be easily managed and scaled in the future. This review is an opportunity to mentor and guide less experienced developers, so your insights should be both educational and actionable.