How to deal with missing data for Bernoulli Naive Bayes?

I am dealing with a dataset of categorical data that looks like this: content_1 content_2 content_4 content_5 content_6 0 NaN 0.0 0.0 0.0 NaN 1 NaN 0.0 0.0 0.0 NaN 2 NaN NaN NaN NaN NaN 3 0.0 NaN 0.0 NaN 0.0 These represent user downloads from an intranet, where a user is shown the opportunity to download a particular piece of content. 1 indicates a user seeing content and downloading it, 0 indicates a user seeing content and not …
Category: Data Science

Get publish post link?

Is there a way I can call a link so when clicked it publishes the post via the ID I provide? I have get_delete_post_link( $postID ) set fine, and would like to do the same to make a draft go to published, or if you can't publish post, make it pending. I also have this code running in my functions.php file so may be also a way to call this if a link is clicked.
Category: Web

Clustering finite size points

I'm looking for a clustering algorithm for a set of points that also have a radius (aka circles). Effectively I have a set of circles each with parameters (x, y, r). Just taking the circle's centre is no good for large circles. For example if I have a small circle close to the edge of a large circle I want them to be in the same cluster. My current solution is to create a new set of points that spatially …
Topic: clustering
Category: Data Science

Pagination at category doesnt work with same name of page

i have a problem with my pagination but only at category page. I'am not developer, and i try fix it from few days. My pagination working if i make different name of pages for main BLOG, and category of BLOG, but if is the same, doesn't work... I would like set everywhere "blog/category/?strona=4" and "category/?strona=4". For example now if i have 3 pages at main page of blog, on category doesn't work page 1 2 and 3, page 4 and …
Category: Web

How to add a target to a link

Is there a filter I could use to get and change the html output of a link? I would need to add a target="_blank" in some cases. I'm using the filter post_link to change the url itself where neccessary, but I would need to be able to modify the html part as well. I cannot find correct filter, I ran into a "edit_post_link" filter, but that didn't do the trick as it seems like it's working only at the back-end. …
Category: Web

How do I read a dat file, for which I don't know its structure?

Is there any way to at least read the text from the dat file. I have its corresponding mdf file hence I know what all data and columns are there in it. How do I figure out the contents in my dat file. Because all that I am getting currently is some gibberish even if I am opening it in binary mode. from asammdf import MDF dat_file = r"C:\Users\HPO2KOR\Desktop\Work\data1.dat" mdf_file = r"C:\Users\HPO2KOR\Desktop\Work\data1.mdf" df = mdf.to_dataframe() mdf = MDF(mdf_file) df.head() which …
Category: Data Science

Add .html permalink to post if specific category

I followed this helpful guide (update 2) Giving specific category posts its own permalink structure returns 404 that creates the following permalink if the category “Foodguide” is selected: /foodguide/25/post name slug.html (Category/post Id/post name.html) Here is the code that I am using in functions.php: //Rewrite URLs for "Foodguide" category add_filter( 'post_link', 'custom_permalink', 10, 3 ); function custom_permalink( $permalink, $post, $leavename ) { // Get the category for the post $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->cat_name == "Foodguide" ) …
Category: Web

Tensorflow training with batch size of (1, None, features), but model expects extra dimension

I've made an autoencoder like below, to accept variable-length inputs. It works for a single sample if I do model.fit(np.expand_dims(x, axis = 0) but this won't work when passing in an entire dataset. What's the simplest approach in this case? import numpy as np import tensorflow.python.keras.backend as K from tensorflow.python.keras.layers import Input, LSTM, Lambda from tensorflow.python.keras.models import Model def repeat(x): step_matrix = K.ones_like(x[0][:, :, :1]) latent_matrix = K.expand_dims(x[1], axis = 1) return K.batch_dot(step_matrix, latent_matrix) timesteps = None features = 2 …
Category: Data Science

Upload file could not be moved to wp-content/uploads

I know it has been asked over and over again on the internet and i spend hours digging deeper into the web. But the no answer so far. Why we get this error when you upload a file The uploaded file could not be moved to wp-content/uploads I tried various file persimission on folders and files in the ftp. Tried a fresh install WP. I tried this code define( 'UPLOADS', 'wp-content/uploads' ); I tried adding the path in the wp/options.php …
Category: Web

Block a specific url request

I probably have a plugin that makes a request to an URL slowly down my website. At the moment I'm still debugging the issue but, in the meantime, is there a way to prevent Wordpress to request this URL? I know there's the rule define('WP_HTTP_BLOCK_EXTERNAL', true); but it actually blocks every request.
Category: Web

Three data sets in one plot in Tableau

The goal is to plot three data sets in one plot: (DATE1_GOOD, DATE1_BAD); (DATE2_GOOD, DATE2_BAD); (DATE3_GOOD, DATE3_BAD). Unfortunately, I'm getting all possible combinations: So now the task is to combine the three diagonal plots into one and delete the rest since they make no sense. I tried dragging the axes but the result is not what I'm looking for, I get: (DATE3_GOOD, DATE1_BAD); (DATE3_GOOD, DATE2_BAD); (DATE3_GOOD, DATE3_BAD): I'm new to Tableau, is it even possible to do what I want? …
Topic: tableau
Category: Data Science

How to Get Category Name When Export Products

I'm writing an export plugin for WooCommerce. I want to print the product categories and subcategories in separate columns while exporting the products in the plugin I developed. My code is as below. function wpae_wp_all_export_csv_headers( $headers, $export_id ) { global $wpdb; $last_id = $wpdb->get_var( 'SELECT id FROM ' . $wpdb->prefix . 'bek_export' . ' ORDER BY id DESC LIMIT 1 '); if ( $export_id == $last_id++ ) { $additional_headers = array( 'Category 1', 'Category 2', 'Category 3', 'Category 4', 'Sub-Category …
Category: Web

PyTorch: LSTM training loss not decreasing; starting at very high loss

I am training an LSTM to give counts of the number of items in buckets. There are 252 buckets. However, I am running into an issue with very large MSELoss that does not decrease in training (meaning essentially my network is not training). I've tried all types of batch sizes (4, 16, 32, 64) and learning rates (100, 10, 1, 0.1, 0.01, 0.001, 0.0001) as well as decaying the learning rate. In fact, with decaying the learning rate by 0.1, …
Category: Data Science

Model Performance on external validation Set really low?

I am using the LGBM model for binary classification. My train and test accuracies are 87% & 82% respectively with cross-validation of 89%. ROC-AUC score of 81%. But when evaluating model performance on an external validation test that has not been seen before, the model gives a roc-auc of 41%. Can somebody suggest what should be done?
Category: Data Science

Cannot dequeue Elementor Font Awesome css

I am using the same below code to dequeue many other styles but it is not working for Elementor, and a couple of others. function enqueue_content(){ wp_dequeue_style( 'elementor-icons-shared-0' ); wp_dequeue_style( 'elementor-icons-fa-solid' ); wp_dequeue_style( 'elementor-icons-fa-regular' ); add_action('wp_enqueue_scripts', 'enqueue_content', 20); I have also tried the method described on their support: https://docs.elementor.com/article/286-speed-up-a-slow-site EDIT: It seems as if the styles I can't dequeue are loading from a different, parent wp-content folder (it is a multisite).
Topic: php css Wordpress
Category: Web

SGD versus Adam Optimization Clarification

Reading the Adam paper, I need some clarificaiton. It states that SGD optimization updates the parameters with the same learning rate (i.e. it does not change throughout training). They state Adam is different as learning rate is variable (adaptive), and can change during training. Is this the primary difference why Adam performs (for most cases) better than SGD? Also, it states that it is computationally cheaper, how can this be given that it seems more complex than SGD? I hope …
Category: Data Science

Add sub variations in product page

Is there any way to add specific variations switches in woocommerce sites. Suppose I want to create a phone cover/case website. When user selects a design, it will ask for phone brand. Like iPhone, Redmi or OnePlus. Then there comes another drop-down menu with list of different models of selected brand. Already tried variation swatches and product variation swatches. Is there any way or plugins to do like this? TIA
Category: Web

Add a role and give admin priviledges

I am creating a Super Admin role in wordpress Roles. $capabilities=array(); add_role('Administrator', 'Administrator', $capabilities ); add_role('Super Admin', 'Super Admin', $capabilities) ); So while adding a new user I got the Role Option Super Admin. So I added a Super User . Now When I login to wp-admin It gives me error saying: you do not have sufficient permissions to access this page. What more I have to do to make it work. I dont want to use any pluggin. I …
Category: Web

Neural Network One-hot Feature concatenation

I'm trying to add features to a model with two one hot encoded features. The features are defined like this. vocabulary = "ACGU" mapping_characters = list(vocabulary) integer_mapping = {x: i for i,x in enumerate(list(vocabulary))} n1 = [integer_mapping[word] for word in df[1][i]] Afterwards I'd like to add an additional one dimentional feature. If I use a concatenate layer, this means the model I'm using will go from (N, L, 4) dimensions per sample to (N, L, 5) dimensions, with the one-hot …
Category: Data Science

What could be the problem leading to the result that a model can never perfectly overfit?

I tried to fit my model on a small batch of 128 samples for binary classification. The model should be powerful enough as it has hundreds of thousands of parameters. It should be able to overfit to 100% accuracy. However, it only fts to 96% for the best. It is about the same as when I train it on 30,000 samples. So, I tried the following but all failed: use a smaller batch of 16 samples, it still cannot overfit …
Category: Data Science

How can I store sources, effective dates, and confidence for every property in a knowledge graph?

What I am wanting to do is ensure that every property in a knowledge base comes from at least one source. I would like to ensure that every edge is spawned (or at least explained) by some event, like a "claim" or "measurement" or "birth." I'd like to rate on a scale the confidence that some property is correct, which could also be inherited from the source's confidence rating. Finally, I want to ensure that effective date(s) are known or …
Category: Data Science

SQL query - get a featured image's alt / alternative text

I am writing some SQL queries to get post data out of a database for certain posts (so WP functions are not an option). I am trying to get post IDs, post URLs, post featured image URLs and associated alt text for the featured images. Alt text is held in the postmeta table with the meta_key '_wp_attachment_image_alt'. The query below works for everything except alt text. I am confident I need to use a left join because I want all …
Category: Web

Split in 2 columns add to cart button and variable forms

I'm struggling to separate variation form from the add to cart button in 2 columns. Here is what I need: The data inside the squer comes from a third party plugin called "TM Extra Product Options" I'm using WP Bakery to build the layout as a "content template". I've created these shortcodes: /* from tm extra options plugi. show final price */ function preco_final() { do_action( 'teste' ); } add_shortcode('precofinal', 'preco_final'); /*from tm extra optins plugin. show extra fields */ …
Category: Web

WP didn't redirect to canonical category URL

I have a problem with canonical redirect. mydomain.com/mycat is the correct category URL but the following URL works too: - mydomain.com/asdfa/mycat - mydomain.com/1234/mycat - mydomain.com/anythingyouwant/mycat And all these URLs show the category mycat... The canonical is mydomain.com/mycat and now Google give results with bad URLs. Can you please help me because I didn't understand why. I have the same template on other website and when we try to go to mydomain.com/asdfa/mycat, WP redirect to the canonical URL mydomain.com/mycat
Category: Web

Whole time column in csv file convert into UTC (epoch) using python

I have a dataset with time and columns. I want to plot a graph with time and value. I tried many methods but didn't come proper graph. Because I have a time series. Then I thought I will convert time into UTC then try to plot it. But I didn't have any idea how to convert the whole column into UTC. Can anyone help me to solve this error? time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.mktime(time.strptime("2008-09-17 14:04:00", "%Y-%m-%d %H:%M:%S")))) This code is for only …
Category: Data Science

DB-Scan with ring like data

I've been using the DBScan implementation of python from sklearn.cluster. The problem is, that I'm working with 360° lidar data which means, that my data is a ring like structure. To illustrate my problem take a look at this picture. The colours of the points are the groups assigned by DBScan (please ignore the crosses, they dont have anything to do with the task). In the picture I have circled two groups which should be considered the same group, as …
Category: Data Science

Binary document classification using keywords for a very small dataset

I have a set of 150 documents with their assigned binary class. I also have 1000 unlabeled documents. Each document is about the length of a journal paper. Each class has 15 associated keywords. I want to be able to predict the assigned class of the documents using this information. Does anyone have any ideas of how I could approach this problem?
Category: Data Science

Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?

I am developing a WordPress plugin and wants to run a background task that calls an API and updates database table. Now, the API can only give results for 5 DB entries in one go and for 500 entries in my table, I have to make 100 API call. The API has allowed TPS quota of 1 and also in every 40 minutes, its old response expires which means I need to update my table if any entry is older …
Category: Web

Restrict heading level in Gutenberg block `core/heading`

I'm building a simple Gutenberg Block that lets the user create just headlines and lists. I've got a solution, but the user can select any heading level she or he wants to. How I can I restrict the core/heading block to e.g. heading level H4? The crucial part in my edit.js is this: return ( <div {...blockProps}> <InnerBlocks onChange = { onChangeContent } allowedBlocks={ ['core/list', 'core/heading'] } /> </div> )
Category: Web

How to access "default" property of attribute in Gutenberg

In a Gutenberg block I try to read the value of an attribute's default property, so that I can find out in the transformation routine (to another block type) if any give attribute still has the default value. With this.props.attributes I only see the values of attributes, but I need their "meta data". One sample declaration in registerBlockType would look like: attributes: { amount: { type: 'integer', default: 1 }, // ... }
Category: Web

Woocommerce how to update variable product price programitically?

I want to update woocommerce variable product price by code. Here I wrote some code,, its create product but not update variable price: $post = array( 'post_title' => 'Product Title', 'post_content' => '', 'post_status' => 'publish', 'post_type' => "product" ); $new_post_id = wp_insert_post( $post ); wp_set_object_terms ($new_post_id,'variable','product_type'); /** * Add product attribute. */ $attr_names = array( 'Length' => array( '12', '13','14','15' ) ); $attr_data = array(); foreach ( $attr_names as $attr_name => $attr_values ) { $attr_sanitized_name = 'pa_' . sanitize_title( …
Category: Web

How do I predict with a Keras model on a dataset similar to how preprocessing.image_dataset_from_directory is formatted

I was wondering if anyone has written code where I can read from a directory of image (not having a subfolder inside to represent a "class") and then running model.predict() on it. I do not want to setup a subfolder because it's usually named as a class since this folder will be unseen and unlabelled data. Here is my code attempt which does not work: model = tf.keras.models.load_model('Classification_model') data_augmentation = keras.Sequential( [ layers.experimental.preprocessing.Rescaling(1./255) ] ) dataset = tf.data.Dataset.list_files("test/*.JPG", shuffle = …
Category: Data Science

Rewrite comment form post ID on submit

I have a WordPress comment form, with a custom field (added with the Advanced Custom Field plugin) where the visitor can chose from a options (these are page IDs). When submitting the form, I want this select value to replace the comment_post_ID that by default adds the current page ID. What I'm trying to achieve is having a global comment form on just one page and then for the visitor to select a page (in our case, these are medical …
Category: Web

About

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