machine-learning

Is dropout layer still active in a freezed Keras model (i.e. trainable=False)?

大兔子大兔子 提交于 2021-02-16 21:22:49
问题 I have two trained models ( model_A and model_B ), and both of them have dropout layers. I have freezed model_A and model_B and merged them with a new dense layer to get model_AB (but I have not removed model_A 's and model_B 's dropout layers). model_AB 's weights will be non-trainable, except for the added dense layer. Now my question is: are the dropout layers in model_A and model_B active (i.e. drop neurons) when I am training model_AB ? 回答1: Short answer: The dropout layers will continue

Extracting Information from the Decision Rules in rpart package

社会主义新天地 提交于 2021-02-16 20:58:13
问题 I need to extract information from the rules in decision tree. I am using rpart package in R. I am using demo data in the package to explain my requirements: data(stagec) fit<- rpart(formula = pgstat ~ age + eet + g2 + grade + gleason + ploidy, data = stagec, method = "class", control=rpart.control(cp=0.05)) fit printing fit shows n= 146 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 146 54 0 (0.6301370 0.3698630) 2) grade< 2.5 61 9 0 (0.8524590 0.1475410) * 3) grade>=2

Extracting Information from the Decision Rules in rpart package

送分小仙女□ 提交于 2021-02-16 20:58:06
问题 I need to extract information from the rules in decision tree. I am using rpart package in R. I am using demo data in the package to explain my requirements: data(stagec) fit<- rpart(formula = pgstat ~ age + eet + g2 + grade + gleason + ploidy, data = stagec, method = "class", control=rpart.control(cp=0.05)) fit printing fit shows n= 146 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 146 54 0 (0.6301370 0.3698630) 2) grade< 2.5 61 9 0 (0.8524590 0.1475410) * 3) grade>=2

Object of type 'ndarray' is not JSON serializable

不羁岁月 提交于 2021-02-16 15:50:28
问题 I am new to python and machine learning. I have a Linear Regression model which is able to predict output based on the input which I have dumped to be used with a web service. See the code below: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25) regression_model = LinearRegression() regression_model.fit(X_train, y_train) print(regression_model.predict(np.array([[21, 0, 0, 0, 1, 0, 0, 1, 1, 1]]))) # this is returning my expected output joblib.dump(regression_model, '..

Find the minma /valley points and get the index where the valley starts and valley ends in R

浪子不回头ぞ 提交于 2021-02-16 15:29:06
问题 I am kind of new to Statistics and R.I have a requirement to find the peaks and valleys and the index where the peak/valley starts and ends. For the Maxima/peak i got the findPeaks function which helps me with the peak requirement.But i am unable to find any packages for finding the valley points that suits my requirement. The following is the R function for finding the peaks. function (x, nups = 1, ndowns = nups, zero = "0", peakpat = NULL, minpeakheight = -Inf, minpeakdistance = 1,

Why does the standardscaler have different effects under different number of features

冷暖自知 提交于 2021-02-16 15:16:38
问题 I experimented with breast cancer data from scikit-learn. Use all features and not use standardscaler: cancer = datasets.load_breast_cancer() x = cancer.data y = cancer.target x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=42) pla = Perceptron().fit(x_train, y_train) y_pred = pla.predict(x_test) print(accuracy_score(y_test, y_pred)) result 1 : 0.9473684210526315 Use all features and use standardscaler: cancer = datasets.load_breast_cancer() x = cancer

Split autoencoder on encoder and decoder keras

只愿长相守 提交于 2021-02-16 14:48:10
问题 I am trying to create an autoencoder for: Train the model Split encoder and decoder Visualise compressed data (encoder) Use arbitrary compressed data to get the output (decoder) from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D from keras.models import Model from keras import backend as K from keras.datasets import mnist import numpy as np (x_train, _), (x_test, _) = mnist.load_data() x_train = x_train.astype('float32') / 255. x_train = x_train[:100,:,:,] x_test = x

random_state parameter in classification models

北城以北 提交于 2021-02-16 14:25:07
问题 Can someone explain why does the random_state parameter affects the model so much? I have a RandomForestClassifier model and want to set the random_state (for reproducibility pourpouses), but depending on the value I use I get very different values on my overall evaluation metric (F1 score) For example, I tried to fit the same model with 100 different random_state values and after the training ad testing the smallest F1 was 0.64516129 and the largest 0.808823529). That is a huge difference.

Macro metrics (recall/F1…) for multiclass CNN

拈花ヽ惹草 提交于 2021-02-16 13:20:29
问题 I use CNN for image classification on unbalance dataset. I'm totaly new with tensorflow backend. It's multiclass problem (not multilabel) and I have 16 classes. Class are one hot encoded. I want to compute MACRO metrics for each epoch: F1, precision and recall. I found a code to print those Macro metrics but it's only work on validation set From: https://medium.com/@thongonary/how-to-compute-f1-score-for-each-epoch-in-keras-a1acd17715a2 class Metrics(Callback): def on_train_begin(self, logs={

Batch size for Stochastic gradient descent is length of training data and not 1?

让人想犯罪 __ 提交于 2021-02-15 07:10:25
问题 I am trying to plot the different learning outcome when using Batch gradient descent, Stochastic gradient descent and mini-batch stochastic gradient descent. Everywhere i look, i read that a batch_size=1 is the same as having a plain SGD and a batch_size=len(train_data) is the same as having the Batch gradient descent. I know that stochastic gradient descent is when you use only one single data sample for every update and batch gradient descent uses the entire training data set to compute the