How do I check if an article is popular this week?

I use this function to set and get post view of post in my WordPress function wpb_set_post_views($postID) { $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); function wpb_get_post_views($postID){ $count_key = 'wpb_post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 view"; } return $count.' view'; } Please , how can I check if an article …
Category: Web

How to manage missing data in meteorological time series?

How to know the type of missing data is what it is: MCAR, MAR or NMAR, knowing that I'm working on time series multivariate, and is that going to help me deal with the missing data, and what is the best techniques of processing missing data in time series, knowing that I work on meteorological data?
Topic: time-series
Category: Data Science

How can the labels of AgglomerativeClustering be re-computed?

I am using scikit-learn's AgglomerativeClustering on a large data set. I would like to modify the distance_threshold after the model has already been computed. Computing the model is slow (quadratic time), but it should easily be possible to re-compute the labels for a new distance_threshold in linear time because the model stores the children_ and distances_ arrays permanently. But how can the labels be re-computed for a different distance_threshold? It can be assumed that distance_threshold was originally set to 0, …
Category: Data Science

Scaling negative and positive variables when performing a k-means cluster analysis

I'm looking to perform a k-means cluster analysis on a set of data that contains variable ranges that contain both positive and negative values. Given the rangers vary so much the data will need to be scaled, but my concern is with the variables that contain negative value ranges. Should I perform some sort of log transformation on all the date so as to scale the data to positive values. For example: Variable A: 3.4, 5.6,1.3,7.6,8.3 Variable B: 1,2,3,2,1 Variable …
Topic: k-means
Category: Data Science

Post and Page Inheritance to subsites in a WordPress Network

I have to develop a multi-country, multi-lingual website. One country may have multiple languages. I have setup a WordPress Network and created subsites for each country like following. abc.com/ > Global Website abc.com/usa > USA Website abc.com/fra > France Website I am detecting Countries through Geo Location API and forcefully redirect them to their own country's website. Each country has their own set of languages e.g. France will have English and French with French as default language. I decided to …
Category: Web

Can i use Transformer-XL for text classification task?

I want to use transformer xl for text classification tasks. But I don't know the architect model for the text classification task. I use dense layers with activation softmax for logits output from the transformer xl model, but this doesn't seem right. when training I see accuracy is very low. Output of my model: My training step:
Category: Data Science

Estimating time to travel between two lat/longs

I'm trying to create an offline estimator for how long it would take to get from one lat/long to another. Two approaches I have come across are the Haversine distance and the Manhattan distance. What I'm thinking of doing is calculating both of them and then using the average between the two as the distance and then use some average speed to calculate time. Since this value will be used as an estimator for drivers in a city a straight …
Category: Data Science

Keyword checking in Gravity Forms

In Gravity Forms I'd like to include a small keyword checker that is checking the user's message for "spammy" words and stops sending the entry to the admin. For this a hidden field changes it's value. I have this code included in my functions.php so far function strpos_arr($haystack, $needle) { if(!is_array($needle)) $needle = array($needle); foreach($needle as $what) { if(($pos = stripos($haystack, $what))!==false) return $pos; } return false; } /* * Our bad words validation function */ add_action('gform_pre_submission_1', 'keywords_check'); function keywords_check($validation_result){ …
Category: Web

How to aggregate face embeddings of all photos of the same person?

I am classifying about 3000 thousand people's faces using FaceNet. Each person has about 100 photos. FaceNet first calculates a face embedding ( a feature vector) for each photo. So each person has 100 face embeddings. What I want to do is aggregate the face embedding of each person into one. What is the best way of doing this? I have tried to use mean method. But I am not sure whether this is recommended way. -- The reason I …
Topic: svm
Category: Data Science

Big difference between Bootstrap Values and Approximately Unbiased p-values

I'm clustering objects over many different descriptors. I chose a hierarchical clustering method (specifically average linking algorithm with euclidean distances) because I wanted to use bootstrap values to give statistical significance to my clusters. I used pvclust (in python, it should be equivalent to r package pvclust). The package calculates both Bootstrap values BP and Approximately Unbiased p-values AU. The results are shown in this dendrogram I don't know how to interpret the fact that UA are relatively high while …
Category: Data Science

Recommender system based on clusters

I'm wondering if this is a correct approach to build recommender systems: My problem: Recommend phone devices, you have device X and you are likely to switch to device Y. Understand the data. I want to know the implication of each dimension on the device switch. How should I do it? Correlation matrix? assign to each switch one ID and check de CM?. Per example, the switch may be different by country, etc. Once I know the implications of each …
Category: Data Science

wp-admin 302 redirects

I have a new install of WordPress on my Mac mini server. The site uses SSL and has a valid up to date certificate from StartCom. The site loads, but with no CSS or theme. Mainly, I can't get into wp-admin (or wp-login.php) as it redirects with two 301 redirects and then multiple 302 redirects. I used http://redirectdetective.com to find out what was happening, but now I don't know how to fix the redirects. Here is my .htaccess # BEGIN …
Category: Web

BERT base uncased required gpu ram

I'm working on an NLP task, using BERT, and I have a little doubt about GPU memory. I already made a model (using DistilBERT) since I had out-of-memory problems with tensorflow on a RTX3090 (24gb gpu's ram, but ~20.5gb usable) with BERT base model. To make it working, I limited my data to 1.1 milion of sentences in training set (truncating sentences at 128 words), and like 300k in validation, but using an high batch size (256). Now I have …
Category: Data Science

WooCommerce Subscriptions: Hide one variation subscription

Woocommerce subscriptions | All Products for WooCommerce Subscriptions Does anyone know if there's a way to disable the subscribe option for a specific product variation? i.e. product with 2x attributes: attr-1, attr-2 All of which can be bought singly or via a sub on the PDP, is there a way to disable the subscribe option for one of the attributes? There's no succinct way using the wcsatt_product_subscription_scheme filter without a lot of JS logic. Have reached out to WC and …
Category: Web

Where can I find an algorithm for human activity classification using thigh and shank sensors?

I am working on a project where I initially need to classify the type of activity a subject is performing based on raw accelerometer and gyroscope data from the thigh and shank of both legs. The type of activities would be day-to-day tasks such as standing, sitting, running, sit-to-stand, stair climbing, if playing sports, cutting, etc. I have tried reading papers and looking on git to find an algorithm that will do this for me. I know that there are …
Category: Data Science

Creating a Searchable PDF Archive of Publications

We are a not for profit association that produces a quarterly publication of about 45 pages. Want to create a members only archive of back issues in pdf format. This would be used for research (not a replacement for hardcopy) so we would like to be able to search all or as many issues as possible at one time by word. We have an index of articles by category and author so we can link directly to an issue from …
Category: Web

Adding hreflang tags automatically in WordPress subdirectory multisite

We have a WordPress MU subdirectory network setup: www.example.com - main website, USA, global www.example.com/uk/ - to display for UK visitors www.example.com/au/ - to display for Australian visitors. We want to add hreflang tags for each webpage and exclude the locations custom post type. From this question, I've adjusted the code in the child theme's functions.php to: function add_hreflang_attribute() { $site_url = network_site_url(); // base URL $alt_langs = array( 'au', 'uk' ); // two-letter language code $page_path = substr(get_permalink(), strlen(home_url('/'))); …
Category: Web

Hide Admin Menu for Specific User ID who has administrator Role

I am trying to hide almost every single admin menu from wordpress dashboard for a specific user id who has administrator role. I want to give that user only option to edit a certain custom post type named lessons and other custom post type Events. I am using LMS wordpress theme from themeforest by designthemes. I am not sure why this theme just don't give access to the WP-admin for other role except administrator, like Editor, Contributor etc. So I …
Category: Web

Maximum image width/height?

If uploading a big image, WP will decrease the dimension and add -scaled to the file. How can I get what is its max limit? 5000x5000 => it can't be greater than X so WP will make it smaller than X. How can I find the X?
Category: Web

Hide custom meta data if empty

I have a custom field created for WooCommerce products. I am using the below code to create // ADD CUSTOM WOO DATA add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_custom_fields'); // Save Fields add_action('woocommerce_process_product_meta', 'woocommerce_product_custom_fields_save'); function woocommerce_product_custom_fields() { global $woocommerce, $post; echo '<div class="product_custom_field">'; // Custom Product Text Field woocommerce_wp_text_input(array( 'id' => '_sales_email', 'placeholder' => '', 'label' => __('Sales Email Link', 'woocommerce'), 'desc_tip' => 'true' )); echo '</div>'; } function woocommerce_product_custom_fields_save($post_id) { // Custom Product Text Field $woocommerce_custom_product_text_field = $_POST['_sales_email']; if (!empty($woocommerce_custom_product_text_field)) update_post_meta($post_id, '_sales_email', esc_attr($woocommerce_custom_product_text_field)); } …
Category: Web

Hide the wp-admin bar from dashboard

I want to hide the admin bar from dashboard. I tried with following code: add_action('after_setup_theme', 'remove_admin_bar'); function remove_admin_bar() { if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); } } It hide the admin bar when a logged in admin visit as front-end user. I actually want to hide the admin bar from dashboard back-end as indicated by red arrow in the following picture: Any help is appreciated.
Category: Web

the Customizer - proper way to instantiate an image upload control via javascript

I am trying to create an image control using: wp.customize.control.add( new wp.customize.Control( myControlSettingID { type: "image", button_labels: {select: 'Select image', change: 'Change image', remove: 'Remove', default: 'Default', placeholder: 'No image selected'...} description: "Upload or select an image for this featured link" id: "issue_section_term_apple_settings_link_image" label: "Custom image" priority: 1 section: "issue_section_term_apple_section" } ) ); I am using the "type" property and set it to "image" which is what the WP_Customize_Image_Control php class has set for the class "type" property. This is …
Category: Web

isSavingPost() for widgets

I want to get the block ID of my widgets (e.g. #block-1, which is displayed on the frontend after saving a widget) on the widgets screen in the backend. What I try to achieve is to display the ID of the widget in the toolbar so that you can easily copy it. I currently use a custom API endpoint to receive the ID but it will trigger a request on every render (I already debounced it, but am searching for …
Category: Web

Add post meta fields, when creating a post using WordPress' REST API

In the documentation for /posts for WordPress REST API it states that I can add a meta-field. But it doesn't say which format that should be in. I can find other guides showing how it should be if using Postman: data = { "title": "test", "content": "testingfrompython", "status": "draft", "author": 1, "meta": { "location": "NYC", "date": "never", "event_url": "http: //google.com" }, "featured_media": 1221 } But how should it be setup, if I'm call the endpoint using PHP and cURL? This …
Category: Web

How do I select an image from Media Library in my plugin?

I have written a plugin in which you have a small chat icon in the bottom right corner, however I want the user to be able to choose an image as the icon from the Media Library. How can I do this with the Wordpress API? The image is a setting in the plugin (only changable by the admin)
Category: Web

How to train on extended data set correctly

I have trained my classifier on pictures with a mixture of several classes on each picture, e.g. A-F. The classifier is able to (nearly) correctly segment those classes on the images. Now I got more data with pictures showing class G. To minimize my work, I only labeled class G on the images and left the rest out (Invalid). Two questions for my training arise: If there are no examples of class G in my first dataset (because it could …
Category: Data Science

Gutenberg block "This block appears to have been modified externally" on save

Just starting to play with Gutenberg block development, and I am building a very simple button (yes I know buttons are already included, but this block will have lots of settings and classes not included in the core block). Seem's pretty strait forward, but when I save the block and reload, I get a validation error and the "This block appears to have been modified externally" message. registerBlockType('franklin/button', { title: 'Button', keywords: ['button' ], icon: 'admin-links', category: 'layout', attributes: { …
Category: Web

Change wp-login.php? Problem with .htaccess password protection and multi user shop

I use a .htaccess password protection to secure my wp-login.php. For me as the admin of the WP/WooCommerce installation everything works fine so far (my password manager helps me to remember the tons of passwords). But now I have the problem, that there are are also registered customers which should be able to see their own customer accounts. When these customers want to log out from their account, they click on the link /customer-logout/ (which is in fact just the …
Category: Web

can't modify post title using the_posts filter

I tried to modify post title and content, content is modified in output, but title stays intact: function filter_the_posts( $array , $oQuery) { ... $array[0]->post_title='new title'; $array[0]->post_content ='new content'; return $array; } add_filter( 'the_posts', 'filter_the_posts', 10, 2 );
Category: Web

Linear Regression on data with bimodal outcome

I have a data set with 3,000 features and continuous dependent variables of time with 18,000 instances. The histogram of the dependent variables show that the they have a bimodal distribution. I am building linear regression models that forecast the time, but none of the models are able to make predictions; the $R^2$ values of all of the models are $0$. I plotted the residuals of the models and verified that they are normally distributed I have used LassoCV/Lasso, ElasticNetCV/ElasticNet, …
Category: Data Science

Bypass a WordPress Password Protected Post or Page via a URL

I have a password protected page that i would like to be accessible with a custom link with the password as get variable in url www.domaine.tld/my-page?code=mycustompassword I have found this but this is not working Bypass password protected posts via GET variable Could you pleaser help me to bypass the password form Regards
Category: Web

How does attention for feature fusion works

I am struggling to understand how would a self-attention layer be used for features of different modalities fusion. What I understand until now is that : Every unique modality is fed into a self-attention layer, this layer produces attention scores for every feature of that modality. So these scores give us information about which features are most important in that modality. And then I have read that using these scores we can find out which of the modalities is most …
Category: Data Science

comment_form() not showing on custom post type

I'm using Gravity Forms to create entries from forms, and Gravity View to display these entries on the Front-End. By default, Gravity Forms and Gravity View doesn't have a comment system for the entries, so the idea is, creating a custom comment system. I could do this easier, using custom post types to store and display entries as posts, having comments enabled, but Gravity Views has sorting, advanced search, display modes and such. So on the other side, it wouldn't …
Category: Web

About

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