New answers tagged

0

I use the module skimage, you can import it by: from skimage import data You can get imported the image to one variable like: picture_imported = imageio.imread('picture.jpg') But this variable is imageio.core.util.Array In order to get this as a ndarray just: picture = np.copy(picture_imported)


1

Let's clarify a few things first: The bagging technique is an ensemble method which is not specific to decision trees, it can be applied to any classification method. It's worth noting that there is another ensemble method specifically for decision trees, it's called Random Forest. While it's not the same method, it is known to generally improve performance ...


0

I hope you are aware of the fact that the default type of NumPy is float64 even if it is not required. In this case you can easily change it to 'float16' without losing information. It can reduce size by 30GB for 10 gestures. import numpy as np image_1 = np.ones((240,420)) image_2 = np.ones((240,420)) image_1 = image_1.astype('float16') import sys ...


0

If you restrict to the heavy-side function, the output is completely interpretable, see this explanation.


0

Non-linear models are very complex so that a single feature importance cannot be derived (in sense if I increase one feature the model will tend to a particular class). So saying if you increase one feature, the model will vote more for one class is not what you can expect, since the model is non-linear. For example, have a look at google playground and ...


1

You can use a Sigmoid function on the Force values(Scaled to [0-10] based on a max value) The Threshold should become 5 after scaling. def predict_proba(y_pred): y_pred = y_pred*10/100000 # scaled to [0-10] thresold = 5 proba = np.exp(y_pred - threshold)/(1 + np.exp(y_pred - threshold)) return proba predict_proba(100000), predict_proba(...


0

You can have a look into the literature about learning to rank, for example this work, which ensures reflexivity, is antisymmetric and transitive.


0

The main think you need to be mindful about is the size of the output of your convolutional layer, remember that it's going to be $$ \frac{W-K+2P}{S} + 1 $$ with your K the kernel size, so if you increase your kernel size the size of your output will decrease faster. You might have to reduce the number of layers. If you're using a framework for which you ...


1

Assuming that the "human readable" texts are more likely to contain actual words, you could count the number of dictionary words that occur in each. You could use Wordnet for example. The number or proportion of word hits, and their length, could be features for a model or maybe it would be enough with a simple cutoff rule. You might want to ...


2

You are thinking about this correctly. If data doesn't vary between your outcomes then it doesn't need to be included. That being said, if you are using time series techniques such as trend decomposition to feature engineer, then changing the structure of your data could complicate interpretation (ie: what is a moving average if you've removed data points?). ...


0

If your dataset is imbalance then you can calculate the kappa score.


0

You should use the same metric to evaluate and to tune the classifiers. If you wull evaluate the final classifier using accuracy, then you must use accuracy to tune the hyper parameters. If you think you should use macro-averaged F1 as the final evaluation of the classifier, use it also to tune them. On a side, for multiclass problems I have not yet heard ...


3

Overfitting is "The production of an analysis which corresponds too closely or exactly to a particular set of data, and may therefore fail to fit additional data or predict future observations reliably." (Oxford dictionary) When you fit a ML model, you use a dataset that you assume is a sample of the real statistical distribution you want to model. ...


3

The correlation does not effect your model using decision trees in a classification problem. In the theory of decision tree models, you don`t need correlation or check of multicollinearity. Because the split in decision trees is made of entropy/information gain. The correlation does only check linear dependencies. The same is, when the dataset is highly ...


0

You need only two hyperplanes to solve this. Thus you need two neurons in the hidden layer. You can use two or four neurons in the output layer. Both options result in the correct solution (theoretically). You can use perceptrons. With perceptrons, the output is a boolean vecotor, not a probability.


2

You could train a character-level language model, e.g. an LSTM, on the real short texts, and use the perplexity as the signal to know whether a piece of text is real or not. In order to find an appropriate perplexity threshold, you can have a look at the distribution of perplexities over a validation holdout dataset. UPDATE: There are multiple ...


0

Try making features like vowel_count, consonant_count, digitcount , vowel_density(vowel_count/total_length_of_words) Another wild thing - split the strigns with numbers and _ using regex and try to see if they are english words or not, use a pretrained model like spacy.english or nltk.words to check, make a column representing english words count if any. ...


2

Another possible solution is to use a L1 regularisation. A Lasso Regression can act as a proxy for a feature selection: since the derivative of the L1 norm is a step function, when training the model the weights associated with a given features will be either close or not from zero depending on their importance to predict the output. Moreover, sklearn has a ...


6

You may use Permutation importance - Get your base-line score - Permutate a feature values. May replace with Random values - Calculate the score again - The dip is the feature importance for that Feature - Repeat for all the Features ....Breiman and Cutler also described permutation importance, which measures the importance of a feature as follows. Record ...


2

This will depend on the algorithm/code that you are using. You are right that this is often not an important difference but that doesn't mean it can't create errors if you are using code which expects one or the other without being aware of it. You should equally keep track of data types such as integers vs floats which will similarly produce different ...


0

It's a general question, so there are more then a few things you can do. Although, what stopping you to train a basic clssifier and investigate the results? Some ideas: Use Predictive Power Score to keep on investigate your data Check for non-linear correlation between the features Investigation the features importance Use dimension reduction Check for ...


2

In the first code you split the data X randomly with this line: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 1) Then after training the model you correctly apply it to the test set, which is 20% of the instances: y_pred = xg.predict(X_test) Whereas in the second code you apply the model to the full data X ...


0

I would suggest you to use spacy and add your own custom labels for NER. https://spacy.io/usage/training/#ner


0

Your question is missing some details about your approach. So I will try to answer the question with the information given, and show you what are the missing information. Dataset You have depth images recording different gestures. Each image has a resolution of 240x420, and you have 200 images per gesture. I assume each image has one channel (depth). A ...


2

There are a number of ways to tackle this, I am going to focus on feature selection/extraction, because you mentioned PCA. Sklearn itself offers a few feature selection/extraction algorithms already, see here, like SelectKBest. This would mean for you to maybe select specific frames, or samples, or even pixels (unlikely). Further it has not only PCA but a ...


1

First thing that comes to my mind is to do different encodings. There are some ways to deal with high cardinality categorical data such as: Label Encoding or the famous target encoding. Before anything else I will recommend changing the encoding type. But, since your question about which predictor use with small and space data. I will go still with logistic ...


1

You can use a total variation regularizer (https://en.wikipedia.org/wiki/Total_variation_denoising), it's a penalty for abrupt changes of neighbor values. It's usually used for images, that's why its TF version (https://www.tensorflow.org/api_docs/python/tf/image/total_variation) operates with 4D tensors, but if you're writing your model in pytorch for ...


0

If your network outputs a vector $x \in \{0,1\}^N$ with $N=100$ and $\sum_{i = 1}^{N} x_{i}= 1$, you could consider weights $\mathbf{W}=(w_{i}) \in \mathbb{R}^{N}$ with $w_{i} :=i$ for $i \in \{1,\ldots,100\}$. Then, for prediction vector $x$ and ground-truth vector $y$, you could use the loss function $L(x,y):= || \mathbf{W}^{T}x - \mathbf{W}^{T}y || = || \...


3

You are looping on a folder to predict each image - for filename in os.listdir(image_path): pred_result = model.predict(images) images_data.append(pred_result) filenames.append(filename) But the argument of the predict function is not changing. Its a stacked value defined above as - images = np.vstack(images) This same prediction is being ...


0

I can't tell but I'd look into these 3 options to tell what's wrong : Image Loading is wrong ? check that each loaded image has different data in it Model is wrong ? check that what is outputed by model.predict actually varies Post Processing is wrong ?


2

This is my simple approach. We can approximate $F_{1\text{ Score}}$ and its uncertainty by K-Fold cross validation. We do the same with other model and use T-test to compare their results ($F_{1 \text{ Score}}$). It would be advisable to maintain the same partitions. For the second question (number of test samples), I would use this formula from confidence ...


4

I think there are two primary possibilities for answers, so I'll try to address both of them: (Recommended) If you have multiple independent trials per classifier: This is a lot simpler than if you have only one trial per classifer (and much better). If you have multiple $F_1$ scores per classifier, then you can simply conduct a paired t-test or a Wilcoxon ...


0

In general it is better to have a good mix of positive and negative labels for a model to learn from. That said, many classification problems suffer from significant label imbalance (e.g. fraud detection). I don't see an obvious problem with a 70/30 mix of labels, but as you start modeling be sure to check the confusion matrix and look for where you model ...


0

Please try using yellowbrick This library has amazing viz tools and is almost perfectly incorporated with Sklearn estimators (The only thing is that does not handle are Pipelines)


0

The thresholds don't matter; what matters are the (FPR, TRP) values at those thresholds, as they are points on the curve. Sort them by FPR ascending. For this to work out, you'll want to include the points (0,0) and (1,1) in your list, corresponding to thresholds 1 and 0. You can use a trapezoidal approximation, as each successive pair of points defines a ...


0

If I understand correctly you don't have your target and want to create it using associacion rules. Fp-growth algorithm already reduces itemset checks e.g. based on the fact that if a certain itemset doesn't match selected threshold any other superset of this itemset won't match it either. For this reason it is several times faster than apriori. If you want ...


1

Your description is apt. There isn't anything especially "mathematical" happening here, aside from the AdaBoost algorithm itself. In psuedocode, something like this is happening: For n in 1 .. N_Estimators do Train classifier Tn on data X with weights W Compute weighted residuals E from Tn Update W based on E Renormalize W end In your case,...


1

Interpretability of log loss Log loss isn't necessarily between the range [0; 1] - it only expects input to be in this range. Take a look at this example: $$ y_{pred} = 0.1 \\ y_{true} = 1.0 \\ log\_loss = -(log(y_{pred}) * y_{true} + (1 - y_{true}) * log(1 - y_{pred})) = -(log(0.1) * 1.0) = 2.302 $$ In an extreme case log loss can even be equal to infinity. ...


0

Kudos to @Nicholas to have put myself on the right way. The specific answer on why this was not working with the Corpora model is due on what I guessed over time. The corpus2csc was kind of compressing/forgetting some details. The solution is to specify the length of the dictionary when transposing the values. Therefore, from X = corpus2csc(unseen_vectors)....


1

The general answer is how the model will be used deal. Either way may be optimal for the case. For example - If the model groups applicants into good credit risk and bad credit risk, that might be fine to say model score > x = good risk and model score <= x = bad risk. But maybe there will be differential action based on the model score - like giving a ...


0

There is an example of this here: https://iaml.it/blog/optimizing-sklearn-pipelines


2

My understanding is: The first line is OK - it derives from Bayes Rule Assume that this probability follows a logistic function, that is that $$P(C_1|x) = \frac{1}{1+exp(-a)}$$ Then if $$ y = \frac{1}{1+exp(-z)}$$ then $$ z = ln(\frac{y}{1-y})$$ (some lines below but with $a$ and $\sigma$) Therefore: $$ a = ln(\frac{P(C_1|x)}{1-P(C_1|x)})$$ If there ...


0

Give cross-validation or bootstrapping a shot! Also, for metrics, look at per class performance and macro averaged.


1

This sounds like a normal supervised classification task. Have you tried other standard methods like Support Vector Machines, RandomForests, Gradient Boosting, kNN, Neural Networks etc. as well or is there a particular reason why you only tried clustering methods. Clustering methods like kmeans or spectral clustering are usually used in an unsupervised ...


4

You need to use the same preprocessing elements (dictionary etc) that you used to create your tfidf matrix during training when you come to apply your model to unseen data. Do not create a new dictionary, tfidf_model, etc. for the unseen data, or else the dimensionality of the data you are passing to your model may not be the same. you will lose the ...


1

I can think of these possible solutions: The basic one, club the whole data and try different algorithms and evaluate the results. If Age distribution among the different samples(data set) are not proportionally distributed, i.e. if your dataset have huge samples of 'Young' in comparison to 'Adult' one or vice-versa, then I definitely try to tune my model ...


0

Hope this link would help you. It is always better to have more data, so concatenating the data sources would at least slightly increase the performance of you model than it used to be.


0

Yes, teaching the model to expect a balanced distribution definitely will impact the results on the test set. Oversampling the minority class to balance the distribution will make the classifier more likely to predict that a given example is the minority class. Each iteration of gradient descent will push the model to a location where approximately half of ...


0

Seems to me the best way to do this is to train a single model on all of your data and let it sort out the features that distinguish one data set from another. If you don't know in advance which set you're getting data from, you can't know which model to choose so having more than one would limit you


1

Add all data together, and make sure you have features representing all possible insights. In your case one feature with age/maturity (young, adults...). Lets say you fit a decision tree (or Random Forest, gradient boosting...) the model will decide whether to do a split or not on this feature if it contains meaningful information. If you combine you should ...


Top 50 recent answers are included