Two loops on archive page

I have 2 loops on the archive page. I want the first loop to display the 2 last posts of the category and the second loop offset 2 last post! <div class="top-posts"> <?php if (have_posts()) : while(have_posts()) : the_post();?> <div class="content"> <?php the_post_thumbnail('archive'); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> </div> <?php endwhile;?> <?php endif;?> </div> <div class="primary-posts"> <?php if (have_posts()) : while(have_posts()) : the_post();?> <h2><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h2> <?php endwhile;?> <?php endif;?> </div>
Category: Web

Semantic Search

There is a problem we are trying to solve where we want to do semantic search on our set of data, i.e we have a domain specific data (example: sentences talking about automobiles) Our data is just a bunch of sentences and what we want is to give a phrase and get back the sentences which are: Similar to that phrase Has a part of sentence that is similar to the phrase Sentence which is having contextually similar meanings Let …
Category: Data Science

Check if distribution per week is the same

I have sales by customer (b2b) and by date. I want to check if the distribution per day inside weeks remains the same from week to week. Initial dataset Customer Date Sales Alpha 2019-02-23 527 Beta 2019-02-23 642 Alpha 2019-02-24 776 ... ... ... Beta 2021-07-28 1236 I transformed it into Customer Week Monday Tuesday Wednesday Thursday Friday Saturday Sunday Alpha 201906 0.2202 0.15799 0.178202 0.160449 0.1528 0.130214 0.000067 Beta 201906 0.20573 0.183979 0.182207 0.179824 0.140596 0.107601 0.000061 ... ... …
Category: Data Science

Neural Network for solving these linear algebra problems

Intro There are several questions on this site about whether or not machine learning can solve specific problems. The answer (in my words) seems to be: "Yes, trivially, if you choose a model to learn your specific problem, but you sometimes may choose a model that can't represent/approximate the correct hypothesis." I would like to choose a neural network model where, a priori, all I know is that the input is a "linear algebra" kind of function. The Problem I …
Category: Data Science

Export to csv adding html to file

I am trying to export results to a csv file using the following code. The export appears to work, but when I open the file, it contains the html code from the page. Any help is appreciated. ob_start(); global $wpdb; $domain = $_SERVER['SERVER_NAME']; $table = $wpdb->prefix . "qi_project_requests"; $filename = "export.csv"; $sql = $wpdb->get_results("select * from $table"); $header_row = array( 'Date Submitted', 'Requestor Name' ); $data_rows = array(); foreach ($sql as $data) { $row = array( $data->date, $data->rname ); $data_rows[] …
Category: Web

Algorithm suggestion for anomaly detection in multivariate time series data

I have time series data containing user actions at certain time intervals eg Date UserId Directory operation Result 01/01/2017 99:00 user1 dir1 created_file success 01/01/2017 99:00 user3 dir10 deleted_file permission_denied unique userIds > 10K 10 distinct operations and 4 distinct Results I need to perform anomaly detection on user behavior in real time. Any suggestions on which method I should use? The anomaly needs to flag whether some user operations are outliers A very small subset of input data will …
Category: Data Science

Naive Bayes TfidfVectorizer predicts everything to one class

I'm trying to run Multinomial Bayes classificator on various balanced data sets and comparing 2 different vectorizers: TfidfVectorizer and CountVectorizer. I have 3 classes: NEG, NEU and POS. I have 10000 documents. NEG class has 2474, NEU 5894 and POS 1632. Out of that I have made 3 differently balanced data sets like this: text counts: NEU NEG POS Total number NEU balance dataset 5894 2474 1632 10000 NEG balance dataset 2474 2474 1632 6580 POS balance dataset 1632 1632 …
Category: Data Science

Python: SARIMAX Model Fits too slow

I have a time series data with the date and temperature records of a city. Following are my observations from the time series analysis: By plotting the graph of date vs temperature seasonality is observed. Performing adfuller test we find that the data is already stationary, so d=0. Perform Partial Autocorrelation and Autocorrelation with First Seasonal Difference and found p=2 and q=10 respectively. Code to Train Model model=sm.tsa.statespace.SARIMAX(df['temperature'],order=(1, 1, 1),seasonal_order=(2,0,10,12)) results=model.fit() This fit function runs indefinitely and does not reach …
Category: Data Science

Why activation function is not needed during the runtime of an Word2Vec model

In Word2Vec trainable model, there are two different weight matrix. The matrix $W$ from input-to-hidden layer and the matrix $W'$ from hidden-to-output layer. Referring to this article, I understand that the reason we have the matrix $W'$ is basically to compensate for the lack of activation function in the output layer. As activation function is not needed during runtime, there is no activation function in the output layer. But we need to update the input-to-hidden layer weight matrix $W$ through …
Category: Data Science

Insert wp gallery shortcode into custom textarea

Is there a way to insert wp gallery shortcode into custom metabox textarea ? I would like to have something like this: New metabox in post/page with textarea and below textarea there are a button to open wp browse media gallery lightbox. then when we have done to select few images as gallery, click the "insert gallery" button will insert the shortcode to the textarea custom field. is it possible ? Thanks ====== Update: ====== I was able to show …
Category: Web

Multiclass Classification with Decision Trees: Why do we calculate a score and apply softmax?

I'm trying to figure out why when using decision trees for multi class classification it is common to calculate a score and apply softmax, instead of just taking the averages of the terminal nodes probabilities? Let's say our model is two trees. A terminal node of tree 1 has example 14 in a node with 20% class 1, 60% class 2, and 20% class 3. A terminal node of tree 2 has example 14 in a node with 100% class …
Category: Data Science

How to display custom taxonomy

I have created city taxonomy in back end and i have added mumbai,pune,nashik city in city taxonomy like bellow snipe. My problem is that when i click the city for example mumbai i want display the all product in the mumbai city which i have set from the product tab means that product is in mumbai city category. I have tried with bellow code but not getting any thing. Custom Taxonomies display Template file used to render the Archive Index …
Category: Web

How to remove the two duplicate values

How to remove the two duplicate values Example I have the variable 1 $help_brother: $help_brother = '30,45,12,13,14,15'; And the variable 2 Force World: $force_world = '45,12,15'; The result must be: Result: '30,13,14'; Any help is welcome. Thanks in advance.
Topic: php Wordpress
Category: Web

counter vector fit transform cosine similarity memory error

count_matrix = count.fit_transform(off_data3['bag_of_words']) I have count_matrix shape with count_matrix.shape (476147, 482824) cosine_sim = cosine_similarity(count_matrix, count_matrix) I think the matrix size is too big to cause this memory error --------------------------------------------------------------------------- MemoryError Traceback (most recent call last) in ~/venv/lib/python3.6/site-packages/sklearn/metrics/pairwise.py in cosine_similarity(X, Y, dense_output) 1034 1035 K = safe_sparse_dot(X_normalized, Y_normalized.T, -> 1036 dense_output=dense_output) 1037 1038 return K ~/venv/lib/python3.6/site-packages/sklearn/utils/extmath.py in safe_sparse_dot(a, b, dense_output) 135 """ 136 if sparse.issparse(a) or sparse.issparse(b): --> 137 ret = a * b 138 if dense_output and hasattr(ret, "toarray"): 139 …
Category: Data Science

Can I use a Shortcode output as an HTML attribute value?

Within a span, the shortcode output works: <span>[sola_testimonials_count type='all']</span> Result: <span>5,205</span> But as an attribute value, it doesn't get parsed: <span data-value="[sola_testimonials_count type=\'all\']"></span> Result: <span data-value="[sola_testimonials_count type=\'all\']"></span> This is a third-party plug-in, but I obviously have the code and can manipulate it. Is there a way I can get the shortcode to parse as an HTML attribute value? I'm not a Wordpress developer so forgive me if this is an obvious answer. Many thanks!
Category: Web

Deep Learning - Find most similar images - Triplets vs Pairs

I am working with Python, scikit-learn, keras and with 450x540 rgb images of front-faced watches (e.g. Watch_1, Watch_2). My aim to run an autoencoder or a Siemese Neural Network to find the most similar watches among them. However, I am not sure if I will get better results by comparing pairs of images or triplets of images. As it is defined in this research paper, triplets of images consist of one target image, one image which is (more) similar to …
Category: Data Science

At the first epochs, what will segmentation model get?

I am working at a semantic segmentation problem now, with 5-classes task. But when I running on validation function and output my probablities map. I found that with the background class (the extra class for nnUNet, named class-0), the probalities always up to nearly 1, even when running on much epochs. But the other foreground classes (as class-1 to class-6), probalities can't range to 1.0 the highest. But at least that I can recognize the outline of the target, but …
Category: Data Science

A multivariate linear regression for explaining impacts of the predictors

I am trying to build a multivariate linear regression and the main goal is to understand how the various features impact the response by understanding the coefficients and their confidence intervals. For this reason, I chose multivariate linear regression because the coefficients are intuitive to interpret and from the standard error and the degrees of freedom, I can get the 95% confidence interval of the coefficients. Therefore, I can tell what the impact of a unit increase of a predictor …
Category: Data Science

Does eval loss decreasing slower than train loss indicate overfitting?

I am training a binary classifier using an efficientnetv2 model with a 1M image dataset where I do a 60/20/20 split. Does this graph mean that the model is over-fitting? I can see that the train loss is going down much faster than the eval loss but the eval loss is still going down and the accuracy is going up. Accuracy may seem to be low but it is actually a pretty decent amount for the problem I am working …
Category: Data Science

Woo commerce product quantity wise SKU

In woocommerce i have multiple readymade garment VARIABLE product all have multiple variations with size and colour, I want now variations stock wise SKU field Suppose I have variations of t-shirt yellow XL size 5 quantity I want 5 SKU fields. So in short i want product quantity wise SKU in VARIABLE & simple product both. Thanks
Category: Web

tax_input in wp_insert_post partly not working

I'm inserting a post via wp_insert_post() and in the $args the tax_input looks like this: 'tax_input' => array( "programmas" => 'Modern Family', "zenders" => 'ABC', ), But what is happening: the "programmas" is correctly inserted but the "zenders" is not. I'm 100% sure that I've spelled these custom taxonomies correctly. When running the function, a post is correctly inserted except for the "zenders" part. I have all the capabilities, because I am the administrator and I've inserted my user id …
Category: Web

How to find out the dimensions of an image

I am using this python code to read this image file image = img.imread('/content/drive/My Drive/Colab Notebooks/rusty.png') How do I determine the dimension of this image array? I printed out len(image), len(image[0]) and len(image[0][0]) Which probably shows what's the len of each submatrix...
Topic: python
Category: Data Science

WP_LIST_TABLE bulk action

I created a class extend WP_List_Table and created method for bulk actions like this : function get_bulk_actions() { $actions = array( 'synchronize' => 'Synchronize', 'delete' => 'Delete from Shareino', ); return $actions; } and another method for processing their : function process_bulk_action() { //Detect when a bulk action is being triggered... if ('delete' === $this->current_action()) { wp_die('Items deleted (or they would be if we had items to delete)!'); } } This action's display in a dropbox but when i select …
Category: Web

Transfer learning between Language Model and classification

Following this fast.ai lecture, I am trying to understand the mechanism of Transfer Learning in NLP from a general Language Model (LM) to a classification problem. What is exactly taken from the Language Model training? Is it just the word embeddings? Or is it also the weights of the LSTM cell? The architecture of the neural net should be quite different - where in a LM you would output a prediction after every sequence-step, in a classification problem you would …
Category: Data Science

User Following System

I have a custom plugin which allows users to follow each other. The follow and unfollow functionality works by ajax which is fine but there are just a few bugs that need sorting out which I am unsure as to how I fix them. When you first come on to a new user's page there is a button that is meant to appear which says "Subscribe" and when you click that button, the ajax fires and then upon success the …
Category: Web

Custom Header added within Dashboard pages, is this possible with custom template files?

I created a custom template and called it Header Home"header-home.php" <?php /** * Template Name: Header Home */ ?> <?php if( have_post() ) { while( have_post() ){ the_post(); } } ?> Then on my front page i call it with <?php get_header( 'home' ); ?> Now, when i create a page, and use template "Header Home" and add my html content inside, it's not showing on the front page at all. Shouldn't the loop grab those html and add it …
Category: Web

Feature Selection algorithm/library for CRF

I am using the Conditional Random Fields CRF suite scikit-learn wrapper algorithm. I have read on the literature various approaches for feature selection, but I cannot find any on that package or, generally, available ones for CRF. Would you know any libraries (Python preferred) or easy to implement algorithms for this purpose? Update I tried using the scikit-learn feature selector's library but does not work for 2 reasons: 1) the CRF takes as an input list of lists of dicts …
Category: Data Science

Wp-admin Redirection loop after moving to subdirectory

I've moved my Wordpress files from public_html to a subdirectory public_hmtl/my-site.com. I've changed my .htaccess in the public_html directory by RewriteEngine on RewriteCond %{HTTP_HOST} ^my-site.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.my-site.com$ RewriteCond %{REQUEST_URI} !my-site.com/ RewriteRule (.*) /my-site.com/$1 [L] I've configured my database and wp-config.php too, to: define('WP_HOME','https://www.my-site.com'); define('WP_SITEURL','https://www.my-site.com'); define('RELOCATE',true); But when I want to login per wp-admin the path seems to be like: wp-login.php?redirect_to=https%3A%2F%2Fwww.my-site.com%2Fmy-site.com%2Fwp-admin%2F&reauth=1 Do you have any idea? Thanks Kamil
Category: Web

Validation data shall be in broken down into batches or not?

I am using fit_generator to train the model. The training dataset is being read from a generator function which gives data in a constant batch size. Now I want to know what approach shall I adopt for validation data. Shall I make a generator for the validation set or load it completely into memory and use it in fit_generator? Note: Validation dataset is fitting into memory quite easily therefore batching is an option for me.
Topic: training
Category: Data Science

Encode each comma separated value in Pandas

I have a dataset Inp1 Inp2 Inp3 Output A,B,C AI,UI,JI Apple,Bat,Dog Animals L,M,N LI,DO,LI Lawn, Moon, Noon Noun X,Y AI,UI Yemen,Zombie Extras For these values, I need to apply a ML algorithm. Hence need an encoding technique. Tried a Label encoding technique, it encodes the entire cell to an int for eg. Inp1 Inp2 Inp3 Output 5 4 8 0 But I need a separate encoding for each value in a cell. How should I go about it. Inp1 Inp2 …
Category: Data Science

chart x-axis spacing terminology question

In the following hand made charts I show some value for years. In the first chart I've evenly spaced each year. On the second chart I've spaced them relativelly to their actual year value within time (i.e 2016 is closer to 2017 than 2010). Is there a terminology for the spacing of the second chart? Imagine building a software which would have a toggle control to switch the view from A to B. How would you call it?
Category: Data Science

Is it possible to create a custom admin page for users?

I want to greatly restrict the user's authority in the website. I don't want to give the user access to the admin console but I do want to allow the user to edit their username, email, and password. Everything I've done so far is custom (lots of wp_query) and so I haven't used any plugins yet and would like to keep it that way if I can. Therefore, is it possible to create a custom page where the user can …
Category: Web

AttributeError: 'NoneType' object has no attribute 'landmark'

I am on windows, using jupyter notebook, Mediapipe:Holistic Solution, Python, tensorflow. I am using a Holistic solution and trying to get the left hand, right hand and pose landmarks. I am giving my webcam feed as input. When I run the code below, there are no errors and everything is good. After this, I was trying to check if I got the landmarks by using "results.left_hand_landmarks.landmark" and length of the landmarks using "len(results.left_hand_landmarks.landmark)" I am getting this "AttributeError: 'NoneType' object …
Category: Data Science

About

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