Basic Auth .htaccess on wp-login, but allow logout from woocommerce

I use a .htaccess basic auth on my WC site to help prevent hackers accessing wp-login, which works well... except with WooCommerce if a logged in customer wants to logout from their account - upon clicking the logout link - they are greeted by the Basic Auth popup asking them to "authorise" (generated by our .htaccess). On Woocommerce dashboard: Hello MrTest (not MrTest ? Log out) << clicking on "Log out" brings up the Basic Auth login box.... how can …
Category: Web

Visualizing decision tree with feature names

from scipy.sparse import hstack X_tr1 = hstack((X_train_cc_ohe, X_train_csc_ohe, X_train_grade_ohe, X_train_price_norm, X_train_tnppp_norm, X_train_essay_bow, X_train_pt_bow)).tocsr() X_te1 = hstack((X_test_cc_ohe, X_test_csc_ohe, X_test_grade_ohe, X_test_price_norm, X_test_tnppp_norm, X_test_essay_bow, X_test_pt_bow)).tocsr() X_train_cc_ohe and all are vectorized categorical data, and X_train_pt_bow is bag of words vectorized text data. Now, I applied a decision tree classifier on this model and got this: I took max_depth as 3 just for visualization purposes. My question is: I would like to get feature names in my output instead of index as X2599, X4 etc. …
Category: Data Science

Can inactive WordPress plugins still load scripts?

I recently deleted a contact form plugin (HubSpot All-In-One Marketing) on a site and the contact forms stopped working. Curiously, the forms work when the plugin is installed and INACTIVE, but they do NOT work when the inactive plugin is DELETED. This means that the plugin being present is affecting the site even when it is inactive. How is this possible? How can a contact form work when a plugin is present and inactive, but not when the plugin is …
Category: Web

Find recurrent dates in a small set (and get rid of non recurrent ones)

I need help in the analyse of a categorization problem. Given a set of dates (small set: 20 elements maximum), I would like to group dates which are equally distributed (with a tolerance). It can be, for instance, monthly or weekly separated dates. Here is an example. Given this repartition : I would like to categorize into these two groups: The problem is that I am a developer, not a data scientist. I have an intuition that it should be …
Category: Data Science

2 css files? Theme css file gets override by another css file that I can not edit

I wasted quite some time already to fix this problem. I somehow have a Wordpress css file that overrides the css of my themes css. See attached image: At the top is the css which screws with my design. Below is the color I would actually want within the css file of my theme. I can edit the 2nd css file, but how can I edit the other file? Best regards Julian
Topic: css Wordpress
Category: Web

wp_redirect() - headers already sent

I am trying to use wp_redirect() to redirect the user after successfully submitting a signup form on the page. It's not working and shows the following error: Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/theme/wp-content/themes/test/header.php:10) in /Applications/MAMP/htdocs/theme/wp-includes/pluggable.php on line 1178 I understand there has been already output before, that's why it's not working, but I have no clue how to make this work. The signup form gets rendered by a function, and is submitted …
Category: Web

Sample variance matrix normal distribution in R

I'm trying to perform a multinomial logistic regression in R employing the Metropolis-Hastings algorithm, considering a Matrix Normal Distribution as proposal. I'm using the function rmatrixnorm() included in the package LaplacesDemon in order to sample from the proposal distribution. I followed this strategy since I need a vector of parameter $\underline{\beta_{k}}$, with $k=1,\dots,K$ (number of classes involved in the classification). At the end of the Monte-Carlo iterations, my procedure retrieves the sample mean and the sample covariance of the posterior …
Category: Data Science

Disable plugin on Specific Page of Admin

I have 2 plugins 1) FAT Gallery 2) Salon Booking So FAT Gallery has a certain js lib (select2) which conflicts with Salon Booking Settings page. In this URL example.com/wp-admin/post-new.php?post_type=sln_booking I'm trying to DISABLE the FAT Gallery because it causes js error and i cant do my job. Any idea of how to block it ONLY on the certain page? Thanks a lot!
Category: Web

Compare cross validation values of Bernoulli NB and Multinomial NB

I'm testing the Multinomial NB and Bernoulli NB on my dataset and I'm using the cross validation score to better understand which of the two algorithms work better. This is the first classifier: from sklearn.naive_bayes import MultinomialNB clf_multinomial = MultinomialNB() clf_multinomial.fit(X_train, y_train) y_predicted = clf_multinomial.predict(X_test) score = clf_multinomial.score(X_test, y_test) scores = cross_val_score(clf_multinomial, X_train, y_train, cv=5) print(scores) print(score) And these are the scores: [0.75 0.875 0.66666667 0.95833333 0.86956522] 0.8637666498061035 This is the second classifier: from sklearn.naive_bayes import BernoulliNB clf_multivariate = BernoulliNB() …
Category: Data Science

Allow duplicate slugs for posts on Custom post type in different categories/taxonomy?

i'm making a photo gallery for a plastic surgery website, with before and after photos of patients. i made a custom post type /photo-gallery and a taxonomy /procedures, after reading this post i was able to include the taxonomy in the permalink, now i want to be able to generate permalinks like www.site.com/photo-gallery/facelift/patient-1 www.site.com/photo-gallery/liposuction/patient-1 www.site.com/photo-gallery/breast-augmentation/patient-1 But instead i got a permalink like. www.site.com/photo-gallery/facelift/patient-1 www.site.com/photo-gallery/liposuction/patient-1-2 www.site.com/photo-gallery/breast-augmentation/patient-1-3 is there a way to achieve permalinks like in the first group?
Category: Web

Is there a way to nest taxonomies or custom fields deeper than one level below the post type?

In Wordpress we can create a post type which can contain taxonomies (or custom fields). Can these taxonomies (or custom fields) contain anything? For example other taxonomies or something else? If I need a Wordpress model where I've got people who have got pets who have got toys which have got colours... As you can imagine, two different people can have a cat; a toy for a cat can be at the same time a toy for a dog; the …
Category: Web

Average Precision if Target Class is Not in Evaluation

Suppose I have 5 classes, denoted by 1, 2, 3, 4, and 5, and this is used in object detection. When evaluating an object detection performance, suppose I have classes 1, 2, and 3 present, but classes 4 and 5 are not present in the targeted values. Will each of classes 4 and 5 have average precision of 0 (due to its precision being zero as no true positives can be identified)? Or perhaps there are other considerations to take …
Category: Data Science

Custom Search Query – include only custom fields and title

I have a custom post type and I also need a custom search. I want the post title and two custom fields to be indexed/queried. I found solutions for title only and for custom fields but not for both so I tried to combine. Why doesn't this work? function custom_search( $search, &$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // skip processing - no search term in query $q = $wp_query->query_vars; $n = ! empty( …
Category: Web

Understanding Conv1D Output Shape

I am a little confused with the output shape that Conv1D produces. Consider the code I have used as the following (a lot has been omitted for clarity): input_shape = x_train_2trans.shape # (7425, 24, 1) model.add(Conv1D(filters=4, input_shape=input_shape[1:], kernel_size=(3), activation=LeakyReLU)) model.add(Dropout(0.2)) model.add(Dense(1)) I have tried 3 different kernel sizes of 3, 2 and 1, where the output size produced are: (256, 2500, 12, 1), (256, 2500, 18, 1), (256, 2500, 24, 1), respectively. What I am confused with is the difference …
Category: Data Science

Execute jQuery with custom event listener after successfully add an item to the cart

This is my first post, so please be gentle. I'm already successfully executing some jQuery codes in my woocommerce cart-page after updating the item quantity (Ajax) with the following code: $( document.body ).on( 'updated_cart_totals', function(){ //re-do your jquery }); I also need a similar function to execute a jQuery code after adding a cross selling item (with click on the ajax_add_to_cart_button) in the cart-page. So far i checked the cart.js file to find a custom event to handle this - …
Category: Web

How to evaluate data imputation techniques

I have a data set with 29 features 8 if them have missing values. I've tried Sklearn simple imputer and all it's strategies KNN imputer and several Number of K Iterative imputer and all combinations of imputation order , estimators, number of iterations. My question is how to evaluate the imputation techniques and choose the better one for my Data. I can't run a base line model and evaluate it's performance because I'm not familiar with balancing the data and …
Category: Data Science

Excessive GPU memory usage for Keras model.fit()

I am trying to use Keras to do some image analysis using the Xception model. When I run model.fit, GPU memory usage increases rapidly to 16 GB, despite my training data only being (7546, 299, 299, 3) in size, so about 1.9 GB. I have tried using K.clear_session() between epochs, which helps a bit, but GPU memory usage still quickly reaches the maximum of 16 GB and stays there. I am running this on a Jupyter notebook on Google Colab …
Category: Data Science

Tried to create a user role that can only edit user information, but my test account cannot view the dashboard. What am I missing?

One of our websites includes an online store, which alongside phone sales is one of two ways customers can purchase our products. All of our customer info is stored in a program called Orderwise, which assigns a unique number code to each customer. Now, we've set up the ability to add an Orderwise number to user info on the website, so I've been trying to set up a role which will allow the sales department to get through to the …
Category: Web

Cluster Evaluation with Jaccard and Rand Index

I've clusterized my data according to 3 criteria in 3 groups. I used kmeans to obtain those cluster so the label for each cluster is random and changes at each script run. To evaluate the consistency of my clusters I decided to use Jaccard index but I can't understand how to apply it properly. Let's say I have this data where alpha beta and gamma are the 3 methods, and the Cluster Index is the value returned by K-means for …
Category: Data Science

How to compute threshold?

I would like to detect anomalies for univariate time series data. Most examples on internet show that, after you predict the model, you calculate a threshold for the training data and a MAE test loss and compare them to detect anomalies. So I am thinking is this the correct way of doing it? Shouldn't it be a different threshold value for each data? Also, why do all of the examples only compute MAE loss for anomalies?
Category: Data Science

Getting category posts from a certain year

Is there a way to get category posts from a certain year? I know how to get all posts posted in a certain year -> www.example.com/**year**/ or with months -> wwx.example.com/year/month (that's how the default archive works) Is there a trick to get for wwx.example/year/category/ Thanks!
Category: Web

Uploading PDF using Media Uploader

I have been using a custom code to upload images to Wordpress using custom metaboxes. Here is the code: <script type="text/javascript"> jQuery(document).ready(function( $ ) { var formfield; $('.upload_button').click(function() { $('html').addClass('Image'); formfield = $(this).prev('.upload_image'); // .attr('name'); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); // user inserts file into post. only run custom if user started process using the above process // window.send_to_editor(html) is how wp would normally handle the received data window.original_send_to_editor = window.send_to_editor; window.send_to_editor = function(html){ if (formfield) { fileurl = jQuery('img',html).attr('src'); …
Category: Web

Error after merging two Deep Learning models VGG16 and ResNet50

I have merged two different models namely VGG16 and ResNet50 and given the outputs of the two models as input to another model. I have checked the Layers graph is correct. Before merging the code was running perfectly fine giving correct outputs. I am getting an error: "ValueError: Shapes (None, None) and (None, 7, 7, 3) are incompatible" on the line 6 ValueError Traceback (most recent call last) <ipython-input-36-620554d0106f> in <module>() 4 epochs = 200, 5 validation_data = validation_generator, ----> …
Category: Data Science

Issues with self-implemented logistic regression

I am trying to self-implement a logistic regression algorithm to do some self-learning but I am having a bit of trouble with achieving similar accuracy to the logistic regression of sklearn. Here is the code I am using (the dataset I am using is the titanic 'training.csv' dataset from kaggle which you can download here if you want to test this out yourself.) import numpy as np import random import matplotlib.pyplot as plt #%matplotlib inline def cost(X, Y, W): """ …
Category: Data Science

Jumbotron not showing up on Firefox or Safari

I just want to start out by saying, that I have tried multiple things before I resorted to writing this entry. You guys are my only hope. My site works in Chrome, but disappears in Firefox or Safari. Things I have tried: Added register script then enqueue; In hopes that my grid-12.css is loaded before frontstyle.css(grid-12.css has jumbotron code; bootstrap.css just has my modal.) Moving the end of my while/endif; wp_reset_postdata to the bottom of my jumbotron. Put my jumbotron …
Category: Web

Get the first image from post content (eg.: hotlinked images)

I am using this code directly from the codex. function echo_first_image ($postID) { $args = array( 'numberposts' => 1, 'order'=> 'ASC', 'post_mime_type' => 'image', 'post_parent' => $postID, 'post_status' => null, 'post_type' => 'attachment' ); $attachments = get_children( $args ); //print_r($attachments); if ($attachments) { foreach($attachments as $attachment) { $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' ) ? wp_get_attachment_image_src( $attachment->ID, 'thumbnail' ) : wp_get_attachment_image_src( $attachment->ID, 'full' ); echo '<img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'" class="current">'; } } } I call it within the loop like this …
Category: Web

How to add numeric slug for child page in WordPress 5.9?

I am trying to configure WordPress 5.9 to allow numeric slugs for child pages. Drawing from the 2015 answer to a similar question I took the up-to-date code of wp_unique_post_slug, removed || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) and then added it as the following hook to my theme's functions.php. But for some reason, I just get a critical error: "Allowed memory size exhausted". What can I do to allow numeric slugs for child pages? add_filter( 'wp_unique_post_slug', function ( $slug, $post_ID, $post_status, …
Category: Web

How can I adjust the legend when visualizing clusters in two dimensions?

How can I change the legend as we can see now the legend has some cluster numbers missing. How can I adjust the legend so that it can show all the cluster numbers (such as Cluster 1, Cluster 2 etc, no it's only 0 3 6 9)? (codes I followed this link: Perform k-means clustering over multiple columns) kmeans = KMeans(n_clusters=10) y2 = kmeans.fit_predict(scaled_data) reduced_scaled_data = PCA(n_components=2).fit_transform(scaled_data) results = pd.DataFrame(reduced_scaled_data,columns=['pca1','pca2']) sns.scatterplot(x="pca1", y="pca2", hue=y2, data=results) #y2 is my cluster number plt.title('K-means …
Category: Data Science

Foreach loop through Gravity Forms entries

So, I'm trying to iterate through a foreach loop of all the entries to a gravity forms form. I have it sort of working in a template, but I need to put it in a class (creating a calendar and need to pull in entry information) and now it is just iterating over the last entry a bunch of times. Not sure where I went wrong: $form_id = 9; //Enter the form ID here. The PTO form ID is 9; …
Category: Web

SHAP values interpretation for clasification

I'm trying to understand how SHAP values are calculated for Classification. As far as I understand for each feature the SHAP values are calculated by: $$ \phi_i = \sum_{S \subseteq F \setminus {i}} \frac{|S|!(|F|-|S|-1)!}{|F|!} \left[ f_{S\cup{i}} (x_{S\cup{i}})-f_S(x_S) \right] $$ For regression it makes sense that for three features ${A,B,C}$ each feature has a value. The prediction for one row might be ${A,B,C} = 50$. Then all possible coalitions are calculated with and without the feature to find the marginal contribution …
Category: Data Science

Precision, Recall and/or F1? Which should I use? or something different?

I am trying to use tensorflow to predict a decision based on a timeseries dataset. I have three classes: "Wait", "Fowards", "Backwards" The dataset is high imbalanced ~90% of the time the decision is to "Wait". Thus using accuracy as a metric is not useful. I need my model to focus on correctly identifying a pattern that is either "Fowards" or "Backwards", and so I have implemented the following metric to look at Precision and Recall of the classes I …
Category: Data Science

How to update the 'modified_time' of a post ONLY when content is changed?

For some reasons I show the Last Modified information to my users in the blog. Recently I have to clear up my categories and tags, but these actions will result in the update of 'Last Modified' field of a post, which is not actually I desired. Content updates are what readers really concerned about, and not about meta information (like tags, categories, custom fields, descriptions, etc). So is there a way to update the 'Last Modified' field of a post …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.