# Tag Info

Accepted

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

With np.isnan(X) you get a boolean mask back with True for positions containing NaNs. With ...
• 856

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

For anybody happening across this, to actually modify the original: X_test.fillna(X_train.mean(), inplace=True) To overwrite the original: ...

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

Assuming X_test is a pandas dataframe, you can use DataFrame.fillna to replace the NaN values with the mean: ...
• 191
Accepted

### Python stemmer for Georgian

I don't know any Georgian stemmer or lemmatizer. I think, however, that you have another option: to use unsupervised approaches to segment words into morphemes, and use your linguistic knowledge of ...
• 16k

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

Don't forget col_mask=df.isnull().any(axis=0) Which returns a boolean mask indicating np.nan values. ...
• 181

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

I faced similar problem and saw that numpy handles NaN and Inf differently. Incase if you data has Inf, try this: ...
Accepted

### One Hot Encoding for any kind of dataset

I would recommend to use the one hot encoding package from category encoders and select the columns you want to using pandas select dtypes. ...
• 5,601

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

Do not forget to check for inf values as well. The only thing that worked for me: df[df==np.inf]=np.nan df.fillna(df.mean(), inplace=True) And even better if you ...
• 141
Accepted

### Pandas dataframe, create columns depending on the row value

First we use DataFrame.explode to unnest your lists to rows. Then we use DataFrame.pivot_table to pivot your dataframe from ...
• 186
Accepted

### How is the GridsearchCV Score calculated?

The score is based on the scorer defined in the scoring argument. Meaning, the scorer can be any of the default metrics, such as precision, accuracy or F1-score (e.g., this); or a custom scorer. For a ...
• 172
Accepted

### Filling missing values for Embedded List in Python3

According to the suggestion, @bkshi gave to me I come up with a solution here below: Also since texts_to_sequences() function convert my list to sequences starting ...

### How to obtain unique count of categorical variable based on another categorical variable?

Try nunique(). That should do it. Here is a toy example: ...
• 4,877
Accepted

### Feature Importance from GridSearchCV

I think that you just need: feature_importances = rf_gridsearch.best_estimator_.feature_importances_ This provides the feature importance for all the attributes in ...

### Is it alright to split a GridSearchCV?

First my understanding of your problem. You want to find the best hyperparameters for a Random Forest. For that, you want to first adjust n_estimators parameter and then the rest of parameters in ...
• 5,601

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

In most cases getting rid of infinite and null values solve this problem. get rid of infinite values. df.replace([np.inf, -np.inf], np.nan, inplace=True) get ...

### How to use Cosine Distance matrix for Clustering algorithms like mean-shift, DBSCAN, and optics?

Several scikit-learn clustering algorithms can be fit using cosine distances: ...
• 16.9k
Accepted

### How to present Market Basket Analysis Results?

The best way to understand multiple association rules is to visualize them. This makes it even easier to present. This paper covers multiple approaches for visualizing association rules. Go through ...
• 2,155

### How to combine and separate test and train data for data cleaning?

Add an indicator column while concatenating the two dataframes, so you can later seperate them again: ...
• 186

### Python stemmer for Georgian

If absolutely necessary, You could build your own stemmer. It is fairly simple programming, but takes some studying of the Georgian language in the process, there are however plenty tutorials around ...
• 131
Accepted

### ValueError: Input 0 of layer conv2d is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape

The error message means that the input shape of Conv2D layer should be (128,128,1) which is consistent with your model summary. However, in the actual input the shape it finds is (128,128,3), hence ...
• 347
Accepted

### Beginning my data science journey

I too have a masters degree in physics so maybe you can relate! The first thing to do would be to get your fundamentals in python strong. Pick up a python beginners tutorial from Youtube and learn all ...
• 1,273

### Beginning my data science journey

I'm also a newbie in the DS world but one thing that I find really helpful which I highly recommend is to do a lot of work "by hand". All the model that you can use in DS or Machine Learning ...
Accepted

### PCA followed by UMAP then go into Random Forest

They are 3 different algorithms: they work better in parallel, rather than in series because they have different purposes. In addition to that, their output always brings some uncertainty (overall PCA)...
• 2,793

### ValueError: Input contains NaN, infinity or a value too large for dtype('float32')

Here is the code for how to "Replace NaN with zero and infinity with large finite numbers." using numpy.nan_to_num. df[:] = np.nan_to_num(df) Also see fernando's ...
• 131
Accepted

### Why does my GridSearchCV always break up?

First, you are fitting $5 \cdot 3\cdot2\cdot2\cdot2\cdot5=600$ models and n_estimator=500 is quite big. Of course, this depends on your dataset and in your computing power. My first guess will be ...
• 5,601

### How many trees does a Random Forest need?

My 2 cents: I'm fan of defying the max_leaf_nodes (in this example 5) and then visualizing it. I suggest starting at 3 and then increasing it slightly (the same applies for your Random Forest). In ...
• 977

### How many trees does a Random Forest need?

By other posts and this one seems what you don't have a clear intuition of the n_estimators of the random forest. I am going to assume that you are referring to the n_estimators (from this other ...
• 5,601

### Is it alright to split a GridSearchCV?

Edit: oh, now I think I see why @CarlosMougan said no. You said ...start the same GridsearchCV with the same parameter and just change... If you mean use the optimal values for all ...
• 9,751
Accepted

### Validation Loss is not decreasing - Regression model

the network architecture above is a very strange choice. When you have only 6 input features, it is weird to have so much Dense layers stacked. if network is overfitting, WHERE IS DROPOUT? Why not ...
• 278