Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

segmented-regression

Discontinuous segmented linear regression

Model finds split points by greedy minimization of total variance. Linear trend is eliminated while variance is calculated. Model require numpy and bottleneck for fast computations.

Examples

x = np.linspace(0., 5e8, 100000)
y = 1. - 1e-8*x
y[30000:] += 1.5
y[60000:] += 1.5
y[90000:] += 1.5
y += np.random.normal(scale=0.1, size=y.shape)

m = SegmentedRegression()
m.fit(x, y)
y_ = m.predict(x)
plt.plot(x, y, '.', alpha=.5, color='#999999')
plt.plot(x, y_, color='k')

alt text

x = np.linspace(0., np.pi, 100000)
y = np.sin(x)

m = SegmentedRegression(eps=1e-4)
m.fit(x, y)
y_ = m.predict(x)
plt.plot(x, y, '.', alpha=.5, color='#999999')
plt.plot(x, y_, color='k')

alt text

About

Discontinuous segmented linear regression

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages