<jupyter_start><jupyter_text>features<jupyter_code>df_train=df[df['target'].isnull()==False].copy()
df_test=df[df['target'].isnull()==True].copy()

print(df_train.shape,df_test.shape)
from lightgbm import LGBMClassifier,LGBMRegressor
from sklearn.model_selection import StratifiedKFold,train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import mean_squared_error

features=[x for x in df.columns if x not in ['target', 'target_count', 'target_max', 'target_min','target_variance','Place_ID']]
X,y=df_train[features].drop(['Place_ID X Date'],axis=1),df_train['target']
Xtest=df_test[features].drop(['Place_ID X Date'],axis=1)
bins=np.linspace(0, 1, 10) 
y_bin = np.digitize(y,bins)
y_bin


print(X.shape,Xtest.shape)
X_train,X_val,y_train,y_val = train_test_split(X,y,test_size=0.25,random_state = 1994,stratify=y_bin)
bins=np.linspace(0, 1, 50) 
y_bin = np.digitize(y,bins)
y_bin
# s.to_csv('colabtry4.csv',index=False) ,reg_alpha=1,reg_lambda=10
# s.target.describe()
err=[]
y_pred_tot=[]
from sklearn.model_selection import KFold,StratifiedKFold
fold=StratifiedKFold(n_splits=5,shuffle=True,random_state=1994)
i=1
for train_index, test_index in fold.split(X,y_bin):
    X_train, X_test = X.iloc[train_index], X.iloc[test_index]
    y_train, y_test = y[train_index], y[test_index]
    m=LGBMRegressor(n_estimators=10000,random_state=1994,learning_rate=0.03,num_leaves=50,boosting_type='gbdt',feature_fraction=0.6,
                objective='regression',min_child_samples=12)
    m.fit(X_train,y_train,eval_set=[(X_test, y_test)],eval_metric='rmse', early_stopping_rounds=200,verbose=400)
    preds=m.predict(X_test)
    print("err: ",np.sqrt(mean_squared_error(y_test,preds)))
    err.append(np.sqrt(mean_squared_error(y_test,preds)))
    p = m.predict(Xtest)
    i=i+1
    y_pred_tot.append(p)
np.mean(err)
np.mean(err)
np.mean(y_pred_tot,0)
test['Place_ID X Date']
s['target']=np.mean(y_pred_tot,0)
s
s.target.describe()
s.to_csv('zindi_colab_trylgbm13.csv',index=False)
from google.colab import files
files.download('zindi_colab_trylgbm13.csv') 
# from google.colab import files
# files.download('zindi_colab_trylgbm7.csv')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14679715302491103, 'fraction_numerical': 0.026245551601423486, 'mean_word_length': 8.370833333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '92606', 'license': 'Apache-2.0', 'n_tokens_mistral': 960, 'n_tokens_neox': 911, 'n_words': 115, 'path': 'Urban Air Pollution Challenge by #ZindiWeekendz/lgbm try1.ipynb', 'repo_name': 'rajat5ranjan/Zindi-Solutions', 'size': '2248'}