jQuery works in console but not when in a file

This is the code. jQuery(document).ready(function() { jQuery( '#menu-item-927' ).on( 'ubermenuopen', function(){ jQuery('.site-content').addClass('blur'); }); }); It works when I use it in the console but does not work when in a JS file. Here are the things I have tried: Enqueued script with jQuery dependency wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/custom.js', array( 'jquery' ), '1.0.0', false ); and custom.js does show up in the source. Added jQuery(document).ready(function(). P.S: ubermenuopen is an events API from the UberMenu plugin.
Category: Web

Deleted Page Still In WordPress Database

After permanent trashing/deleting a previous page with the same permalink, I still can't make a page save its permalink without the "-2" added to the end. How should I solve this problem? Choosing "Quick edit" and change the slug and save will not change the permanent link too. I'm not familiar with Wordpress coding or working with database inside phpmyAdmin. If I have to deal with changing SQL, please advice me in steps and easy way. Thank you in advance.
Category: Web

Determining the optimal number of clusters by elbow method

I have a dataset that consists of 700 categorical columns and around 6000 rows. I created 2-50 clusters with the k-mode algorithm and plotted the cost function to determine the optimal number of clusters. This is what the plot looks like I am unsure how determine what is the optimal number of clusters. The cost function seems to converge at 48 clusters, which seems alot considering i have only 700 categorical columns. On the other hand at 24 clusters the …
Category: Data Science

Getting categories id for all products in cart

What I'm trying to do is to take the categories for products which are in the cart. Then check via some conditions what category id is and show different notice. So far I have this /** * Cart collaterals hook. * * @hooked woocommerce_cross_sell_display * @hooked woocommerce_cart_totals - 10 */ $categories = array( 39 ); foreach ( WC()->cart->get_cart() as $cart_item ) { if ( has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) { $found = true; // Set to true break; // …
Category: Web

How to set the same number of datapoints in the different ranges in correlation chart

I am beginner in working with machine learning. I would like to ask a question that How could I set the same number of datapoints in the different ranges in correlation chart? Or any techniques for doing that? . Specifically, I want to set the same number of datapoints in each range (0-10; 10-20;20-30;...) in the image above. Thanks for any help.
Category: Data Science

All custom links suddenly lack href attributes

Short version: before updating to WP 4.5 and on a day when the only known change was adding a page to a submenu via the navigation menu admin all of the menu links of type Custom Link where we specify a URL suddenly lost their href attributes. Links of type Page still have theirs. After much experimentation I confirmed that deactivating all plugins did not change this but setting TwentyFifteen as theme corrected it. Theme authors are no longer available …
Category: Web

Discrete values as target variable

I have discrete values in the target variable(Exactly 13 different values in total) . When I am giving that as input to Random forest Classifier ,it gives error that input as continuous. And if I give it to regressor it is predicting a value between the discrete values. How can I treat this problem
Category: Data Science

Glyphicons Dont Show in WordPress Plugin Only

I have a very simple WordPress plugin that shows a menu/admin page. The page contains Glyphicons - Font Awesome. These glyphicons are never showing. I cannot figure out why because I know the font-awesome css file is being loaded correctly and I know that the admin pages HTML works fine outside of a wordpress plugin and shows the Glyphs. What could possibly be going wrong? <?php /** * Plugin Name: TEST Use FA Icons * Plugin URI: * Description: Test …
Category: Web

WP_Query retuning empty array in rest api

I recently started writing a rest api for my plugin. I need to access some custom posts however WP_Query is returning an empty array when I'm querying the db. There is the custom post type declaration. // custom post type declaration add_action('init', 'register_plugin_custom_post_type'); function register_plugin_custom_post_type() { register_post_type('my_post_type', [ 'label' => "A name", 'StackExchange exemple', 'public' => false, 'show_in_rest' => true ]); } Rest api route registration add_action('wp_rest_init', 'my_plugin_rest_init_callback'); function my_plugin_wp_rest_callback() { register_rest_route('my-rest-route', '/endpoint', [ 'method' => 'GET', 'callback' => 'rest_api_callback', …
Category: Web

How to crop thumbnail size, from both width and height sides

I would like to crop in particular dimensions but I need that to be done on both height and width of the image. Here is a small illustration of what I am trying to do: When I try to use this snippet: add_image_size( 'custom-thumbnail', 160, 160, true); or even add_image_size( 'custom-thumbnail', 160, 160, array( 'center', 'center' )); it only crops the horizontal side and so this is what I get: And this is what needs to be achieved: Is there …
Category: Web

Why does wp_remote_post returns an empty body response on certain endpoints?

Im gonna make this brief; Im using wp_remote_post to do a POST request to an external API. My local development environment looks something like "http://website.test". As of now I am requesting to a QA version of this API so the protocol of the endpoints is HTTP. The problem is that the $response object always returns an empty body. If I copy the exact request JSON that im sending over, and the exact HTTP URL of the API, and use it …
Category: Web

wp-login.php?redirect_to=https problem

wp-login.php?redirect_to=https problem Please forgive me if I am posting in the wrong place but I am here to see if you can help me with some minutes of your time. The problem is a website showing persistent internal errors all around the wp-login.php. I am able to login and access the front end with no difficulties. I have tried to debug but the errors do not show up o any pages. I have tested the theme, the plugins, etc etc …
Category: Web

How to get sentence embedding using BERT?

How to get sentence embedding using BERT? from transformers import BertTokenizer tokenizer=BertTokenizer.from_pretrained('bert-base-uncased') sentence='I really enjoyed this movie a lot.' #1.Tokenize the sequence: tokens=tokenizer.tokenize(sentence) print(tokens) print(type(tokens)) 2. Add [CLS] and [SEP] tokens: tokens = ['[CLS]'] + tokens + ['[SEP]'] print(" Tokens are \n {} ".format(tokens)) 3. Padding the input: T=15 padded_tokens=tokens +['[PAD]' for _ in range(T-len(tokens))] print("Padded tokens are \n {} ".format(padded_tokens)) attn_mask=[ 1 if token != '[PAD]' else 0 for token in padded_tokens ] print("Attention Mask are \n {} ".format(attn_mask)) …
Category: Data Science

Decision boundary in a classification task

I have 1000 data points from the bivariate normal distribution $\mathcal{N}$ with mean $(0,0)$ and variance $\sigma_1^2=\sigma_2^2=10$ with the covariances being $0$. Also there are 20 more points from another bivariate normal distibution with mean $(15,15)$ with variance $\sigma_1^2=\sigma_2^2=1$ and with the covariances being $0$ again. I used the least squares method to calculate the parameters of the decision bounday $\theta_0 + \theta_1 x_1 + \theta_2 x_2=0$, that is $$\theta = (X^T X)^{-1}(X^Ty)$$ where $y$ is a column matrix with …
Category: Data Science

Dataframe has no column names. How to add a header?

I am using a dataset to practice for building a decision tree classifier. Here is my code: import pandas as pd tdf = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/breast-cancer-wisconsin.data', sep = ',', header=0) tdf.info() The column has no name, and i have problem to add the column name, already tried reindex, pd.melt, rename, etc. The column names Ι want to assign are: Sample code number: id number Clump Thickness: 1 - 10 Uniformity of Cell Size: 1 - 10 Uniformity of Cell Shape: 1 - …
Topic: pandas python
Category: Data Science

How to find arbitrary object (toast) using image detection

I'm a beginner, I've done object detection using Haar Cascades on faces as well as ImageAI. So maybe not a complete beginner. I'm working on a simple regression project for my resume, predicting low long a piece of toast has been in the toaster based on an image of the toast. I need a way to draw a rectangle on an image containing pictures of toast to extract them and use in my CNN model. That has been proven to …
Category: Data Science

Approaches on grouping/clustering network device data

So I come from more of a computer science background, and recently have been trying to find a solution to a data-centered problem. I would like to try experimenting different data-science methods on my dataset, but I'd like to decide on which ones are the most interesting, and most importantly, why (and why some are not interesting for that case) : basically, the more you tell me about your thought process, the better, I'm trying to learn from it ! …
Category: Data Science

Possible to set new user's site time zone at user creation using Gravity Forms?

Let's say I have a multisite network running with Buddypress and has Gravity Forms installed with the GF User Registration addon. During new user/site registration, is there ANY way I can have the user set their time zone by selecting from a Gravity Form drop down menu the timezone they want? Basically, I don't want the user to have to login to WP and then go to General settings to change their time zones. Is there any way of achieving …
Category: Web

LSTM for time series forcasting

I manipulate the time series using the different structures of the neural networks in order to make a prediction, and I wonder if there is a way to choose the parameters of the networks intelligently? from the characteristics of the signal, namely (trend, seasonality ...) can we choose these parameters that will make learning better?
Category: Data Science

Should I remove the trend from timeseries when using DeepAR

I saw that for some other algorithms for timeseries data it is advised to remove trend and seasonality before doing the prediction (ex: ARIMA and LSTM) I figured out from the paper that SageMaker's DeepAR deals internally with seasonality, but does the same thing stands for trend? Let's say I have multiple timeseries, where some of them have positive, and some have negative trend. Should I remove trend and then use DeepAR prediction, or should I just ignore it and …
Category: Data Science

Having a repeating custom field in admin custom post type, what I'd go better with, for DB's sake? ACF repeater or query a different post type?

I have: A main custom post type - 'Cards' - each post showing its ACF repeater custom field - 'operations' - with the following sub-fields: 'add/remove', 'amount, 'value', 'date'. Let's say the fully operational website will have 500 Cards posts, with about 50/100 operation rows each. What would be the less stressing solution, to keep querys and Database load reasonable? Keeping my first choice and use custom fields with ACF repeater, inside the Cards posts. Creating a dedicated custom post …
Category: Web

Can we intercept user_login and user_pass from a wp_login_form?

with my plugin, I have a login form. I use the wp_login_form() function of Wordpress. As you know, this function links to the wp-login page. But if the user_login is not present or if the email is empty in the database, an error will be present. My users come from an external database. Imagine the following situation: A user from my external database connects for the first time on the site, so he is not in the wp_users table of …
Category: Web

Empty Pdf file generated with FPDF library in WordPress plugin

I am currently implementing a pdf export functionality within a wordpress plugin i'm developing but the pdf file generated when i click on export button is empty. To implement the export i use FPDF library Ive put the code which uses FPDF in a function which is executed by the wp_ajax_ action hook. Here is the code: <?php require_once plugin_dir_path( __FILE__ ) . 'fpdf/fpdf.php'; function pdf_pull_wpse_212972() { $pdf = new FPDF('p','mm','a4'); $pdf->SetFont('arial','b',14); $pdf->AddPage(); $pdf->Cell(40,10,'Referrer URL',1,0,'C'); $pdf->Cell(40,10,'User IP Address',1,0,'C'); $pdf->Cell(40,10,'User Agent',1,0,'C'); …
Category: Web

What ways can i find two similar sets of customers use KNN?

I have a study where i want to find users similar to a set of users (SEED). My data looks like a pivot by customer e.g. sample of SEED looks like (note i drop cust_id): cust_id | spend_food | spend_nike | spend_harrods | 1 | 145 | 45 | 32 | 2 | 85 | 89 | 0 | 4 | 23 | 67 | 1900 | 5 | 84 | 12 | 900 | So to find users similar …
Category: Data Science

How to change "add to basket" button text in WooCommerce based on product category?

I've created CPT with my events and for each event I've created individual product in WooCommerce. Now I'm using this shortcode in my code <?php echo do_shortcode('[add_to_cart id="'.get_field('event_ticket').'" show_price = "FALSE"]'); ?> for displaying "add to basket" button placed on each event. Every event have Product Category "event" and now I want change default text on "add to basket" button, but only for those products which have 'event' Product Category. How can I do that?
Category: Web

How can I create a custom page for this error?

How can I create a custom page for this too many connections error page because I know it's because my server is overloaded? I wanted to show a custom error page instead of this when my website is overloaded by traffic.
Category: Web

How to inherit field value from parent post into in child / sub post

I have created a custom post type, called 'centres'. This CPT is hierarchical, ie, I can create child pages under each custom post. Centre1 Location1 Contact1 Centre 2 Location2 Contact2 I've defined a custom field called phone_number. This field is populated at the 'parent' level. Ie, Centre1, Centre2. I want to display the phone number on each child page. I don't want to have to add the phone number every time to each page, so would like to get or …
Category: Web

Minimum number of samples to train XGBoost without overfitting

When using Neural Networks for image processing I learned a rule of thumb: to avoid overfitting, supply at least 10 training examples for every neuron. Is there a similar rule of thumb for classifiers such as XGBoost, presumably taking into account the number of features and estimators? And, considering the 'curse of dimensionality' shouldn't the rule of thumb be that n_training is geometric in n_dimensions, and not linear?
Category: Data Science

Is there any way to artificially create a probability calibration for data coming from another model?

I have predictions, which come from a survival model, this model gives me very low probabilities, and I am not sure if they fulfill the real probability of the phenomenon. For example, I calculate $P\left( T\leq t+d \middle| T>t \right)$ and the probabilities are very low (with $d=180$). To summarize, I need these probabilities to be on average another number (let's say $0.2$). Is it possible to create an artificial calibration with only this number (the desired average) as the …
Category: Data Science

Getting a taxonomy's thumbnail url

This is how I am currently trying: $taxonomies = array( 'product_cat' ); $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'hierarchical' => true, 'child_of' => 0, 'childless' => false, 'get' => '', 'name__like' => '', 'description__like' => '', 'pad_counts' => false, 'offset' => '', 'search' => '', 'cache_domain' => 'core' ); $terms = get_terms($taxonomies, $args); …
Category: Web

expanding 1x1xn global average pooling output to the size of the input map HxWxn

I am trying to recreate the model in this paper : BiSeNetV2 There is one module called Context Embedding Block, in which Global Average Pooling is used to embed global information into the feature maps using a residual connection. In the figure provided in the paper, after global pooling and a 1x1 convolution, it mentions a broadcast operation that I traced back to this idea from another paper. Now, I find myself in front of a relatively easy thing, which …
Topic: pytorch python
Category: Data Science

About

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