New answers tagged

1

Generally, the scoring metrics you are looking at are defined as following (see for example Wikipedia): $$precision = \frac{TP}{TP+FP}$$ $$recall= \frac{TP}{TP+FN}$$ $$F1 = \frac{2 \times precision \times recall}{precision + recall}$$ For the multi-class case scikit learn offers the following parameterizations (see here for example): 'micro': ...


0

A macro-average will compute the metric independently for each class and then take the average (hence treating all classes equally), whereas a micro-average will aggregate the contributions of all classes to compute the average metric. In your case as per your confusion matrix, Class 1 TP = 1 FP = 0 Class 2 TP = 1 FP = 1 Class 3 TP = 1 FP = 0 and the ...


0

GridsearchCV accepts multiclassification task automatically, same as XgbClassifier. As an example, something like this would work: xgb_model = xgb.XGBClassifier() parameters = {'max_depth': [6,7,8], 'seed': [1337]} clf = GridSearchCV(xgb_model, parameters, n_jobs=5, n_folds=5, shuffle=True), ...


0

Your question is not very clear: do you mean that your test data never contains this feature? If yes, you should remove this column from the training data. The train and test data must have the same features. If no, i.e. only some instances might not have a value for this column, then it's about having missing values in your data. In this case you could ...


1

The easiest way using scikit learn is this, where model is the variable holding your classifier. print(model.feature_importances_) But beware of using scikit feature importance! See here, it ranks random data very highly. The article proposes using Permutation Importance instead, as well as Drop-Column Importance. They created a library called rfpimp for ...


1

If you have only one example for certain classes SMOTE won't work. Most of the Machine Learning algorithms won't work either. There is a technique called One Shot Learning (it is normally used in computer vision) that "Whereas most machine learning-based object categorization algorithms require training on hundreds or thousands of samples/images and very ...


0

Since you seem to have the same number of rows per sample, perhaps the underlying process is such that it makes sense to treat the data as 2D or unpack into 12 features, as @Arnaud describes. (This seems to depend on the four rows being ordered according to some implicit rule?) More generally though, this is called "multiple instance learning." Probably ...


2

What about doing a concatenation of your rows (i.e. Attr1 -> Attr12) , such that you now have 3*4 features (because 4 rows of 3 features) as an input to a multiclass classification model? For instance, first sample would be described by : X = [1.1, 1.4, 2.5, 2.3, 2.5, 2.7, 1.1, 1.6, 1.9, 1.5, 1.6, 1.7] y = "A" Otherwise, there is no issue in giving 2D or ...


0

The second table is simply saying rows 1 - 4 are 4 different examples of class A, rows 5 - 8 are 4 separate example of class B and the rest are 4 examples of class C. Just modify the table so the target label column has 12 rows the first for having the value A, the next 4 having the value B and the final 4 having the value C. Good luck!


2

The issue is due to your lamda function with the tokenizer key word argument. >>> from sklearn.feature_extraction.text import TfidfVectorizer >>> from joblib import dump >>> t = TfidfVectorizer() >>> dump(t, 'tfidf.pkl') ['tfidf.pkl'] No issues. Now let's pass a lambda function to tokenizer >>> t = ...


0

Your problem can be considered as multiclass classification problem. So, you have a dataset of features X and the predictor y. Where X contain Income, age, sex,etc. and y is an item that one customer will buy with higher probability. To achieve your goal and predict the probability of a customer you can use any classifier from scikit-learn Library (if you ...


Top 50 recent answers are included