Skip to content
Simple implementation (sklearn style) of a model to fit circular data
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Regression on circular data

This model is done to be able to do the principle of the linear regression but on circular data. It's using 3 differents methods coming from scipy implemented using sklearn naming.


Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.


No prerequisites are needed, you can download the repository or clone it.

git clone


No pip installation is available, you just have to include the package in you project folder.

How to use

The model has been build to be similar to sklearn model. As imple example is available below or in files.

import fit_circle

mdl = fit_circle.Circle_Regressor(method="leastsq")
X_1 = mdl3.fit_transform(X, y)

fig, axes = plt.subplots(figsize=(20,20))

axes.scatter(X, y, alpha =0.2, s=2)
axes.add_patch(plt.Circle(mdl._center, mdl._radius, color='g', ls= "--", lw=2, fill=False, label="Prediction"))
axes.scatter(*mdl._center, color='g', marker="+" )

The current model provides the following methods :

  • fit(X, y) : fit the model on the datas provided (must be 2 vectors of same shape)
  • transform(X, y) : transform the data to a (angle, radius) matrix of shape (N_elem, 2)
  • fit_transform(X, y) : apply fit then transform

and attributes after fit :

  • mdl._radius : an integer with the predicted radius
  • mdl._center : an tuple with the predicted center
  • mdl._error : a vector of (N_pts,) with all errors


A more detailed explanation of the model is available in the Notebook Fit_Circle. As it try to minimize the distance point to circle, you may end up with quite different prediction compare to the initial circle as you can see below.


This is related to the arc and noise of the data.


  • Nicolas MINE - Initial work - Coni63


There is no checks / error handling implemented yet. You should not provide a vectors with missing values.

You can’t perform that action at this time.