3

From my understanding you are working on a regression task in which you have applied MainMaxScaler to your target variable y prior modeling. If so you have two options: As the error message suggests, you can reshape the output with array.reshape(-1, 1) Scikit learn has implemented a class to work with transformations on target: So just try from sklearn....


2

You can just compute: $\hat{b}_0 = \operatorname{mean}(y-cx)$


2

As far as I know you cannot add the model's threshold as hyperparameter but in order to find the optimal threshold you can do as follows: make a the standard GridSearchCV but use the roc_auc as metric as per step 2 model = DecisionTreeClassifier() params = [{'criterion':["gini","entropy"],"max_depth":[1,2,3,4,5,6,7,8,9,10],&...


2

According to the sklearn.svm.SVR documentation, the negative $R^2$ value indicates that your model is arbitrarily worse than the trend line on trainY. By default you should check the following: Does your model have a bias/intercept? If not you may observe negative $R^2$. Is testY derived from your training data? Am I using a linear function to fit the data? ...


2

A $R^2$ that is that low tells you that your model is not good. Therefore, you can both make it positive and nearer to 1 by : a) getting better/more data, or b) picking a better model for your data. Also, it'd be more helpful to plot the true/pred values against the underlying $X$ values and not just as a sequence.


2

This depends on what you want to show. When working with metrics you shouldn't just take the value as is, but see what each metric are telling you. baseline_1 isn't better/worse than baseline_0 because it has a higher/lower value in metric X. Both baselines give an interesting perspective on a given dataset and if unsure I'd suggest keeping both. A couple of ...


1

Do the labels have to start from 0? No it doesn't matter where they start as long as they have distinct values. Do the labels have to be sequential? Well it depends from the feature. For example if you have features that are showing order of magnitude, like small<big<vast, then yes the order matters and they are called ordinal features, but if the ...


1

This is indeed expected behavior, because of the way tree models handle multioutput problems. The nodes contain some number of samples, and the score for each output is the average of those samples' corresponding output. Since averaging commutes with sums, the property of summing to 1 is preserved. I'm not sure if this will help, but in symbols: $$ \sum_{\...


1

Because cost_complexity_pruning_path refits the tree model on the data you provide before doing the pruning (source), you need to preprocess the data first. So this should do it: X_preproc = final_pipe[:-1].transform(X_train) path = final_pipe.steps[-1][1].cost_complexity_pruning_path(X_preproc, y_train)


1

When imputing data, one is looking not to modify the true distribution of your data. So a way to test how good your imputation was is to make a test to contrast the true distribution of every feature that has been imputed vs the true (via KS test for example) distribution of the feature (prior imputing) if you can sate with a level. of confidence that your ...


1

IsolationForest doesn't work on Euclidean distance. Hence [0,0] is almost as good as [100,100] It builds random Trees on the dataset and expects that the Outlier will singled-out very early in the Tree while the Inliers will go deep. With that logic, it can figure out the Outlier. The IsolationForest ‘isolates’ observations by randomly selecting a feature ...


1

First of all, the score_samples function of SKLearn's Kernel Density object returns the log of the probability density, not of probability. Therefore, its exponent isn't exactly probability - e.g. in your example you have a probability above 1, which can't be. Second, apparently the log-probability-density is normalized by the number of points the kernel was ...


1

According to my understanding PCA requires that you have the column of equal length, so you either need to shorten the longer columns (basically just skip the incomplete observations) or fill in the gaps in the shorter columns. If you choose the second option, you'll need to learn about the concept of imputation (see the following link for reference ...


1

The c (small one) term is bias or intercept added to the model. This is similar to intercept we add in case of linear regression. The library allows you to set bias term to zero too. When set to multinomial model, the cost function will try to minimize cross-entropy loss. Hard for me to write down the equation here, but I always go back to this useful ...


1

It seems very unlikely that centering would hurt, and so I'd suggest just to do it anyway. Theoretically, in a generalized linear model with regularization, no, centering won't change anything. This is because the intercept term can absorb any changes; shifting $x$ by 100 can simply be rewritten: $$ 15 + 0.2*(x-100) = 15 - 0.2\cdot100 + 0.2x = -5 + 0.2x,$$ ...


1

The reason is the same. I assume you understand how the Features at a very different scale can create issue But just scaling will not always bring them on the similar scale because Standard Deviation is dependent on the Range of the Feature. So, if a feature is very large but in a small range then simply scaling it will not help. Let's check an example ...


1

Instead of using pairwise_distances you can use the pdist method to compute the distances. This will use the distance.cosine which supports weights for the values. import numpy as np from scipy.spatial.distance import pdist, squareform X = np.array([[5, 4, 3], [4, 2, 1], [5, 6, 2]]) w = [1, 2, 3] distances = pdist(X, metric='cosine', w=w) # change the ...


1

Overall, scikit-learn is designed to be not inefficient but it's goal is not hyperefficiency. If your goal is hyperefficiency then you should switch to a different machine learning package. The goal of scikit-learn is to provide a high level interface with machine learning and handle the implementation details "under the hood". That is why there is ...


1

You are on the right path. It appears you might have analysis paralysis. You should start building, then see what works and what does not work. Here is code to get you started: from sklearn.ensemble import RandomForestRegressor from sklearn.feature_selection import VarianceThreshold from sklearn.model_selection import GridSearchCV from ...


1

You might looking for sklearn.ensemble.VotingRegressor which takes the mean of two regression models. Here is an example to get you started: from sklearn.datasets import make_regression from sklearn.decomposition import PCA from sklearn.ensemble import GradientBoostingRegressor, RandomForestRegressor, VotingRegressor from sklearn....


1

As far as I know, scikit-learn has no library for ensemble clustering. On the other hand, you can apply the method on your dataset as follows: import numpy as np import ClusterEnsembles as CE kmeans1 = np.array([1, 1, 1, 2, 2, 3, 3]) kmeans2 = np.array([2, 2, 2, 3, 3, 1, 1]) kmeans3 = np.array([4, 4, 2, 2, 3, 3, 3]) kmeans4 = np.array([1, 2, np.nan, 1, 2, ...


Only top voted, non community-wiki answers of a minimum length are eligible