- classmethod Line.best_fit(points: Union[numpy.ndarray, Sequence], tol: Optional[float] = None, **kwargs) skspatial.objects.line.Line ¶
Return the line of best fit for a set of points.
The line of best fit.
If the points are concurrent.
>>> from skspatial.objects import Line
>>> points = [[0, 0], [1, 2], [2, 1], [2, 3], [3, 2]] >>> line = Line.best_fit(points)
The point on the line is the centroid of the points.
>>> line.point Point([1.6, 1.6])
The line direction is a unit vector.
>>> line.direction.round(3) Vector([0.707, 0.707])