Questions tagged [machine-learning]

Implementation questions about machine learning algorithms. General questions about machine learning (concepts, theory, methodology, terminology, etc.) should be posted to their specific communities.

Machine learning revolves around developing self-learning computer algorithms that function by virtue of discovering patterns in data and making intelligent decisions based on such patterns.

Machine learning is a subfield of computer science that evolved from the study of pattern recognition and computational learning theory in artificial intelligence. Machine learning explores the construction and study of algorithms that can learn from and make predictions about data. Such algorithms operate by building a model from example inputs in order to make data-driven predictions or decisions rather than following strictly static program instructions.

NOTE: If you want to use this tag for a question not directly concerning implementation, then consider posting on Cross Validated, Data Science, or Artificial Intelligence instead; otherwise you're probably off-topic. Please choose one site only and do not cross-post to more than one - see Is cross-posting a question on multiple Stack Exchange sites permitted if the question is on-topic for each site? (tl;dr: no).

Classic Problems:

Relevant Algorithms:

Applications:

Software:

Related-tags:

Video Lectures:-

55241 questions
12
votes
2 answers

Tensorflow error: Using a `tf.Tensor` as a Python `bool` is not allowed

I am struggling to implement an activation function in tensorflow in Python. The code is the following: def myfunc(x): if (x > 0): return 1 return 0 But I am always getting the error: Using a tf.Tensor as a Python bool is not…
12
votes
2 answers

Is there a keras method to split data?

I think the title is self explanatory but to ask it in details, there's sklearn's method train_test_split() which works like: X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.3, stratify = Y) It means: the method will split…
CerushDope
  • 445
  • 1
  • 5
  • 14
12
votes
3 answers

What does train_on_batch() do in keras model?

I saw a sample of code (too big to paste here) where the author used model.train_on_batch(in, out) instead of model.fit(in, out). The official documentation of Keras says: Single gradient update over one batch of samples. But I don't get it. Is…
12
votes
1 answer

R: using ranger with caret, tuneGrid argument

I'm using the caret package to analyse Random Forest models built using ranger. I can't figure out how to call the train function using the tuneGrid argument to tune the model parameters. I think I'm calling the tuneGrid argument wrong, but can't…
Mark
  • 596
  • 1
  • 4
  • 14
12
votes
2 answers

TensorFlow ValueError: The channel dimension of the inputs should be defined. Found `None`

I am trying to implement a "Dilated Residual Network" as described in this Paper in TensorFlow (s. PyTorch Implementation here) to train it on the CityScapes Dataset and use it for Semantic Image Segmentation. Unfortunately I get an error when…
crossx
  • 137
  • 1
  • 1
  • 5
12
votes
3 answers

How to import pre-downloaded MNIST dataset from a specific directory or folder?

I have downloaded the MNIST dataset from LeCun site. What I want is to write the Python code in order to extract the gzip and read the dataset directly from the directory, meaning that I don't have to download or access to the MNIST site anymore.…
Joshua
  • 409
  • 1
  • 4
  • 12
12
votes
1 answer

Extract the coefficients for the best tuning parameters of a glmnet model in caret

I am running elastic net regularization in caret using glmnet. I pass sequence of values to trainControl for alpha and lambda, then I perform repeatedcv to get the optimal tunings of alpha and lambda. Here is an example where the optimal tunings for…
pd441
  • 2,644
  • 9
  • 30
  • 41
12
votes
1 answer

Adding an additional value to a Convolutional Neural Network Input?

I have a dataset of images I want to input to a Convolutional Neural Network Model, however, with each of these images, there is a range or distance from the object associated with the image. I want to input this range as an additional piece of…
12
votes
1 answer

Does dropout layer go before or after dense layer in TensorFlow?

According to A Guide to TF Layers the dropout layer goes after the last dense layer: dense = tf.layers.dense(input, units=1024, activation=tf.nn.relu) dropout = tf.layers.dropout(dense, rate=params['dropout_rate'], …
12
votes
2 answers

Returning probabilities in a classification prediction in Keras?

I am trying to make a simple proof-of-concept where I can see the probabilities of different classes for a given prediction. However, everything I try seems to only output the predicted class, even though I am using a softmax activation. I am new to…
user9040452
  • 231
  • 1
  • 2
  • 8
12
votes
2 answers

How to interpret output of .predict() from fitted scikit-survival model in python?

I'm confused how to interpret the output of .predict from a fitted CoxnetSurvivalAnalysis model in scikit-survival. I've read through the notebook Intro to Survival Analysis in scikit-survival and the API reference, but can't find an explanation.…
Max Power
  • 8,265
  • 13
  • 50
  • 91
12
votes
2 answers

How to get the weight vector in Logistic Regression?

I have a X feature matrix and a y label matrix and I am using binary logistic regression how can I get the weight vector w given matrix X feature and Y label matrix. I am a bit confused as to how achieve this within sklean. How do I solve the…
12
votes
1 answer

Which layers should I freeze for fine tuning a resnet model on keras?

I already know how to do it on vgg (fine tuning the last conv block) and inception (fine tuning the top two blocks). I'd like to know which layers is recommended to freeze in order to fine tuning a resnet model.
12
votes
1 answer

result of rpart is a root, but data shows Information Gain

I have a dataset with an event rate of less than 3% (i.e. there are about 700 records with class 1 and 27000 records with class 0). ID V1 V2 V3 V5 V6 Target SDataID3 161 ONE 1 FOUR 0 0 SDataID4 11 TWO 2 …
12
votes
7 answers

Split data directory into training and test directory with sub directory structure preserved

I am interested in using ImageDataGenerator in Keras for data augmentation. But it requires that training and validation directories with sub directories for classes be fed in separately as below (this is from Keras documentation). I have a single…