New answers tagged

0

The main assumption in supervised learning is that the training set is a representative sample of the space of all possible instances for the problem. This is why in the regular classification setting there is simply no way to consider a "not in any class" option: what the model learns is to distinguish between the classes seen in the training set, ...


0

In general this would mean that P predicts only a small number of instances higher than 0.9 whereas R predicts most instances higher than 0.9. Therefore a weighted average of the two scores will fall somewhere in the middle, likely resulting in a moderate precision and moderate recall. This can give significantly better results but only if the two ...


1

torch.argmax has an extra argument dim which you can specify such that the maximum value is taken over a specific dimension. If you specify the dimension which represents the number of images it will return an array of indices where each value is for one image. For example: import torch # 3 images with 5 classes t = torch.randn(3, 5) # tensor([[-1.2917, 1....


4

You need {0,1} or {-1,1} labels depending on the output of your model. If you have a Sigmoid output use {0,1}, while TanH outputs work with {-1,1}. No label choice is inherently right or wrong, as long as it's compatible with your model architecture and gives you good results. EDIT: In case of logistic regression you must use {0,1}, that is because this ...


0

This can be done by using inverse transformation theorem import numpy as np import pandas as pd from sklearn.datasets import make_classification from sklearn.preprocessing import QuantileTransformer def make_gausssians_binary_classification(n_samples= 1000, n_features= 5, ...


2

Generally, I'd pick a very simple, transparent/explainable model and use the results in a semi-automated way. That is, do not just derive a prediction but rather insights. You could, for example, use a (or multiple) decision tree(s) which you pre or post prune. The result could be a tree with, let's say, just 1-3 features to find simple rules like "if a ...


0

I have had the same problem while training in huge data sets in Jupyter Notebooks. The only solution I found was to create a scrip .py with my training process (including model persistence) and running it from my terminal (python3 myscript.py)


0

It would mean that the model trained with some irrelevant features is overfit: a good model uses only features which have some predictive power on the target variable, so if the sample is representative enough any irrelevant feature is ignored or assigned very little weight. However if the training dataset is too small or the model too complex then it uses ...


1

The main problem with very little data is that it's almost impossible to know how representative the sample is. Some people would even say that less 20-30 data points cannot be representative of anything. Every single data point can have a huge impact on any model, so any prediction has a huge margin of error. If one is going to train a model from a tiny ...


0

Depending on the library you use you should be able to create a checkpoint of your model every few iterations so that you dont lose your models in the event of a crash. If you are unlucky enough to encounter a crash, you can always begin retraining from the latest available checkpoint. That way you don't start from scratch. Good Luck on your internship.


0

My team created a PyPi package called Happy Transformer. Happy Transformer is built on top of Hugging Face's Transformers library to provide a simple interface to implement Transformer models. I suggest you take a look at the text classification section. https://happytransformer.com/ https://github.com/EricFillion/happy-transformer


1

F-score calculated by f_classif can be calculated by hand using the following formula shown in the image: Reference video Intuitively, it is the ratio of (variance in output feature(y) explained by input feature(X) and variance in output feature(y) not explained by input feature(X)). Example : Using sklearn code for f_classif from sklearn.feature_selection ...


0

Clearly your exercice is not very clear, at least it is not to me. I guess you should consider $I$ as the variance or std deviation of the variable, just make sure that is a parameter of your code so you can change it later in case it is not what you assumed it was. Check up in your course if it corresponds to something, but it doesn't seem anything familiar ...


0

So, the question is asking for advice on what to do next, given the model's performance. Firstly, in terms of confusion matrices, it is often useful to display proportions, rather than number of examples. It makes it easier for us to gauge where the error is occurring. Looking at the most recent confusion matrix, it is clear that a lot of the examples are ...


0

Perhaps you can see if Graduated_high_school is correlated in any way to GPA_college? If there is no correlation, you can try to fit a model by dropping the Graduated_high_school column. Else, you can try to drop rows belonging to under-represented high schools. However, one problem I foresee is that future predictions might have Graduated_high_school that ...


1

There are probably many different strategies but it's a difficult problem when the imbalance is as severe as it is here. Without any correction the model is likely to ignore the smallest classes, as you noticed. However forcing the class weight as if the data is balanced is certainly too strong a correction. A middle ground would be to resample the training ...


1

you need to define how many time steps you want to have in each time series block. then for each unique patient, you need to create these blocks so the training set going to be a 3D matrix, and the dimensions are: number of blocks * number of time steps * number of features in addition to time series data, you can also add another head to feed NN with the ...


0

There is no obstacle to doing this. For example you can create data by make_classification, and compare different algorithms by building model on it. You can also pass a random_state value to obtain same data each time you call the function. Both SVM, and Decision Trees can work with continuous data.


0

I believe this could help someone. The problem was that the output classes were randomly assigned. My classes are called: 0,1,2,3,4...,22. However, DataGenerator assigned output '5' to class 13, output '7' to class 15, and so on. Hence, the classes were shuffled. It is important to assign the output to each class.


1

You need to first define the model. Once you have defined the model, then, instantiate a class of it. Once that is done, use model.load_state_dict(torch.load(path_to_model_file)).


1

Got the very same error recently. Your network is usually defined as a class (here class EfficientNet(nn.Module). It seems when we load a model, it needs the class to be defined so it can instantiate it. In my case, the class was defined in the training .py file. So what I did to fix that error was just copy-paste (it seems importing it didn't work for me, ...


0

Yes, the classifier will expect the relative class frequencies in operation to be the same as those in the training set. This means that if you over-sample the minority class in the training set, the classifier is likely to over-predict that class in operational use. To see why it is best to consider probabilistic classifiers, where the decision is based on ...


0

If you are working on a real application, then the way in which to evaluate performance depends on what is important for the operational use of the model. For many practical problems the misclassification costs for false-positive and false-negative errors are different (e.g. for a medical screening test a false-positive is likely to be a much less serious ...


-2

Undersampling should mostly not be preferred because it causes a huge amount of data loss. In the end, we are giving so much effort to collect data and it basically does not make sense when we throw them away. The issue is here is that you lose samples where your model could learn new things. Oversampling usually works better as you observed but the problem ...


0

Everybody understands how to perform $k$-fold cross-validation but there is often quite a lot of confusion about where/how to use it. So thanks for this good question :) First, cross-validation is a statistical method for evaluation, not for training: Of course training is performed during cross-validation, but it is performed $k$ times and therefore there ...


1

Wouldn't remove similar looking observations unless you have a strong reason to do so. By deleting similar looking observations you may be adding bias into the underlying distribution responsible for generating the data. Your model may be misled into learning a biased distribution and that may affect final performance. To start with use the entire dataset as ...


0

Yes it is possible. For 3000 classes classification, we use a network with 3000 outputs and then apply a softmax function. here is the link to a VGG paper, a CNN used to perform 1000 classes classification.


0

The reason you get predictions without an exact time is because that is how models are trained. They are not trained to predict the exact time but a window for it. The reason a model is not trained to predict exact time is because it introduces a lot of problems starting with data imbalance and the huge number of classes it would introduce. Also, DL/AI is ...


0

It depends on the problem you are working on. If number of categorical variables is very large, it is better to use label encoding. But the label encoding should be meaningful i.e. the categories which are close to each other should get similar labels. Let's say you are creating a model where you have a feature Month. But there is a periodicity in your ...


0

...Because the Keras documentation does not specify the keys for the class_weights.. You may get an idea with these two parameters, labels: Either "inferred" (labels are generated from the directory structure), or a list/tuple of integer labels of the same size as the number of image files found in the directory. Labels should be sorted according ...


0

Are both the candidates and values to be estimated? Or is it only the candidates. If it's only the candidates, then try using a classification model. You can then use the predicted class probabilities as weights on the candidate values to arrive at a final values for your entities.


0

I suggest hugging face is a good try although I have little experience using it. If it ultimately does not work well, you can also try NLTK, gensim and SpaCy. They are all widely used in NLP. Here is a demo notebook that I found: https://www.kaggle.com/thebrownviking20/topic-modelling-with-spacy-and-scikit-learn Hope it helps and best luck to your ...


0

The recommendation is going to be still Huggingface transformers. You extract the features from BERT, then, some dense layers and then, feed them into sigmoid layer with unit equal to number of classes. Pose it as a multi-label classification.


0

The view classification (front, back, ...) is the easier part as you have the correct labels in your dataset. I would do it using transfer learning : pick a pre existing image classification model (such as VGG or Res-Net) and freeze it (parameters.require_grad = false in pytorch layer.trainable = false in keras), remove the last classification layers and ...


1

It should work: the variable is ordinal so using numerical values makes sense. So there's a bug somewhere, here are a few suggestions of things to look at: Possibly a type conversion error somewhere: make sure the variable is interpreted as numerical. Check whether the model actually uses the variable: if not then it's likely some type error; if yes then I ...


0

Yes but your training and testing sets should be different in each run otherwise I don't see how you can interpret the result. As Jayaram said, the best practice is always do a K-fold cross validation.


0

Yes, you can try k-fold validation, where indicidual models are generated from various subsets of the data and performance measured on a validation set. You can the compute the average and variance of model accuracy, other performance metrics to understand how stable your model is.


0

Every Machine Learning Problem is different, so there is no standard answer to your question. For the problem you're working on maybe a 70-30 train-test split would result in an optimal model which performs equally well on the test dataset, whereas for another problem may be that ratio just won't do any justice to the model. It's all about experimentation. ...


0

Your model is decent. Predictions are better than random chance. Macro average is a simple average of the performance measures (precision, recall etc) across all classes/labels. Micro average is a weighted average of the same , where the weights are based on the number of samples per class/label (support column).


0

You could convert your categorical outputs back into their numeric equivalents, and then use the confusion matrix and normal


Top 50 recent answers are included