I tried several things to find the best regression model with the best parameters but i can't go higher than 40% right predictions.
So i have 67741 rows in an excel file. the data looks like this after cleaning (4 columns only , is it enough ?) :
and the target rows like this :
I'll try to explain my process .
I went to this website https://scikit-learn.org/stable/tutorial/machine_learning_map/index.html. From this graph the models that should suit my data are Lasso and ElasticNet, i got very bad score with this code :
classifiers = [
ElasticNetCV(cv=5, random_state=0,max_iter=40000), # i added the max_iter cause i got a warning saying that i should increase it
linear_model.Lasso(alpha=0.1,max_iter=40000)] # i added the max_iter cause i got a warning saying that i should increase it
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.33, random_state=42)
for clf, param in zip(classifiers, param_grid):
name = clf.__class__.__name_
clf.fit(X_train, y_train)
print("=" * len(name))
print("{}".format(name))
print(clf.score(X_test, y_test))
The scores:
============
ElasticNetCV
0.002404878871672067
=====
Lasso
0.0066801704903023396
Then i tried several other models and i finally got something with:
BaggingRegressor(base_estimator=DecisionTreeRegressor(),
max_features=0.5, max_samples=0.5)
Score :
================
BaggingRegressor
0.3460147571634854
So i used GridSearch and then cross validation score to get the best parameters but every time i launch it i got a different result something like that :
BaggingRegressor(base_estimator=DecisionTreeRegressor(), bootstrap=True,
bootstrap_features=False,
max_features=0.2, max_samples=0.7, n_estimators=10,
n_jobs=None, oob_score=False, random_state=None, verbose=0,
warm_start=False)
i used this that way :
param_grid = [{'max_samples': [0.1, 0.2, 0.5, 0.7, 1],
'max_features': [0.1, 0.2, 0.5, 0.7, 1],
'n_estimators': [5,10,15,20,25]}
def grid_search(clf, param_grid):
grid_search = GridSearchCV(clf, param_grid, cv=5)
grid_search.fit(X, y)
print(grid_search.best_estimator_)
print("=" * len(name))
print(grid_search.best_params_)
print("=" * len(name))
print(grid_search.best_score_)
and cross validation like that : scores = cross_val_score(clf, X, y, cv=10)
Sorry if it's a bit long, with 67000 rows i can't get something more than 30% correct predictions ? what's the problem ?
Thank you