New answers tagged

0

This should work, you dont need to append. def meanEmbeddings(model, words): # remove out-of-vocabulary words words = [word for word in words if word in model.vocab] if len(words) >= 1: return np.mean(model[words], axis=0) else: return []


2

Remember, that in higly imbalanced data model does not learn anything as it minimises its objective function just by predicting everything to majority class. Yes Sample weight values you have assigned seems to do the right thing. What sample weight does is tweak the objective function to consider one error in predicting True class equivalent to 20 error in ...


0

My own investigation on this forum and on SKLearn bug reports and forums is that the core of the problem - that SKLearn decision tree classifier does not handle categorical or sparse data - has been complained about for some years with no important changes to the code in this respect. Three approaches suggest themselves. Firstly, expand out the tuples to non-...


0

As stated in the docs, the KNeighborsClassifier from scikit-learn uses minkowski distance by default. Other metrics can be used, and you can probably get a decent idea by looking at the docs for scikit-learn's DistanceMetric class


0

Scikit-learn MLPRegressor has a .partial_fit method for training on batches which will overcome this memory issue.


0

Machine learning models take vectors (arrays of numbers) as input. When working with text, the first thing you must do is come up with a strategy to convert strings to numbers (or to "vectorize" the text) before feeding it to the model. The performance of a Machine Learning Model not only depends on the model and the hyperparameters but also on how ...


1

These string data, called categorical data can be converted to numerical data using many Categorical Encoding Techniques. Encoding categorical data is a process of converting categorical data into integer format so that the data with converted categorical values can be provided to the different models. Types of Categorical Techniques: Backward Difference ...


1

You can multiple things here : Converting them to numerical introduces some sense of ordering For example if you say slovenia is 1 and USA is 2 ans ordering is introduced instead you can use one hot encoding. Pandas getdummies function will do it for you If one of your string has a lot of values say 1000 one hot encoding does not makes sense. In those ...


0

In the explicit looping approach the scores (and the best score from it) is being found using models trained on X_train. In the LassoCV approach the score is computed from the model built on X_calib (the full dataset) using the best alpha found during the cross-validation. I missed the (obvious?) fact that the final model in LassoCV is found using the &...


0

+1 to Craig for the answer to the actual question. But I want to address two other remarks from your post. ...the class probability of sklearn random forest does not seem correct. Because for sklearn random forest, the sizes of classes of the training set determines the class probabilities of a single tree and the class probabilities of the random forest. ...


0

More data is not always better. How do you know it is unsatisfactory to not consider older data? In your case it might actually improve the performance of your model. I would pefer one of the first two suggested methods, and see what their effect is on your performance indicator(s) compared to the time-naive baseline. As a side note, do you have any clue ...


2

For the question - Why the performances of weka random forest and sklearn random forest are similar but they use different methods to compute class probabilities of an input instance? Often different algorithms will have similar results. This is not surprising. If you run the data through a GBM or logistic regression (with the proper feature engineering) ...


0

You should probably transpose your x array since the first dimension should correspond to the number of samples in your dataset, currently the first dimension represents the number of features instead of the number of samples. The following should work: import numpy as np from sklearn.model_selection import train_test_split # generate random data with same ...


0

The problem seems to be that you are dividing by 10 (k) at each iteration, I can think to try to calculate the average, this is incorrect and probably it is what is causing you to see a very low metric value. It would be simpler and correct, to only store the values for the metric in each iteration at the validation set and finally just calculate the average ...


1

$$R^2_{out}=\dfrac{\sum \big( y_i-\hat y_i \big)^2 }{ \sum\big( y_i-\bar y_{in} \big)^2 } $$ If your out-of-sample performance (measured by squared residuals) is worse (bigger) than performance of a naïve model that always predicts the in-sample mean of $y$, then your out-of-sample $R^2_{out}<0$. This is not unique to polynomial regression.


0

The scores you are seeing indicate that a linear regression would with multiple polynomial features does not fit the data well, with performance decreasing drastically on new data when using features polynomial features of degree 5/6 and higher (likely because of overfitting and/or multicollinearity). R-squared can be negative, for what this exactly means ...


0

In scikit-learn, PCA has the fit_transform method which fits and applies the dimensionality reduction to the training data. There is also transform which only applies the dimensionality reduction. With new unknown samples, use transform.


0

From the info you provide, I think you can do: average the test scores you get from your splits instead of printing per split, or use the cross_validation_score option given by sklearn, and then average such scores: cross_val_score(clf, X, y, cv=5).mean(), or use the sklearn GridSearchCV class, with which you can access the details of your cross ...


0

As per my experience, It didn't drop any columns. It replaced the name of the columns from actual column names to 1, 2, 3... To put the actual column names after the imputation imp = SimpleImputer(missing_values = np.nan, strategy = 'most_frequent') imp.fit(df) df = pd.DataFrame(imp.transform(df), columns = df.columns)


0

In response to: However, in the final line (asking for predictions) I get an error--"dimension mismatch"--because the dimension is entirely different. Of course the dimensions are different--this is a different set of tweets. How can I fix this problem? While of course this is a different set of tweets, what that error message is really saying is ...


0

Apparently the reason I was getting worse performance was because I was using cross validation during HP tuning but not when I built the base model. Hence the issue. Another mistake was not scaling my data! Typical noob mistakes!


Top 50 recent answers are included