<jupyter_start><jupyter_text>LIGHT GBM RESGESYON<jupyter_code>!pip install lightgbm
# Yazılım dünyasında yeni çıkan herşey yüzde 90 daha iyi değildir. Yeni çıkan şeylerinde bir eskimesini beklemek gerekir.
# Yukarıdaki kurulumda hata olursa - conda için
# conda install -c conda-forge lightgbm
import numpy as np 
import pandas as pd 
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.metrics import mean_squared_error, r2_score
import matplotlib.pyplot as plt
from sklearn import model_selection
df = pd.read_csv("verisetleri\Hitters.csv")
df = df.dropna()
dms = pd.get_dummies(df[['League', 'Division', 'NewLeague']])
y = df["Salary"]
X_ = df.drop(['Salary', 'League', 'Division', 'NewLeague'], axis=1).astype('float64')
X = pd.concat([X_, dms[['League_N', 'Division_W', 'NewLeague_N']]], axis=1)
X_train, X_test, y_train, y_test =  train_test_split(X, y, test_size=0.25, random_state=42)
import lightgbm
from lightgbm import LGBMRegressor
lgb_model = LGBMRegressor().fit(X_train, y_train)
lgb_model.get_params()
y_pred = lgb_model.predict(X_test)
np.sqrt(mean_squared_error(y_test, y_pred))<jupyter_output><empty_output><jupyter_text>MODEL TUNNING<jupyter_code>lgb_model = LGBMRegressor()
lgb_model.get_params()
# PARAMETRELER NASIL SEÇİLİR

# Öntanımlı parametrelere bakarak, buradaki değerin etrafındaki değerler denenebilir.

lgbm_params = {"learning_rate" : [0.01, 0.1, 0.5, 1], "n_estimators" : [20, 40, 100, 1000], "max_depth" : [1, 2, 3, 4, 5, 6, 7 ,8 ,9, 10] }
lgbm_cv_model = GridSearchCV(lgb_model, lgbm_params, cv=10, n_jobs=-1, verbose=2).fit(X_train, y_train)
lgbm_cv_model.best_params_
lgbm_tuned = LGBMRegressor(learning_rate=0.1, max_depth=6, n_estimators=20).fit(X_train, y_train)
y_pred = lgbm_tuned.predict(X_test)
np.sqrt(mean_squared_error(y_test, y_pred))<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup