How to add pagination to custom page

I am using the loop in my custom page template as you can see in my code. Only 2 posts must be shown and for the rest I should be able to have pagination. <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array ( 'posts_per_page' => 2, 'post_type' => 'post', 'category_name' => 'news', 'category' => 1, 'paged' => $paged ) ); // The Loop while ( have_posts() ) : the_post();?> <div class="news-page-content-wrapper"> <div class="news-page-content"> <h1><a class="read-more"href="<?php the_permalink(); ?>"><?php the_title();?></a></h1> …
Category: Web

Query posts only with featured image

I want to query 6 posts, but only those which have a featured image attached. I am using meta_key method for this with WP_Query as such: $args = array( 'post_type' => 'post', 'meta_key' => '_thumbnail_id', 'post_count' => 6 ); $query = new WP_Query($args); Followed by <?php while($query->have_posts()) : $query->the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_post_thumbnail('thumbnail'); ?> <?php endwhile; ?> This doesn't seem to work. The query is returning more than 6 posts and also those which don't have a featured …
Category: Web

Null Inputs/Inhibiting Inputs & Outputs with Scikit-Learn MLPRegressor

I'm trying to build a general predictive model of a model of a machine. I've got a variable number of sensor inputs, and I'd like to create a MLPRegressor that can estimate outputs from the input values. I know I can create individual AIs to model each individual output (ie. if I have 5 inputs, I can make 5 different AIs with 4 inputs each). But given that I have some large numbers of inputs, I was hoping for a …
Category: Data Science

Select only post id and meta value with WP_Query

I'm developing a simple rank plugin, which allows visitors to like the posts and also shows the total like scores for each tag in the plugin's admin page. I need both post IDs (in order to reach the tag data of them) and like values. This is my query at the moment: $args = array( 'meta_key' => '_Like', 'orderby' => 'meta_value', ); $query = new WP_Query($args); But this query returns the complete post object, it's not efficient for the memory. …
Category: Web

How to implement hierarchical labeling classification?

I am currently working on the task of eCommerce product name classification, so I have categories and subcategories in product data. I noticed that using subcategories as labels delivers worse results (84% acc) than categories (94% acc). But subcategories are more precise as labels, what's important for the whole task. And then I got an idea to first do category classification and then based on the results continue with subcategories within the predicted category. The problem here is that I …
Category: Data Science

semantic segmentation using kmeans or mean shift

i know what semantic segmentation is and i know how to do semantic segmentation using deep learning but my question here can i do semantic segmentation with a traditional way like kmeans or mean shift ckustering? here's what i tried to do import numpy as np import cv2 from sklearn.cluster import MeanShift, estimate_bandwidth #from skimage.color import rgb2lab #Loading original image originImg = cv2.imread('test/2019_00254.jpg') # Shape of original image originShape = originImg.shape # Converting image into array of dimension [nb of …
Category: Data Science

How to predict a mathematical progression with keras

I try the following model for a many-to-many recurrent network: [170] [682] [2730] | | | o ------- o -------- o ----- o ----- o / | \ / | \ / | \ [2, 2, 3], [2, 10, 11], [2, 42, 43] {t=1} {t=2} {t=3} {t=4} {t=5} The model should be the following: x1* (x2+x3), Where [ x1=constant ]. [ x3=x2+1 ]. [ x2=x1* (x2+x3) of previous time {t-1} ] This model should return the result of [ x1* …
Category: Data Science

Agglomerative Hierarchial Clustering in python using DTW distance

I am new to both data science and python. I have a dataset of the time-dependent samples, which I want to run agglomerative hierarchical clustering on them. I have found that Dynamic Time Warping (DTW) is a useful method to find alignments between two time series which may vary in time or speed. I have found dtw_std in mlpy library and scipy.cluster.hierarchy in SciPy in order to cluster my data. From the scipy docs, I find that I could use …
Category: Data Science

Is it possible for the (Cross Entropy) test loss to increase for a few epochs while the test accuracy also increases?

I came across the question stated in the title: When training a model with the cross-entropy loss function, is it possible for the test loss to increase for a few epochs while the test accuracy also increases? I think that it should be possible, as the Cross Entropy loss is a measure of the "distance" between some 1-hot encoded vector to my model's predicted probabilities, and not a direct measure of my model's accuracy. But I was unable to find …
Category: Data Science

Show Custom Post Type by Author

I would like to set up a function in my functions.php file in a theme so that when a custom-post-type is being viewed, if the user clicks the author name in the post, it only shows CPTs by that author, but on the main blog if they click the author name it will only show the blog posts of that author. I already have the author names showing in my custom post and normal post meta and I have an …
Category: Web

Which machine learning algorithms can be used for trajectory classifications?

I am working on project for clustering of air objects based on their trajectories. Like I would like to train a model on a dataset of different flying object's trajectories so later I can predict what type of object is based on trajectory data. Now trajectory data include 4 things (Altitude, Longitude, Latitude, and Time). So based on set of such dataset we may be able to classify objects like plane, rocket, missile, etc. What I cannot figure out is …
Category: Data Science

Post in bulk based on category template

Let's start with an example of what I want to do. take a look at hardreset.info / devicesfaq.com as you can see, the articles are almost the same, they only change few keywords / or based on title (device name) let's say I have the same categories and a custom article for each one (hard reset, check imei, delete google account, etc). Ok, now I want to post in bulk in all the categories I choose (check imei, hard reset, …
Category: Web

custom query to get posts

I want to create custom links like mydomain.com/custom_page/cat=ABC&tag=XYZ So that when a user clicks on the link s/he can see all posts in the category 'ABC' having tag 'XYZ' For this I've created a custom template with the following code <?php /* Template Name: MyCustomTemplate */ ?> <?php get_header(); ?> global $wp_query; get_query_var( 'cat' ); get_query_var( 'tag' ); <?php get_footer(); ?> I don't know how to query for the posts in the category 'ABC' with the tag 'XYZ' I checked …
Category: Web

Interpreting the variance of feature importance outputs with each random forest run using the same parameters

I noticed that I am getting different feature importance results with each random forest run even though they are using the same parameters. Now, I know that a random forest model takes observations randomly which is causing the importance levels to vary. This is especially shown for the less important variables. My question is how does one interpret the variance in random forest results when running it multiple times? I know that one can reduce the instability level of results …
Category: Data Science

One-hot encoding with values other than 1

I was thinking if I have an input which has 36 possible values, and I make it as 36 inputs where exactly one of them is non 0, what is optimal value for each of the non 0 inputs? It may be: [1, 0, 0,....,0] [0, 1, 0,....,0] [0, 0, 1,....,0] Or: [36, 0, 0,....,0] [0, 36, 0,....,0] [0, 0, 36,....,0] Or even: [6, 0, 0,....,0] [0, 6, 0,....,0] [0, 0, 6,....,0] In order this feature to have same impact …
Category: Data Science

Trying to re-direct users to specific page based on an ACF variable

I have a case where I have an ACF variable that is stored within a users profile and based on that variables state I need to redirect to one of two pages once the user logs in. This is just a true or false value that will represent if a user has logged in before. I have tried using wp_redirect to do this and it does sort of work but seems to run excruciatingly slow and sometimes will briefly get …
Category: Web

Resize header image

How can I access to the css file where is the header's background image? background: url("http://xxx.es") no-repeat scroll center top / 1600px auto transparent; It's not in the style.css
Category: Web

Rule of thumb for good number of features when dealing with grouped data

I have a classification problem on clinical data where I have multiple samples for each patient. So the samples related to the same patient are somehow dependent from each other. I know that is not possible to know a priori the optimal number of features to use, but there are some rule of thumb that works in many cases. My question is: are those rules valid also in my case? In particular, I should relate the number of features to …
Category: Data Science

Is wp-admin/about.php required? Can i omit it from my website

There is a page in wordpress available by default(accessible from wp-admin), the url is as follows: https://mywebsite.com/wp-admin/about.php I'am considering to remove this page, or block access to it however I understand that some wp-admin resources are required for proper functioning of WP websites Hence why i want to confirm and ask whether or not I can omit wp-admin/about.php from my wordpress website? If I dont remove it it might be indexed by google.
Category: Web

Calculate an ambiguity score based on topic models and Hellinger distance

I am trying to calculate some sort of ambiguity score from text based on topic probabilities from a Latent Dirichlet Allocation model and the Hellinger distance between the topic distributions. Let’s say I constructed my LDA model with 3 topics, these topics are related to basketball, football, and banking, respectively. I would like some kind of score that says that if the topic probabilities of a document is Basketball: $0.33$, Football: $0.33$, and Banking: $0.33$, that document is more ambiguous …
Category: Data Science

*Just curious* I erroneously used hook add_action() instead of add_filter() and there was no error and the result was correct. Why is that?

While working on a project I used the incorrect hook type add_action() which does not exist, yet there was no error notice and the correct result returned. I only realized it was wrong while searching for the method along with the $hook_name name in the package and it was not found, and when I checked the code reference page, it showed that it is add_filter(). Why does it still work?
Category: Web

Getting content from custom fields of different pages on a single page

I want to get content from one custom field of different pages along side their page titles and I'm using the following code: <?php $mypages = get_pages( array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'child_of' => 53, 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish' ) ); foreach( $mypages as $page ) …
Category: Web

how to retrain model with periodic new features?

I've trained a gradient boosting classification model. But, suppose i've a set of fixed features F1,F2....Fn and new features which are added weekly (no. of actions done in that week). So, after 2 weeks dataset to be trained on is : Fixed Dynamic F1 ,F2 .....Fn W1 ,W2 After 3 weeks Fixed Dynamic F1 ,F2 .....Fn W1 ,W2, W3 How do we approach this problem on production server, is there any approach available which allow model to be retrained on …
Category: Data Science

Display a specific category in a focused area of my site

I've been trying to change the code of my WordPress site. Rather than showing "trending posts" which is determined by post_views_count, I simply want to show posts from a certain category. The code, as it stands is: if ( !function_exists( 'getCrunchifyPostViews' ) ) { function getCrunchifyPostViews($postID){ $count_key = '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.' Views'; } } if ( !function_exists( 'setCrunchifyPostViews' ) ) { function setCrunchifyPostViews($postID) { $count_key …
Category: Web

Were attachment media settings removed from Wordpress?

In the past, when selecting a picture in the media library, you could see the "attachment display settings". I installed wordpress 5.3.2, I uploaded an image to the media library. I don't see attachment display settings anymore. This is also nowhere to be seen in the image block of wordpress. Was it removed, or is it my installation of wordpress?
Category: Web

generate custom permalink based on a custom field

I'm newbie to the Wordpress. So far I have a custom post type called 'property'. This post type has one custom field called 'property_city'. In WP-admin - permalink setting, I have selected Post name option. So, posts of this custom post type have URLs like: http://xxx.local/properties/edge-apartments/ http://xxx.local/properties/northgate-point/ What I want to have those URL to be generated using the city of the property and also I want to change properties prefix with student-properties like that: http://xxx.local/student-properties/Manchester/edge-apartments/ http://xxx.local/student-properties/Chester/northgate-point/ I have tried …
Category: Web

How to optimize hyperparameters in Bert?

I am using the BERT model in order to classify stereotypes in sentences. I wanted to know if there is a way to automate the optimization of hyperparameters such as 'epochs', 'batchs' or 'learning rate' with some function that is similar to 'GridSearchCV' (I don't know if this function can be used in the BERT model, if it can be used let me know) so I don't have to test combinations of values 'by hand'. I attach part of my …
Category: Data Science

Table of contents (TOC) plugin is not showing header tag

I made a post template using meta box(custom field). If I put data into metabox, the template part (contents with h2, h3, p) shows up at the bottom of post (not on post edit page). However, every TOC plugins use "revisions" to check if there is h2 or h3 like this code. public function widget( $args, $instance ) { global $ht_kb_toc_tools, $wp_query; if( ! is_singular() ) return; if ( ! isset( $wp_query ) ) { return; } if( is_a($ht_kb_toc_tools, 'HT_KB_TOC_Tools') …
Category: Web

Wordpress Multisite login_redirect to primary blog and specific page based on role

I'm stumped trying to redirect my users to a specific page on their primary blog when they login to the root/main site on a MU setup. I have the site editors with a specific 'editor' role and then tenants with 'subscriber' role. The following code (in a plugin in MU folder) redirects the users with one of the 3 editor roles but will not redirect those with 'subscriber' role. Any help would be greatly appreciated! Thanks! public function login_redirect($redirect_to, $requested_redirect_to, …
Category: Web

Get negative predicted value in Support Vector Regresion (SVR)

I am doing Covid-19 cases prediction using SVR, and getting negative values, while there should be no number of Covid-9 cases negative. Feature input that I was used is mobility factor (where have negative data) and daily cases of Covid-19. Kernel that I used is RBF kernel. Can anyone explain why I am getting negative values? are the independent variable (mobility) that I used influence that?
Category: Data Science

Predicting products to be sold in a store - problem formulation

I have a data from a store for the products that sold since more than 5 years. Each sell process has a customer id, date, and the quantity of the product. I want to build a machine learning model to predict the products that will be sold in the next day/s for each of the customers, giving that I have N products (~2k) and M customers (~50). I am not able to formulate this problem. It's a regression task (probably), …
Category: Data Science

Can human error on ImageNet dataset be non-zero if the same person who created the dataset in the first place took the test?

Somehow I can't digest the reason given in the here. Which is binary classification is done when creating the dataset; However, multi-class classification on the test would give some error. It might be if a different person took the test, but what if the same person who created the test took the test? Can we see a few errors? One thing that is bugging me is that if someone thinks that an object in the image is a dog with …
Category: Data Science

WordPress post/page pagination (page links) to go back to the first section

I am using the page links: https://codex.wordpress.org/Styling_Page-Links as: wp_link_pages(array('before'=>'', 'next_or_number'=>'next', 'previouspagelink' => '«', 'nextpagelink'=>'»')); I want to add an additional link, For eg: X, which upon clicking will take the user to the first section. Is it possible to achieve this using this function? Any help is much appreciated.
Category: Web

How are the embedding and context matrices created and updated in word embedding?

I am struggling to understand how word embedding works, especially how the embedding matrix $W$ and context matrix $W'$ are created/updated. I understand that in the Input we may have a one-hot encoding of a given word, and that in the output we may have the word the most likely to be nearby this word $x_i$ Would you have any very simple mathematical example?
Category: Data Science

High Performance Classification or Similarity Algorithim for Mixed Data Types?

I have a database holding 10-ish features that describe different breeds of dogs. They are mostly categorical features, but some provide ranges for values. Here's a demo representation of the database, showing the mixture: |Breed|Min_Height|Max_Height|Min_Weight|Max_Weight|sub_cat|is_friendly| |---------------------------------------------------------------------| |Dober|20 |20 |40 |52 |sport |FALSE | |Pood |15 |25 |35 |45 |water |TRUE | ... As you can see, the data is mixed and the ranges have some overlap from entry to entry. Say I receive an input of: |height|weight|sub_cat|is_friendly| |---------------------------------| |16 |43 …
Category: Data Science

Python: How to construct a joyplot with values taken from a column in pandas dataframe as y axis

I have a dataframe df in which the column extracted_day consists of dates ranging between 2022-05-08 to 2022-05-12. I have another column named gas_price, which consists of the price of the gas. I want to construct a joyplot such that for each date, it shows the gas_price in the y axis and has minutes_elapsed_from_start_of_day in the x axis. We may also use ridgeplot or any other plot if this doesn't work. This is the code that I have written, but …
Category: Data Science

About

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