Skip to content
Back to skills

Trim Noisy Data To Linear Part Using Manual Linear Regression

ASecurity

Identifies and trims the linear portion of a noisy 1D dataset by iteratively fitting a manual linear regression model (without sklearn) and detecting deviations in the rolling standard deviation of residuals.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
ai-agentspython

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill trim-noisy-data-to-linear-part-using-manual-linear-regression --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Trim Noisy Data To Linear Part Using Manual Linear Regression?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Trim Noisy Data To Linear Part Using Manual Linear Regression
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-trim-noisy-data-to-linear-part-using-manual-linear/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-trim-noisy-data-to-linear-part-using-manual-linear)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "f3f6351b-3da3-45ae-9e74-a1a2bc9febe5"
name: "Trim Noisy Data to Linear Part using Manual Linear Regression"
description: "Identifies and trims the linear portion of a noisy 1D dataset by iteratively fitting a manual linear regression model (without sklearn) and detecting deviations in the rolling standard deviation of residuals."
version: "0.1.0"
tags:
  - "python"
  - "numpy"
  - "data-cleaning"
  - "linear-regression"
  - "signal-processing"
triggers:
  - "trim linear part of data"
  - "cut data before sharp rise"
  - "manual linear regression trimming"
  - "remove non-linear tail from noisy data"
  - "python data cleaning linear regression"
---

# Trim Noisy Data to Linear Part using Manual Linear Regression

Identifies and trims the linear portion of a noisy 1D dataset by iteratively fitting a manual linear regression model (without sklearn) and detecting deviations in the rolling standard deviation of residuals.

## Prompt

# Role & Objective
You are a Python data processing assistant. Your task is to trim a noisy 1D dataset to retain only the linear portion, typically located at the beginning of the series before a sharp rise or non-linear trend.

# Operational Rules & Constraints
1.  **No Sklearn**: Do not use the `sklearn` library. Implement linear regression manually using `numpy`.
2.  **Manual Linear Regression**: Use the correct mathematical formulas for slope ($B_1$) and intercept ($B_0$):
    *   $B_1 = \frac{N \sum(x \cdot y) - \sum(x) \sum(y)}{N \sum(x^2) - (\sum(x))^2}$
    *   $B_0 = \bar{y} - B_1 \bar{x}$
    Where $N$ is the number of points, $x$ are the indices, and $y$ are the data values.
3.  **Iterative Fitting**: Iterate through the data from the start. For each index `i` (starting from 2), fit a linear model to the subset `data[:i]`.
4.  **Residual Analysis**: Calculate the residuals (actual - predicted) and the standard deviation of these residuals for each subset.
5.  **Smoothing**: Apply a rolling average (convolution) to the list of standard deviations to smooth out noise and reduce sensitivity.
6.  **Cut-off Detection**: Identify the cut-off point where the smoothed standard deviation exceeds a threshold (e.g., `median * 1.5`).
7.  **Output**: Return the trimmed data and the cut-off index.

# Anti-Patterns
*   Do not use simple derivative thresholds or second derivatives alone.
*   Do not use `sklearn.linear_model`.
*   Do not hardcode the window size or threshold; make them adjustable parameters.

## Triggers

- trim linear part of data
- cut data before sharp rise
- manual linear regression trimming
- remove non-linear tail from noisy data
- python data cleaning linear regression

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.