Skip to content
Advertisement

Tag: scikit-learn

Unable to convert tensorflow.python.framework.ops.Tensor object to numpy array for passoing it in sklearn.metrics.cohen_kappa_score function

I thought of implementing kappaScore metrics using sklearn.metrics.cohen_kappa_score Error I get when I try to run this code: Here the type of y_true and y_pred requires to be in list or numpy array But the type of y_true and y_pred are, When directly try to print it (i.e, without type() function), it shows like this: Unable to use y_true.numpy() (Convert

trying to callibrate keras model

I’m trying to calibrate my CNN model by Sklearn implementation CalibratedClassifierCV, tried to wrap it as KerasClassifier and to override the predict function but without success. someone could say me what I did wrong? this is the model code: this is me trying to calibrate it : the output : valX_cnn and val_y_cnn are of type np.array. tried even to

“Not enough values to unpack” in sklearn.fit

Here’s the piece of the code: This says: The train and test datasets had been prepared before, and they behave nicely with other classifiers. Such a generic error message tells me nothing. What is the problem here? Answer In short, the issue was that you passed the result of skf.split(titanic_dataset, surv_titanic) to the cv argument on LogisticRegressionCV when you needed

How to change colors for decision tree plot using sklearn plot_tree?

How to change colors in decision tree plot using sklearn.tree.plot_tree without using graphviz as in this question: Changing colors for decision tree plot created using export graphviz? Answer Many matplotlib functions follow the color cycler to assign default colors, but that doesn’t seem to apply here. The following approach loops through the generated annotation texts (artists) and the clf tree

Calculating hamming distance in a given year

I have a following dataframe: I would like to calculate pairwise hamming distance for each pair in a given year and save it into a new dataframe. Example: (Note: I made up the numbers for the hamming distance, and I don’t actually need to Pair column) I tried something like: Answer The function pairwise_distances can take in a matrix, so

Fixing points as non-outliers during outlier detection in Python

I found this Scikit Learn page explaining how to use different algorithms to detect outliers: https://scikit-learn.org/stable/modules/outlier_detection.html Is it possible to set a group of instances as non-outliers so that the algorithms understand that those specific points should not be detected as outliers? Answer If you have enough so called non-outliers for training, one option is to use Novelty detection with

Advertisement