How to create different media uploader frames / filter library depending on a custom action

Here is the thing. I am using the WP media uploader on the frontend. What I need is to have it behave differently depending on a certain action. I am attaching the media in a specific custom post type single page. This is a small excerpt from my code. I'm using this to trigger the media library. var uploader = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function(e){ // Some code here }); Then I am filtering the library …
Category: Web

splitting point in LightGBM?

I am not able to understand how the first root node is selected in LightGBM and how the splitting at nodes happens further. I read blogs and related documents and I understand that in this histogram-based splitting happens. But it is not clear after the bins are made what is the decision on the basis of which split happens. How is the best split decided? Please elaborate on this.
Category: Data Science

How do you extract speerate structures from a cluster of points in 2d cordinate

I have a bunch points in x,y that correspond to so physical processes. My goal to extract and group points based on the event/process the correspond to. The image attached shows a example of how the data looks like. By inspection you can clearly make out at least 2 curves that correspond to process I want. The data itself has a lot of noise and some false positive events. I have already played around with Dbscan and it doesnt quite …
Topic: clustering
Category: Data Science

How to arrange web scraped data in a table using R?

Original Code library(netstat) library(RSelenium) library(tidyverse) obj<-rsDriver(browser="chrome",chromever="101.0.4951.15",verbose=F,port=free_port()) remDr<-obj$client remDr$navigate('https://www.imdb.com/search/title/?year=2022&title_type=feature&') Title<-remDr$findElements(using='css','.lister-item-header a') lapply(Title,function(x) { x$getElementText()%>% unlist() }) o/p: [[1]] 1 "Doctor Strange in the Multiverse of Madness" [[2]] 1 "Senior Year" My attempts to arrange data in tabular form- 1.movies=data.frame(Title,stringsAsFactors=FALSE) view(movies) **Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure("webElement", package = "RSelenium")’ to a data.frame** 2.movies=data.frame(x,stringsAsFactors=FALSE) view(movies) **Error in data.frame(X, stringsAsFactors = FALSE) : object 'X' not found** 3.Part of original code tweaked- lapply(Title,function(x) { **t<-list(x$getElementText()%>% unlist())** }) l=data.frame("movie"=t,stringsAsFactors …
Category: Data Science

uncertainties in non-convex optimization problems (neural networks)

How do you treat statistical uncertainties coming from non-convex optimization problems? More specifically, suppose you have a neural network. It is well known that the loss is not convex; the optimization procedure with any approximated stochastic optimizer together with the random weights initialization introduce some randomness in the training process, translating into different "optimal" regions reached at the end of training. Now, supposing that any minimum of the loss is an acceptable solution there are no guarantees that those minima …
Category: Data Science

Does autoencoder with few images not work?

I am trying to load 2 images to an autoencoder but for some reason, it does not rebuild the input image. An autoencoder is supposed to compress and decompress an image. However, when passing two images with which it trains, it only shows a black color instead of the corresponding image. import keras from keras import layers # This is the size of our encoded representations encoding_dim = 32 # 32 floats -> compression of factor 24.5, assuming the input …
Category: Data Science

Magnific Popup - Add Caption to Images

My theme uses Magnific Popup as follows in theme.js /* add lightbox for blog galleries */ $(".gallery a[href$='.jpg'],.gallery a[href$='.jpeg'],.featured-item a[href$='.jpeg'],.featured-item a[href$='.gif'],.featured-item a[href$='.jpg'], .page-featured-item .slider a[href$='.jpg'], .page-featured-item a[href$='.jpg'],.page-featured-item .slider a[href$='.jpeg'], .page-featured-item a[href$='.jpeg'], .gallery a[href$='.png'], .gallery a[href$='.jpeg'], .gallery a[href$='.gif']").parent().magnificPopup({ delegate: 'a', type: 'image', tLoading: '<div class="loading dark"><i></i><i></i><i></i><i></i></div>', mainClass: 'my-mfp-zoom-in', gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] // Will preload 0 - before current, and 1 after the current image }, image: { tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', …
Category: Web

Convert minute duration (string) to float

I am trying to convert my time watched in a netflix show to a float so I can total it up. I cannot figure out how to convert it. I have tried many ways, including: temp['Minutes'] = temp['Duration'].apply(lambda x: float(x)) Error: ValueError: could not convert string to float: '00:54:45' 2022-05-18 05:21:42 00:54:45 NaN Ozark: Season 4: Mud (Episode 13) NaN Amazon FTVET31DOVI2020 Smart TV 00:54:50 00:54:50 US (United States) Wednesday 2022-05-18 I have pulled the day of week and Day …
Topic: time
Category: Data Science

Show posts from a single category by default using wordpress.com

I have a blog at wordpress.com on the legacy "Personal" plan. I blog about different but related subjects and categorise the posts accordingly. The blog was originally about one subject but, over time, the content diverged. One subject is more generally accessible while the second is more specialized. When someone visits my blog, can it show posts only from the more general category by default? For example, I could create a new page containing the "Blog Posts" block to show …
Category: Web

How to train millions of doc2vec embeddings using GPU?

I am trying to train a doc2vec based on user browsing history (urls tagged to user_id). I use chainer deep learning framework. There are more than 20 millions (user_id and urls) of embeddings to initialize which doesn’t fit in a GPU internal memory (maximum available 12 GB). Training on CPU is very slow. I am giving an attempt using code written in chainer given here Please advise options to try if any.
Category: Data Science

WordPress on Nginx - Missing admin/toolbar

Hi I've been trying to figure this out for quite some time now, but whatever I do nothing seem to work. I have a VPS setup running Nginx + Varnish with WordPress multisite. Everything works fine except the admin/toolbar when browsing the sites. It simply wont load. It loads in the admin area, but when viewing site it doesn't load. I have checked the "Show Toolbar when viewing site", and I have deactivated all plugins. Now I have even gone …
Category: Web

How can I imporve accuracy for text classification and mapping using SVM?

I am working on a problem where I need to predict the text corresponding to another text in my training data file. For example: if I have value like the software in one of my columns and another corresponding column holds a value adobe pdf for it then my algorithm should be able to predict the same for my test data as well. For example, if my test data has Tableau then the predicted category should be software corresponding to …
Category: Data Science

ServerSideRender not rendering in block editor, but output is in "apiFetch"

I'm building a dynamic block. All seems to be working fine, except it isn't actually rendering the block in the editor. It is doing something, because if I inspect the page source in the editor, the content that should be being rendered is on the page, but it's inside of an apiFetch: <script id="wp-api-fetch-js-after"> ... wp.apiFetch.use(..."content":{"raw":" \\my html is here ","protected":false,"block_version":1}, ... My edit code looks like this: import ServerSideRender from '@wordpress/server-side-render'; import { useBlockProps } from '@wordpress/block-editor'; export default …
Category: Web

How to create a classified section in place of comments_template

I am running a site where users can find great information about musical artists and their releases. Each release is a wordpress post. Each artist is a wordpress post. In my single-artist.php and my single-release.php, i use comments_template(); EDIT: here is my comments.php comment_form(); if (have_comments()) : $wantto= get_comment_meta( $comment_id, 'wantto', true ); echo '<ol class="post-comments">'; wp_list_comments(array( 'style' => 'ol', 'short_ping' => true, )); echo $wantto; echo '</ol>'; endif; It just shows a text box. Here's an example of a …
Category: Web

How do I link to a dynamic ACF button from a Custom Post type?

I have a custom post type archive that has articles that call some ACF content on each post. I've used WP_Query to pull these articles onto the archive page, and there's a button in each article that when clicked will open a modal window with images I've placed in an ACF repeater for the custom post. How do I call the modal window by that button without calling the other modal windows open? Here's my code for the archive page: …
Category: Web

Assigning a new document to a cluster based on keywords extracted and tf-idf

I have about 40 clusters of documents defined by a combination of k-means clustering algorithm and hand curation. For example, some of the clusters given by k-means are too noisy so they have been further subdivided. Now I want to assign new documents to these clusters. I found that it is possible to extract keywords using tf-idf based methods as mentioned here. My approach is to extract key terms from each of these clusters using tf-idf based method and I …
Category: Data Science

PAC Learnability - Notation

The following is from Understanding Machine Learning: Theory to Algorithm textbook: Definition of PAC Learnability: A hypothesis class $\mathcal H$ is PAC learnable if there exist a function $m_H : (0, 1)^2 \rightarrow \mathbb{N}$ and a learning algorithm with the following property: For every $\epsilon, \delta \in (0, 1)$, for every distribution $D$ over $X$, and for every labeling function $f : X \rightarrow \{0,1\}$, if the realizable assumption holds with respect to $\mathcal H,D,f$ then when running the learning …
Category: Data Science

The wp_blogmeta table is not installed. Please run the network database upgrade

We’re using WP Engine for web hosting. I originally manually turned on Multisite through wp-config.php & Tools > Network Setup. Since then, I've learned we need to use their Enable Multisite function to enable subdirectory multisite. When WP_DEBUG is on, we see a message: Notice: wp_check_site_meta_support_prefilter was called incorrectly. The wp_blogmeta table is not installed. Please run the network database upgrade. I then created wp_blogmeta manually using: CREATE TABLE IF NOT EXISTS wp_blogmeta ( meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, …
Category: Web

Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)

I am developing custom theme from scratch and creates a custom post type and getting this warning while editing custom post type. I also design custom Meta box with two input fields and using nonce in it. Any help removing these warning? Here is code of custom metabox in functions.php //Custom Metabox function register_book_meta_box(){ add_meta_box('book_meta_box_id', 'Book Detail','design_book_meta_box','books','advanced','high'); } add_action('add_meta_boxes','register_book_meta_box'); function design_book_meta_box($post){ wp_nonce_field(basename(__FILE__),'book_cpt_nonce') ?> <div> <label for="book-author">Author Name  </label> <input type="text" name="book-author" placeholder="Author Name" value="<?php echo get_post_meta( $post->ID, 'book-author-key', true );?>"> </div> …
Category: Web

Deriving Prediction Intervals for Orthogonal Distance Regression using `scipy.odr`

Questions How can I derive prediction intervals for predictions based on new observations from the output of scipy.odr? Is it also possible (or necessary) to take into account uncertainties in the new observations? Background I would like to perform a linear regression between two sets of variables, both of which have uncertainties associated with them, and also be able to derive prediction intervals as part of the output. I have identified Orthogonal Distance Regression (ODR) as a possible method by …
Topic: regression
Category: Data Science

How to Predict/Forecast street's Traffic based on previous values?

I have a dataset which has the following 5 columns: date, hour, day_of_week, street_id, counts My dataset has information about the number of cars that each street (same city) has in a given hour of a certain date, and I want to predict the traffic count that a certain street has in a given hour of a certain date. I think I could use certain variables depending on the day and hour that I want to predict, for example, if …
Category: Data Science

Get posts by category via ajax

In my page-members.php I output my list of categories <?php $args = array( 'orderby' => 'slug' ); $categories = get_categories($args); foreach ($categories as $category) { echo '<a href="' . get_category_link($category->term_id) . '"><div class="category-block">' . $category->name . '</div></a>'; } ?> I'd like for a click on those links to fill the right column with the posts of that category. I have a js file loaded for this page; my functions.php: if (is_page()) { global $post; if ($post->post_name == 'members') { wp_enqueue_script('jquery', …
Topic: ajax Wordpress
Category: Web

Clustering with hierarchical data dependencies

I am currently looking into how to cluster data with hierarchical dependencies. An example of a problem that I want to cluster: we would like to cluster cities to identify similar characteristics with respect to inhabitants. As input data, I have some characteristics such as the age, weight, height and sex of the inhabitants. Each city will therefore be modeled by a vector : ______________ _ _ number of people aged 20 years old | x_1 | number of people …
Category: Data Science

Visualizing 28 different variables with 28 different colors?

ColorBrewer seems to be very useful in selecting a color pallet to represent factors that have up to 12 possible values. I have 28. Is it a horrible idea to represent 28 variables with color? If so, could you suggest an alternative visual indicator? Currently I'm using the colors for column side colors in a heatmap shown below. As you can see, the Strain column is not very informative:
Category: Data Science

Added .html to Woocommerce permalink but pagination don't work!

I'm recently added this code to my Wordpress website to add .html for my product category. It worked okay with the category (http://mywebsite.com/parent-category/product-category.html) but when I clicked the pagination, the link turned into (http://mywebsite.com/parent-category/product-category.html/page/2) This is a code that i added to function.php on my site function wpse_178112_category_permastruct_html( $taxonomy, $object_type, $args ) { if ( $taxonomy === 'product_cat' ) add_permastruct( $taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%.html", $args['rewrite'] ); } add_action( 'registered_taxonomy', 'wpse_178112_category_permastruct_html', 10, 3 ); Please help, I'm just a Wordpress newbie . Thank …
Category: Web

Can't retrieve body params from PUT endpoint using formdata

I have one endpoint to create players, which is a PUT request to a certain route. While I was sending parameters via JSON, it was working fine, but now I need to upload a picture with data, so I switched to formdata format. This is the function running in the endpoint: public function put(WP_REST_Request $request) { ['foto' => $file] = $request->get_file_params(); if (!empty($file)) { if (!function_exists('media_handle_upload')) { require_once(ABSPATH . 'wp-admin/includes/image.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); } $attachmentId = media_handle_upload('foto', …
Category: Web

Custom fields not showing in custom post type

I'm putting together a basic landing page http://shurity.com/, and in trying to clean up my code, I wanted to replace some static content with dynamic content for the user. The element in question is the modal that pops up when you click subscribe...my text does not show up when I attempt to include it in the loop. The following code is a template file that matches the custom post type I created for the modal, and the post type has …
Category: Web

Change post format using custom field

I'm creating a theme using the CF Post Formats plugin. But I've run into some trouble I don't know how to solve. Here's what I want to be able to do: Create a new standard-format post Enter a url into the _format_link_url custom field If the custom field is not empty, on save/update, change the post format to 'link'; else, remain 'standard'. For whatever reason, I can't get set_post_format to work in this context (perhaps there's a conflicting update?). I …
Category: Web

How to input sets as features

Need advice on the best way to represent the below data to be fed into an ML algorithm (yet to decided on) This is from the online order processing domain. An order consists of a set of variable number of items. Each item can be located in different warehouses, again this is a variable number. The entire order with multiple items and items with multiple warehouses per item, needs to be processed as one training sample. The goal is to …
Category: Data Science

How do I turn off self-closing tags for markup in WordPress (for HTML5, or HTML4, for example)?

I want to use HTML5 in my WordPress theme, how do I turn off wptexturize? I don't mind WP adding breaks, but I want them to be <br> and not <br />. How do I get control over how those breaks show up in my code? EDIT: I only really care about the <br> tag issue, I don't mind the typographic changes it makes. EDIT2: Actually, I guess <img> tags matter too. Any self-closing standalone tags will matter here. So, …
Category: Web

Need term or method name for evaluation of CNN without ground truth using e.g. a regression model

I have the following problem, I have trained a CNN and I can evaluate the network in-sample. I want to use the trained model for the class prediction of images for which I have no ground truth. However, there are other features referenced to these images that I can implement in a regression model along with predicted labels to predict Y. The only way to evaluate somehow the CNN is to infer if the predicted labels have an effect on …
Category: Data Science

WordPress multisite dashboard not working..!

I have installed a multisite network in WordPress on my test server and it was working fine but when I did the same on my production server it's not working properly. When I try to login in wp-admin it opens perfectly fine but when I try to open dashboard of subsite, its dashboard loads without css and none of the links opens (every link showing file not found) while the default dashboard working perfectly fine. This setup is working fine …
Category: Web

About

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