🚴‍♂️SciKit-Learn'e Giriş

Makine öğrenimi uygulamak için önceden hazırlanmış python paketine giriş.

❔ SciKit-Learn Nasıl Çalışır?

Tabloda verilen Estimator class yapısını kullanılır

👶 Scikit-Learn Basit Kullanım

from sklearn.linear_model import LinearRegression
lr = LinearRegression(fit_intercept=True, normalize=False)
lr.fit(X.reshape(-1, 1), y)
lr.coef_, lr.intercept_

predictions = lr.predict(X.reshape(-1, 1))
plt.plot(X, y, '.', label='data')
plt.plot(X, predictions, label='model')
plt.legend();

👨‍💻 Scikit-Learn PipeLine Kullanımı

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import PolynomialFeatures

pipe = Pipeline([
    ('polynomial_transform', PolynomialFeatures(3)),
    ('linear_fit', LinearRegression())
])

pipe.fit(X.reshape(-1, 1), y)

predictions = pipe.predict(X.reshape(-1, 1))
plt.plot(X, y, '.', label='data')
plt.plot(X, predictions, label='model')
plt.legend();

🦋 Genelleştirme Yapılması Durumunda SciKit-Learn Performansı

X = np.linspace(0, 4, 100)
y = X**exp + np.random.randn(X.shape[0])/10
predictions = pipe.predict(X.reshape(-1, 1))
plt.plot(X, y, '.', label='data')
plt.plot(X, predictions, label='model')
plt.legend()

🔗 Harici Bağlantılar

Last updated

© 2024 ~ Yunus Emre Ak ~ yEmreAk