machine-learning

How to do Cohen Kappa Quadratic Loss in Tensorflow 2.0?

痴心易碎 提交于 2021-02-18 08:16:14
问题 I'm trying to create the loss function according to: How can I specify a loss function to be quadratic weighted kappa in Keras? But in tensorflow 2.0: tf.contrib.metrics.cohen_kappa No longer exists. Is there an alternative? 回答1: def kappa_loss(y_pred, y_true, y_pow=2, eps=1e-10, N=4, bsize=256, name='kappa'): """A continuous differentiable approximation of discrete kappa loss. Args: y_pred: 2D tensor or array, [batch_size, num_classes] y_true: 2D tensor or array,[batch_size, num_classes] y

Exception in thread “main” java.lang.UnsatisfiedLinkError: no jep in java.library.path

若如初见. 提交于 2021-02-18 08:13:11
问题 I have 'libjep.so' file after downloading jep and I also had set the environmental variable LD_LIBRARY_PATH in ~./bashrc as shown below: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python2.7/dist-packages/jep/libjep.so as well as in runtime System.load("/usr/local/lib/python2.7/dist-packages/jep/libjep.so"); But when I have the follwing line in my code, Jep jep = new Jep(); It shows the below error: Exception in thread "main" java.lang.UnsatisfiedLinkError: no jep in java.library

Generate table with side-by-side node models of `partykit:mob()` object

有些话、适合烂在心里 提交于 2021-02-18 07:51:08
问题 Let's say I fit a model using partykit:mob() . Afterward, I would like to generate a side-by-side table with all the nodes (including the model fitted using the whole sample). Here I attempted to do it using stargazer() , but other ways are more than welcome. Below an example and attempts to get the table. library("partykit") require("mlbench") ## Pima Indians diabetes data data("PimaIndiansDiabetes", package = "mlbench") ## a simple basic fitting function (of type 1) for a logistic

scikits confusion matrix with cross validation

假装没事ソ 提交于 2021-02-18 06:42:42
问题 I am training a svm classifier with cross validation (stratifiedKfold) using the scikits interfaces. For each test set (of k), I get a classification result. I want to have a confusion matrix with all the results. Scikits has a confusion matrix interface: sklearn.metrics.confusion_matrix(y_true, y_pred) My question is how should I accumulate the y_true and y_pred values. They are arrays (numpy). Should I define the size of the arrays based on my k-fold parameter? And for each result I should

scikits confusion matrix with cross validation

戏子无情 提交于 2021-02-18 06:41:25
问题 I am training a svm classifier with cross validation (stratifiedKfold) using the scikits interfaces. For each test set (of k), I get a classification result. I want to have a confusion matrix with all the results. Scikits has a confusion matrix interface: sklearn.metrics.confusion_matrix(y_true, y_pred) My question is how should I accumulate the y_true and y_pred values. They are arrays (numpy). Should I define the size of the arrays based on my k-fold parameter? And for each result I should

Prediction is depending on the batch size in Keras

岁酱吖の 提交于 2021-02-18 05:13:51
问题 I am trying to use keras for binary classification of an image. My CNN model is well trained on the training data (giving ~90% training accuracy and ~93% validation accuracy). But during training if I set the batch size=15000 I get the Figure I output and if I set the batch size=50000 I get Figure II as the output. Can someone please tell what is wrong? The prediction should not depend on batch size right? Code I am using for prediction : y=model.predict_classes(patches, batch_size=50000

Prediction is depending on the batch size in Keras

断了今生、忘了曾经 提交于 2021-02-18 05:13:10
问题 I am trying to use keras for binary classification of an image. My CNN model is well trained on the training data (giving ~90% training accuracy and ~93% validation accuracy). But during training if I set the batch size=15000 I get the Figure I output and if I set the batch size=50000 I get Figure II as the output. Can someone please tell what is wrong? The prediction should not depend on batch size right? Code I am using for prediction : y=model.predict_classes(patches, batch_size=50000

How to avoid overfitting on a simple feed forward network

放肆的年华 提交于 2021-02-17 14:53:46
问题 Using the pima indians diabetes dataset I'm trying to build an accurate model using Keras. I've written the following code: # Visualize training history from keras import callbacks from keras.layers import Dropout tb = callbacks.TensorBoard(log_dir='/.logs', histogram_freq=10, batch_size=32, write_graph=True, write_grads=True, write_images=False, embeddings_freq=0, embeddings_layer_names=None, embeddings_metadata=None) # Visualize training history from keras.models import Sequential from

sklearn LabelBinarizer returns vector when there are 2 classes

青春壹個敷衍的年華 提交于 2021-02-17 12:45:16
问题 The following code: from sklearn.preprocessing import LabelBinarizer lb = LabelBinarizer() lb.fit_transform(['yes', 'no', 'no', 'yes']) returns: array([[1], [0], [0], [1]]) However, I would like for there to be one column per class: array([[1, 0], [0, 1], [0, 1], [1, 0]]) (I need the data in this format so I can give it to a neural network that uses the softmax function at the output layer) When there are more than 2 classes, LabelBinarizer behaves as desired: from sklearn.preprocessing

Get column name based on condition in pandas

[亡魂溺海] 提交于 2021-02-17 07:18:07
问题 I have a dataframe as below: I want to get the name of the column if column of a particular row if it contains 1 in the that column. e.g. For Row 1: Blanks, For Row 2: Manufacturing, For Row 3: Manufacturing, For Row 4: Manufacturing, For Row 5: Social, Finance, Analytics, Advertising, Right now I am able to get the complete row only: primary_sectors = lambda primary_sector: sectors[ sectors["category_list"] == primary_sector ] Please help me to get the name of the column in the above