Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
174 views
in Technique[技术] by (71.8m points)

scipy - Python: Cubic Spline Regression for a time series data

I have the data as shown below. I want to find a CUBIC SPLINE curve that fits the entire data set (link to sample data). enter image description here

Things I've tried so far:

  1. I've gone through scipy's Cubic Spline Functions, but all of them are only able to give results at a single time only, whereas I want a single curve for the entire time range.

  2. I plotted a graph by taking an average of the spline coefficients generated by scipy.interpolate.splrep for a 4 number of knots, but the results were not good and didn't solve my purpose.

Things that can help me:

  1. An idea about how to optimize the number and position of knots for a better fit

  2. If not that, then if someone can help me find the exact polynomial coefficients for the Cubic Splines for a given number of knots.

  3. If someone can suggest a complete way to solve this problem.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I made a 3D scatterplot of the data, converting the timestamps to "elapsed time in seconds" from the first timestamp, the image is below. It appears to me that the data has a sort of 3D equivalent of an outlier, here shown as an entire line of data that is considerably below most of the other data. This will make creating a 3D surface fit of any kind difficult.

scatterplot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...