Category : scikit-learn

I’m perfoming a LinearRegression model with a pipeline and GridSearchCV, i can not manege to make it to the coefficients that are calculated for each feature of X_train. mlr_gridsearchcv = Pipeline(steps =[(‘preprocessor’, preprocessor), (‘gridsearchcv_lr’, GridSearchCV(TransformedTargetRegressor(regressor= LinearRegression(), func = np.log,inverse_func = np.exp), param_grid=parameter_lr, cv = nfolds, scoring = (‘r2′,’neg_mean_absolute_error’), return_train_score = True, refit=’neg_mean_absolute_error’, n_jobs = -1))]) ..

Read more

x_tr = SelectKBest(chi2, k=25).fit_transform(x_tr,y_tr) x_ts = SelectKBest(chi2, k=25).fit_transform(x_ts, y_ts) This is the code I have. I’m worried that it will select different features for the training and testing data. Should I change the code or will it give the same features? Source: Python..

Read more

I’ve trained a machine learning model using sklearn and want to simulate the result by sampling the predictions according to the predict_proba probabilities. So I want to do something like samples = np.random.choice(a = possible_outcomes, size = (n_data, n_samples), p = probabilities) Where probabilities would be is an (n_data, n_possible_outcomes) array But np.random.choice only allows ..

Read more