# Tag Info

1

The first issue seems to be in the following block of code: # Calculating the roc curve for each class changing the pos_label value fpr_cl0, tpr_cl0, _ = roc_curve(iris_y_test, y_test_prob[:,1], pos_label = 0) roc_auc_cl0 = auc(fpr_cl0, tpr_cl0) fpr_cl1, tpr_cl1, _ = roc_curve(iris_y_test, y_test_prob[:,1], pos_label = 1) roc_auc_cl1 = auc(fpr_cl1, tpr_cl1) ...

0

Yes, it is the right way to proceed. Basically, you've got a map from $(X,Y)$ (e.g. latitude, longitude geographic coordinates), onto a value $Z$ (e.g. geographic altitude). K-nearest neighbours is an algorithm that helps efficiently to find out the K closest points to a given target, that can be any random $(X,Y)$ point different from the initial data set, ...

1

Can I conclude that the error at my node is 60 +-13 i.e my values in this particular sample split ranges from 60-13 to 60+13. No you cannot, because the actual error values depend on the data. For example you might have 1 instance with error 41.11 and 9 instances with error 0: $$MSE=\frac{41.11^2+0^2+...+0^2}{10}=169$$ This example shows that the only ...

1

The documentation says: random_state : int, RandomState instance, default=None Controls the randomness of the estimator. The features are always randomly permuted at each split, even if splitter is set to "best". When max_features < n_features, the algorithm will select max_features at random at each split before finding the best split among ...

0

I don't feel like previous answers answered the question at all. So I'll give a quite comprehensive explanation with two concrete use case at the end. Normalizer normalizes rows (samplewise), not columns (featurewise). It totally changes the meaning of data because the distributions of resulting feature values are totally changed. Therefore, a scenario where ...

1

It would seem that you are over-interpreting what is essentially just convenience shorthand names for the model arguments, and not formal terminology; here, "‘ls’ refers to least squares regression" should be interpreted as "'ls' is the loss function used in least-squares regression". Formally you do have a point of course - sse would be ...

1

Note that the algorithm is called Gradient Boostign Regressor. The idea is that you boost decision trees minimizing the gradient. This gradient is a loss function that can take more forms. The algorithm aggregates each decision tree in the error of the previously fitted and predicted decision tree. There you have your desired loss function. This parameter is ...

1

As of October 2020... In terms of basic neural network functionality, they are pretty equivalent. Some differences: Stability: tensorflow 2.0 underwent a lot of changes from tensorflow 1.x, specifically in the very way it worked (they changed from a computational graph paradigm to an imperative paradigm). This caused a lot of friction and left many ...

0

I only have a guess, but I suspect it could be simply due to random initialisation. This would mean that after few training samples the models would still be very different. After 400k training samples the models all converge to the same learning path. I could be wrong of course!

1

If you are talking about testing accuracy in this case (ie you are comparing results on data you didn't train with) - it's possible that adding more estimators is overfitting on your training set and is therefore performing poorly on your holdout set. If this is the case I would recommend approaching the problem with a more basic method such as ...

1

Use f1_score instead of the classification report: from sklearn.metrics import f1_score ... print('f1_score', f1_score(xgb_results, y_test))

1

Pipelines themselves don't generally carry the methods and attributes of the final estimator, aside from basics like predict, predict_proba, transform. If you need to access a method of a step, you should access the step itself using one of: pipe[-1] pipe['decisiontreeclassifier'] pipe.named_steps['decisiontreeclassifier'] However, in this case it's a ...

0

I have had a first crack at coming up with a workaround, although its ugly and won't scale: alpha_candidates = (np.arange(0.0,0.5, 0.001)).tolist() alpha_accuracy_list = [] # Create Decision Tree classifer object for i in alpha_candidates: clf2_entropy_alpha = DecisionTreeClassifier(criterion = 'entropy', ccp_alpha= i,random_state=42) pipe = ...

1

This would not reduce the effect of the curse of dimensionality because you are not reducing any dimensions, simply the values of one dimension. A valid reason to do this would be if there are so few training examples above 20 that your neural network struggles to learn much about them. But as Erwan suggested, you should simply try clamping and not, and ...

0

You should visualize your data to see what kind of decision bound might fit. Possibly, there is no weighting of features that can predict drug type.

2

I can't say exactly why you get null accuracy, but I have some comments that may help: you are mixing continous data and categorical data. You might already be aware: when standardizing your data: you are although standardizing your categorical data (sex, disease_type), just be sure that it makes sense (depending on the classifier you're using) depending ...

1

What shepan6 is suggesting is basically to manually search for the best "transformation choice hyperparameters" by trying them all and seeing what performs best. This is a good idea (I upvoted), but if you want to go further, you can use a package like hyperopt and manually define an "objective" function that accepts a parameter that ...

3

There seems to be two possible approaches to your problem : If they are just identification features that you know aren't informative, you should remove them yourself. SelectKBest - like almost any other EDA tools - works on all the features you provide it, there is no way it knows what features are supposedly uninformative identification features and which ...

1

Two problems: Your sorting is incorrect: eVec = eVec1[np.flip(np.argsort(eVal1))] sorts the rows of the matrix, but you want to sort the columns. Replacing this with eVec = eVec1[:, np.flip(np.argsort(eVal1))] fixes this issue. The sign of the eigenvectors are sometimes opposite. (That's fine, being an eigenvector is scale invariant, and while both np....

1

First, note that Random Forests can handle categorical variables (moreover, if you have too much categories, reducing this number is a good practice). If you want to apply a filter to your data, I'd suggest you using sklearn transformers (like OneHot Encoder, Label Encoding, ... pick the one you need according to what you want to do). In this case, you have ...

1

Linear regression will not work for this problem because the relationship between the board features and target variable that you are using is not linear. Is this how data scientists would go about creating the training set for tic tac toe? It is not 100% clear what your goal is. For simplicity I will select that your goal as "Predict the probability ...

0

Gradient boosting machines can return values outside of the training range. Have a look at this post Can Boosted Trees predict below the minimum value of the training label? In practice this is unlikely to happen, but it can be the case for your data. If this is happening probably what it means is that your training data and the one you are evaluating are ...

2

If what you want to do is keep the same proportions across the splits, what you are doing is right. In order to validate properly your model, the class distribution should be constant along with the different splits (train, validation, test). In the train test split documentation , you can find the argument: stratifyarray-like, default=None If not None, ...

0

you can try stratified sampling method from sklearn.model_selection import StratifiedShuffleSplit split=StratifiedShuffleSplit(n_split=1, test_size=0.2, random_state=9)

0

You can get all the Trees using clf.estimators_ Then you can traverse the Tree using custom code.[Check here] Then you can take it to whatever format you want i.e. Array/DataFrame A sample code to view one of the Tree from sklearn import datasets iris = datasets.load_iris() X = iris.data y = iris.target clf = RandomForestClassifier(max_depth=3, ...

1

It is impossible to retrieve column names from a trained Random forest classifier from my experience, there is also a previous answer for an identical question.

0

Linear Regression is associating any numerical (or binary, which is a particular numerical) value to a coefficient. Multiplying those values by those coefficients gives you an output, and setting the threshold, you know if the model predicts 1 or 0. (This is a brief summary, you'll find plenty of people explaining in details how it works). If your variable ...

0

The problem is that you are using the everydaydata to build the traintarget dataset, but you should use the labels in everytarget. That is why is complaining abut the shape, because the labels should be one dimensional. Try replacing this: traintarget = np.concatenate((everydata[:140],everydata[212:357]),axis=0) with this: traintarget = np.concatenate((...

0

So the error is risen on your dd.fit(traindata,traintarget) lane. If you print your traintarget.shape(), you'll see it's (285, 30). Target (often called y_train) is the array that should have only outputs of your training set, so the model can learn links between X_train (traindata) and y_train. Here your y_train have 30 attributes, where it should be 1 (...

1

I'm not sure if you ever figured this out but I was trying to find answers on this exact same question and there aren't really any good answers in my opinion. I finally figured it out though. OrdinalEncoder is capable of encoding multiple columns in a dataframe. So, when you instantiate OrdinalEncoder(), you give the categories parameter a list of lists: enc ...

1

The way to understand Max features is "Number of features allowed to make the best split while building the tree". The reason to use this hyperparameter is, if you allow all the features for each split you are going to end up exactly the same trees in the entire random forest which might not be useful. To overcome this we let the model select a ...

0

Run it twice. Here is the math for the 2nd test_size. Let's say I want {train:0.67, validation:0.13, test:0.20} The first test_size is 20% which leaves 80% of the original data to be split into validation and training data. (1.0/(1.0-test_size))*validation_size = second_test_size # (1.0/(1.0-0.20))*0.13 = 0.1625 Also, look into the stratify parameter as ...

4

I modified your code so the code runs as a block and is setup to predict new data: import string from nltk.corpus import stopwords import pandas as pd from sklearn.feature_extraction.text import CountVectorizer from sklearn.model_selection import train_test_split from sklearn.metrics import classification_report,confusion_matrix, accuracy_score from sklearn....

0

The default number of estimators is 100. Reducing the number of estimators may work.

0

Grid search grows geometrically with the number of hyperparameters and values for each hyperparameter. It is best practice to minimize the search space to fewer options. Increased performance on training dataset is no guarantee of increased performance on test set.

0

From the traceback, you can find the problem stems from here: is_estimator_type = (is_classifier if is_classifier(self) else is_regressor) for est in estimators: if est not in (None, 'drop') and not is_estimator_type(est): raise ValueError( "The estimator {} should be a {}.".format( est....

1

that's probably due to the fact your class is not really 100% compatible to the scikit-learn estimator interface. You can easily verify this with the check_estimator method in sklearn.utils.estimator_checks. This should ensure you it is a proper classifier which can be passed then to AdaBoost. I'd also suggest to inherit from BaseEstimator in addition to ...

1

If you are concerned about imbalanced data, you should be using sklearn.model_selection.StratifiedKFold which preserves the percentage of samples for each class. That way the validation set is representative of underlying class percentages.

1

The general idea of using a validation set is to analyse or control the training of the model. Usually, the model tends to under-fit or over-fit, and this can be observed using the validation split. In practical applications, we just have the visible training set and unknown test set. So, with some assumption on the test set, a simple assumption can be such ...

3

Is it possible that after running the optimization my score won't get better (and even worse?) ? Yes, theoretically, by pure luck, it is possible that your initial guess, before optimization of hyper-parameters, provides better results than the best of parameter combination found in the parameters grid. However, assuming you have enough data and your ...

0

In an Anomaly Detection scenario the labeled data is useful for several things: Hyper-parameter optimization. Selecting the anomaly threshold, feature/preprocessing settings, etc. Estimating performance on unseen data ("generalization"). Estimating the robustness of our AD model pipeline To be able to do 1. and 2. we at minimum need split into a ...

Top 50 recent answers are included