Change pubDate in rss feed in another format

In the default wordpress rss feed the element <pubDate> is <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> and gives a result of <pubDate>Tue, 12 May 2020 12:39:03 +0000</pubDate> how can i change this line to give a result of <pubDate>12/05/2020 12:39:03 +0000</pubDate> (d/m/Y) or <pubDate>12-05-2020 12:39:03 +0000</pubDate> (d-m-Y) but to be valid with RFC-822 ? I tried many variations <pubDate><?php echo mysql2date('r', get_the_time('Y-m-d H:i:s')); ?></pubDate> or <pubDate><?php echo get_post_time( 'd/m/Y …
Category: Web

Wordpress change wp_nav_menu walker with a custom one

I have a downloaded theme and it where the wp_nav_menu is created it looks something like this: <div class="nv-nav-wrap"> <div role="navigation" class="<?php echo esc_attr( join( ' ', $container_classes ) ); ?>" aria-label="<?php esc_attr_e( 'Primary Menu', 'neve' ); ?>"> <?php echo wp_nav_menu( [ 'theme_location' => 'primary', 'menu_id' => $menu_id, 'menu_class' => 'primary-menu-ul nav-ul' . $additional_menu_class, 'container' => 'ul', 'walker' => '\Neve\Views\Nav_Walker', 'fallback_cb' => '\Neve\Views\Nav_Walker::fallback', 'echo' => false, ] ); ?> </div> </div> I've created a child theme and I want to …
Category: Web

Feature creation ideas for propensity models?

I'm working on a propensity model, predicting whether customers would buy or not. While doing exploratory data analysis, I found that customers have a buying pattern. Most customers repeat the purchase in a specified time interval. For example, some customers repeat purchases every four quarters, some every 8,12 etc. I have the purchase date for these customers. What is the most useful feature I can create to capture this pattern in the data?. I'm predicting whether in the next quarter …
Category: Data Science

Wordpress Custom Post Type - Post Attribute: Template. Template shows up and saves on the back end, but the default theme file is being rendered

Edit: Now I've found that this is Hybrid Core, and apparently the template hierarchy is different. I still haven't solved my problem below though. In addition to the title. My thinking is that if I am able to select a template in the backend, it should honor that selection. It doesn't change though. I've tested the other template file in place of the default, and it works. This is the function to add my custom post type. This works just …
Category: Web

Giving each person in order their top choice which is still available in Google Sheets

The problem I want to solve is my residential building's garage choices. There will be a random distribution of parking spaces. I thought that it would be better if each person writes down which spaces they want in order of preference, and then their priority of picking a parking slot is randomized. For instance: Person a chooses: p3, p5, p1, p2, p4 Person b chooses: p3, p1, p2, p4, p5 Person c chooses: p1, p3, p2, p5, p4 Person d …
Category: Data Science

Dynamically add sub menu items

I have been able to add menu items with this statement, this however creates a flat menu. The menu has been created already. I just need to add items. wp_update_nav_menu_item(4, 0, array('menu-item-title' => __($post_title), 'menu-item-url' => home_url('/'.$url.'/'), 'menu-item-status' => 'publish')); this is super simple to use. How do I add a sub-menu item?
Category: Web

CNN can't predict images outside the dataset

I am using celeba dataset to train my CNN face landmark detection model. Here is my model class LandmarkModel: def __init__(self,inp_shape): self.model = models.Sequential() self.model.add(layers.Conv2D(16, (3, 3), activation='relu', input_shape=inp_shape))#l1 self.model.add(layers.Conv2D(32,(3, 3), activation='relu')) self.model.add(layers.MaxPooling2D((2, 2))) self.model.add(layers.Conv2D(64,(3, 3), activation='relu')) self.model.add(layers.Flatten()) self.model.add(layers.Dense(512)) self.model.add(layers.Dense(10)) def getModel(self): return self.model I have trained my model for around 5k-6k images with loss of 0.1. When I use image from dataset that is outside of training sample I get correct prediction. But when I use my own clicked …
Category: Data Science

Learning high bias in neural net

I have this simple model, which tries to predict constant $[1, 1, .. 1, 0, ..., 0]$ vector regardless of input. I found that model predicts it successfully if trained on input in $[0,10]$ range, however model's predictions are always $[0...0]$ vectors if model is trained on input in $[750, 770]$ range. I was thinking model should converge to high bias weights and still be able to predict constant vector even for larger training inputs. Maybe anyone can advice what …
Category: Data Science

NAN in keras neural network results

I am creating a neural network simple architecture. But I keep getting NAN in result, cant figure out why, below is my code. import pandas from keras.models import Sequential from keras.layers import Dense from keras.wrappers.scikit_learn import KerasClassifier from keras.utils import np_utils from sklearn.model_selection import cross_val_score from sklearn.model_selection import KFold from sklearn.preprocessing import LabelEncoder from sklearn.pipeline import Pipeline from collections import Counter from sklearn.metrics import classification_report, confusion_matrix from sklearn.preprocessing import StandardScaler #from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder from tensorflow.keras …
Category: Data Science

Decision trees for anomaly detection

Problem From what I understand, a common method in anomaly detection consists in building a predictive model trained on non-anomalous training data, and perform anomaly detection using the error of the model when predicting on the observed data. This method requires the user to identify non-anomalous data beforehand. What if it's not possible to label non-anomalous data to train the model? Is there anything in literature that explain how to overcome this issue? I have an idea, but I was …
Category: Data Science

Meta query with order by another custom field

Edit: I will try to explain in detail my problem. I am working on a portfolio site. There are a few custom post types: Projects, Publications, Exhibitions, Lectures and Slides. Home page consists of following sections: slider with Slides portfolio consisting of: selected (marked by Client) Projects, Publications, Exhibitions and Lectures and remaining Projects, Publications, Exhibitions and Lectures awards section Now, I have problem with the portfolio section. It is to be paged in order to use Infinite Scroll by …
Category: Web

How to stop execution of a function via add_action hook?

I have the following functions: function test($post_id){ do_action('test_action',$post_id); echo $post_id; } add_action('test_action',function($post_id){ if ( $post_id == 2 ) //Stop test function execution } Using the function hooked to add_action, how to stop the execution of test() function without adding any code to test(). In the above example, if $post_id == 2 , the echo $post_id; code should not run in test().
Category: Web

Sort users by meta key value even if meta key not present for all users

Only some users have a specifice meta_key some_metakey associated with their ID. The following args successfully orders users with a specified role by some_metakey but only those with that meta_key. Can anyone point the direction to change the args to include ALL users with a specified role even if they do not have the some_metakey meta_key? $args = array( 'role__in' => [ 'role1', 'role2', 'role3', 'role4' ], 'order' => 'DEC', 'meta_key' => 'some_metakey', 'orderby' => 'meta_value' ); $users = get_users( …
Category: Web

Kmeans cluster validation when I have labeled test data

I'm trying to implement the unsupervised k-means algorithm for sentiment analysis of imdb movie dataset created by stanford. The steps that I followed is : 1) Load the comments 2) Apply tokenization and stemmetion ,use tf-idf algo to create tfidf matrix. 3) Use k-means algo to divide the data into 2 clusters. My problem is how do I validate the the clusters I have labeled test data. I want to check if all the negative examples go in one cluster …
Category: Data Science

How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field

I have searched high and low for a solution and couldn't find anything; hopefully someone here more skilled than myself can lend a hand. I have two testimonial videos (from a video custom post type) displayed randomly every time the page loads. There are different clients that have testimonials and in some cases, there are multiple testimonials from the same client. I have the query working that randomly displays two videos from the custom post type (while filtering out a …
Category: Web

Division of numbers from contours in opencv in python for cnn

I want to separate numbers in suppose 7638 into different images which can be predicted individually using cnn. By finding contours how can I divide each contour into separate image in python. To be more clear: How can I divide https://www.letter2word.com/products/americana-numbers into 0,1,2,3..9 into individual images using the concept of contours in opencv in python so that the resulting images can be predicted by cnn classifier and later all the results written together to give the number in image(initial) as …
Category: Data Science

Error migrating from live website to localhost

I'm trying to move a Wordpress installation in a web hosting to a localhost installation for development. I followed this tutorial (Section Manually Move a Live WordPress Site to Local Server, for now I'm not allowed to install plugins, so I must do it manually). I'm using MAMP Free edition and followed all the steps in the aforementioned tutorial. But when I tried to open the site in the local installation I got the message (In Safari): Safari cannot open …
Category: Web

Cross-Validation for Unsupervised Anomaly Detection with Isolation Forest

I am wondering whether I can perform any kind of Cross-Validation or GridSearchCV for unsupervised learning. The thing is that I have the ground truth labels (but since it is unsupervised I just drop them for training and then reuse them for measuring accuracy, auc, aucpr, f1-score over the test set). Is there any way to do this?
Category: Data Science

title tag for custom post type remove taxonomy name from title tag

So it appears I am missing a vital pice of information somehow to make my custom post type title tag behave. everything else works fine. my current - simple - scenario is this : wordpress 3.8, twentytwelve theme, wpizza plugin (I'm the author of this , so that's what the questions relates to really), nothing else I registered the wppizza custom post type and taxonomies like so: /******************************************************* [register custom post type] ******************************************************/ public function wppizza_register_custom_posttypes(){ $labels = array( 'name' …
Category: Web

Should I resample my dataset?

The dataset that I have is some text data consisting of path names. I am using TF-IDF vectorizer and decision trees. The classes in my dataset are severely imbalanced. There are a few big classes with a number of samples more than 500 and some other minor classes with a number of samples less than 100. Some are even smaller (less than 20). This is real data collected, so the chance where the model seeing minor class in actual implementation …
Category: Data Science

Cron schedule not updating after run

Cron-jobs are incredibly slow in my website. I created this small script, outside of the Wordpress environment, just to test the response time of WP Cron: <?php //Method which does a basic curl get request function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); //getinfo gets the data for the request $info = curl_getinfo($ch); //output the data to get more information. print_r($info); curl_close($ch); return $data; } get_data('http://www.example.com?wp-cron.php?doing_wp_cron=1486419273'); These …
Category: Web

approach for predicting machine failure using maintenance history

I have been struggling with this problem for a while now and I finally decided to post a question here to get some help. The problem i'm trying to solve is about predictive maintenance. Specifically, a system produces 2 kinds of maintenance messages when it runs, a basic-msg and a fatal-msg, a basic message indicates that there is a problem with the system that needs to be checked (its not serious), a fatal-msg on the other hand signals that the …
Category: Data Science

How to get custom fields in a post when published

add_action( 'publish_post', 'sm12_publish_post' ); add_action( 'save_post', 'sm12_publish_post', 20 ); //After save meta value function sm12_publish_post( $postid ){ /** some checks */ if( "publish" != get_post_status( $postid ) ) return; $post= get_post($postid); $sub = 'test subject'; $mgs = 'test message'; wp_mail( '[email protected]', $email, $mgs); } I need to get the custom fields to my frontend (Laravel) from Wordpress Backend. The post was successfully saved, and I was able to get the Post ID and title, but I can't fetch the values …
Category: Web

Is there anyway to classify the category on give amazon reviews using python

I am trying to find a model or way to classify text which falls into a category and its a positive or negative feedback. For ex. we have three columns Review : Camera's not good battery backup is not very good. Ok ok product camera's not very good and battery backup is not very good. Rating : 2 Topic :['Camera (Neutral)', 'Battery (Neutral)'] My Whole Dataset is like above and Topic is not standard one , Topic value is based …
Category: Data Science

How do I extract these vocal features using Python?

I'm creating a model to predict, based on several acoustic features, the probability that a person has a certain disease, using this dataset: https://archive.ics.uci.edu/ml/datasets/parkinsons. These are the features: MDVP:Fo(Hz) - Average vocal fundamental frequency MDVP:Fhi(Hz) - Maximum vocal fundamental frequency MDVP:Flo(Hz) - Minimum vocal fundamental frequency MDVP:Jitter(%),MDVP:Jitter(Abs),MDVP:RAP,MDVP:PPQ,Jitter:DDP - Several measures of variation in fundamental frequency MDVP:Shimmer,MDVP:Shimmer(dB),Shimmer:APQ3,Shimmer:APQ5,MDVP:APQ,Shimmer:DDA - Several measures of variation in amplitude NHR,HNR - Two measures of ratio of noise to tonal components in the voice RPDE,D2 - Two …
Category: Data Science

Enqueue All Stylesheets Found In a Theme Folder

Is there a built-in Wordpress function that will allow you to enqueue all stylesheets for a particular theme? I have a directory structure that looks like: -my-custom-theme -css -header.css -footer.css -functions.php I want to load all CSS files found in the my-custom-theme/css folder
Category: Web

extract features from low resolution

I have medical images and need to extract features from the layer before the classification layer using VGG for example but the resolution of the images is not efficient... Are the features without improving this resolution will not be affected or do I need to improve the resolution before extracting the features? I was doing processing in color images for extracting the features using VGG by this processing preprocess = T.Compose([ T.Resize(256, interpolation=3), T.CenterCrop(224), T.ToTensor(), T.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, …
Category: Data Science

How is the input given to the NeuMF architecture?

I was going through this neural recommendation paper (Fig. 2). I want to implement it from scratch in Tensorflow. The thing I don't understand is how is the input given to this architecture. Can someone explain with a small example? If I am right the embedding latent factor has to be $M\times K$ and $N\times K$ after passing through the embedding layer? If I have $Users \times Items$ rating matrix- [[2, NaN, 4], [3, 1, NaN], [4, NaN, 5]] They …
Category: Data Science

Why do Transformers need positional encodings?

At least in the first self-attention layer in the encoder, inputs have a correspondence with outputs, I have the following questions. Isn't ordering already implicitly captured by the query vectors, which themselves are just transformations of the inputs? What do the sinusoidal positional encodings capture that the ordering of the query vectors don't already do? Am I perhaps mistaken in thinking that transformers take in the entire input at once? How are words fed in? If we feed in the …
Category: Data Science

How to add a shortcode to an HTML image tag

I want to add a timestamp to use as unique id for conversion tracking. I have a [[timestamp]] shortcode on my site. In text it works fine, but the shortcode does not work when placed inside the src attribute of an image tag, e.g.: <img src="http://example.com/transaction_id=[[timestamp]]"> Does anyone know a solution to this issue? The shortcode I use: // Do TimeStamper Shortcode ( timestamper() ) function timestamper( $atts ){ if (!is_admin()) { add_filter('widget_text', 'do_shortcode', 11); } $time = current_time( 'timestamp' …
Category: Web

how load content as pop-up using ajax

There's a way to use ajax to load the content from single.php or a custom .php like ajax-single.php like this page does it: https://yellowimages.com/all/objects/apparel-mockups/ also like them show the URL from the post when you click on the link, I hope somebody can help me with this because I can't find a way to do it yet. EDIT 1: I use the next code on my index.php to load the post titles with the permalink: <div id="single-post-container"></div> <div class="wrap"> <?php …
Category: Web

PCA and orange software

I am analysing if 15 books can be grouped according to 6 variables (of the 15 books, 2 are written by an author, 6 by an other one, and 7 by an other one). I counted the number of occurrences of the variables and I calculated the percentage. Then I used Orange software to use PCA. I uploaded the file. selected the columns and row. And when it comes to PCA the program asks me if I want to normalize …
Category: Data Science

Where do I USE add_rewrite_rule?

I need to add a RewriteRule to my site. I have tried in .htaccess with no luck, it doesn't get parsed, so I'm all but giving up on that. I found the documentation on add_rewrite_rule, but have no idea where I'm supposed to use it. I am not writing a plugin. I need to put in one simple rule. I went to the functions.php file in what is the current theme folder. Is this the one I use? I inserted …
Category: Web

About

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