# Buku "Python untuk GIS", Bab 12: Kotak Perkakas Tambahan: Pustaka Ilmiah
# scipy dan scikit-learn: statistik dan pembelajaran mesin
import numpy as np
from scipy.optimize import curve_fit

x = np.array([1.0, 2.0, 3.0, 4.0])
y = np.array([2.1, 3.9, 6.2, 7.8])


def garis(x, a, b):
    return a * x + b


(a, b), _ = curve_fit(garis, x, y)
print(round(float(a), 2), round(float(b), 2))
