score:4
Well if your model is outputting a zero probability for a given class, then the log probability for that class is negative infinity. So if you're summing over probabilities in the log space (or otherwise need this value), then obviously you can't work with this.
For this to occur in Random Forest, it means all of the trees are agreeing that the probability of this particular class for that particular data point is zero. You could mitigate this by increasing the number of trees (which would increase the chance at least one of them says that this example falls into that class). Or you could reduce the max_depth
parameter to perhaps similar effect.
Alternatively you could just soften the outputs of your model before applying the logarithm, for instance by setting the output probabilities to min(max(p, 0.001), 0.999).
Hope that helps.
Credit To: stackoverflow.com
Related Query
- Sklearn RandomForestClassifier predict_log_proba divide by zero error
- Sklearn RandomForestClassifier predict_log_proba divide by zero error
- python divide by zero encountered in log - logistic regression
- Sklearn Python Log Loss for Logistic Regression evaluation raised an error
- Random Forest Regression MAPE Divide by Zero error after MinMax Scaling
- MLE Log-likelihood for logistic regression gives divide by zero error
- python divide by zero encountered in log - logistic regression
- Sklearn Python Log Loss for Logistic Regression evaluation raised an error
- Random Forest Regression MAPE Divide by Zero error after MinMax Scaling
- MLE Log-likelihood for logistic regression gives divide by zero error
- Unbalanced classification using RandomForestClassifier in sklearn
- Using sklearn cross_val_score and kfolds to fit and help predict model
- Error when trying to import sklearn modules : ImportError: DLL load failed: The specified module could not be found
- Error using sklearn and linear regression: shapes (1,16) and (1,1) not aligned: 16 (dim 1) != 1 (dim 0)
- Error in if(ncol.matrix < rep) {: argument is of length zero
- Load and predict new data sklearn
- Call predict function for nearest neighbor (knn) classifier with Python scikit sklearn
- Python sklearn RandomForestClassifier non-reproducible results
- Chi Square Analysis - expected frequencies has a zero element at (0,). error
- RandomForestClassifier was given input with invalid label column error in Apache Spark
- error in GridsearchCV sklearn
- sklearn - Predict each class's probability
- Find out error rate using sklearn
- error with sklearn CalibratedClassifierCV and SVM
- Sklearn Pipelines: Value Error - Expected number of features
- Is log loss in XGBoost and Sklearn the same?
- Root mean log squared error issue with scitkit-learn.ensemble.GradientBoostingRegressor
- How to get both predicted value and error metric in sklearn
- Python SKLearn fit Value Error Input
- Trying to use TSNE from sklearn for visualizing my high dimensional data , but getting import error
- Scikit-Learn issues error for RandomForestClassifier for multilabel classification - Jagged arrays
- Unknown label type error when Sklearn naive bayes used with floating point numbers
- Sklearn RandomizedSearchCV OSError: [Errno 5] Input/output error
- Why sklearn Random Forest takes the same time to predict one sample than n samples
- matlab predict function error with fitrtree model
- Error message when using predict with LARS model on testdata
- Why I'm getting this error while executing KernalPCA method present in decomposition module of sklearn
- I am attempting to use Python MultinomialNB from sklearn to classify some data but it returns a Value Error
- Incrementally fitting sklearn RandomForestClassifier
- Sklearn model coefficients and predict mismatch in linear_model
- Getting an error with random forest model using sklearn
- How to use trial and error algorithm to predict the next number in a sequence?
- sklearn SGDClassifier can not make it train or predict deterministically
- Python SKlearn contamination must be in (0, 0.5] error
- How can I check feature values for a predict value in sklearn
- Sklearn predict function
- NumPy log function throws attribute error for int
- Error using BayesSearchCV from skopt on RandomForestClassifier
- Simultaneously predict fields with sklearn
- Error by creating my own scorer with make_scorer in sklearn
More Query from same tag
- SOM multiple BMU, need to work on one random one or all of it
- Difference between fine-grained and coarse-grained score for WSD tasks?
- mutual information and prediction accuracy
- Why doesn't ID3 algorithm work on the UCI Mushroom dataset in Weka?
- Classification report in scikit learn
- Stuck with input/output shapes in keras, lstm
- OpenCV SVM: Update a trained SVM
- CNN on tfidf as input
- Saving and loading of Keras model not working
- Very basic Keras CNN with 2 classes giving inexplicable answers
- Support Vector Machine Primal Form Implementation
- How to stop variables from being updated?
- Splitting training and test data
- Why loading a model takes so much time for me in R?
- How to use ROC curve
- Supervised Machine Learning algorithms
- Whether to use Caffe or Theano for Moore-Penrose Pseudo inverse?
- ValueError: The features to the model returned by input_fn must have static shape, using TPU Estimator API
- one hot encoding of output labels
- Machine Learning Algorithm Android Spell Check and Auto Correct
- Evaluate Loss Function Value Getting From Training Set on Cross Validation Set
- split() missing 1 required positional argument: 'y'
- How to know the factor by which a feature affects a model's prediction
- Keras imageGenerator Exception: output of generator should be a tuple (x, y, sample_weight) or (x, y). Found: None
- How to get coefficients and feature importances from MultiOutputRegressor?
- Primer on TensorFlow and Keras: The past (TF1) the present (TF2)
- keras datagen.flow_from_directory class mode categorical get labels wrong
- Keras. ValueError: I/O operation on closed file
- Difference between image dataset representation in Tensorflow and Theano
- Noisy validation loss in Keras when using fit_generator
- Writing a confusion matrix function taking positive class as an input
- Tensorflow Keras MNIST get probabilities of prediction
- Counting multiple instances of an object in an image using machine learning
- Is there hope for using Lasagne's Adam implementation for Probabilistic Matrix Factorization?
- Function to determine a reasonable initial guess for scipy.optimize?