How would you quantify an experience into a score without labeled data

How would you approach a scenario where you have to quantify an abstract notion like “customer experience” without having any labeled data? So basically what you have are bunch of variables that you know, more or less, how they affect the experience, but you don't know the "weights" of importance of each one. So e.g. if it is an experience from a food delivery service, then I have the ETAs for the order, ratings (not very reliable by the day), …
Category: Data Science

Create new folder and upload files to custom folder via wp_handle_upload

I am using wp_handle_upload to upload files from a theme template file. if ( ! function_exists('wp_handle_upload') ) require_once( ABSPATH . 'wp-admin/includes/file.php' ); $uploadedfile = $_FILES['attachedfile']; $upload_overrides = array( 'test_form' => false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile ) { //echo "File is valid, and was successfully uploaded.\n"; //var_dump( $movefile); $attachedfilelink=$movefile['url']; } I want to create a folder inside root / uploads directory with user name of who is uploading and upload the file inside the folder. …
Category: Web

Generate profile face from front face image

How can I generate profile face image, based on an input of a front face image? specifically, I'm more interested in doing it for illustrated characters. For example, given the input of the front face (left) of Homer Simpson, we'll generate his profile face (right): (source) I'm sure that that the technology exists, as evident by many "2D to 3D Avatar" results (here's one for example), so I figure what I'm looking for should be possible (and maybe easier, since …
Category: Data Science

Needed: Java library to calculate text readability/complexity

In principle the same as this but for Java (and ideally for multiple languages) (e.g. flesch reading ease, smog index, flesch kincaid grade, coleman liau index, automated readability index, dale chall readability score, linsear write formula, gunning fog etc). I guess there must be plenty of libs but I just cant find them ...
Topic: text java nlp
Category: Data Science

How to trigger "wp_handle_upload_prefilter" filter when uploading an image programatically?

I am sanitizing uploaded SVG files with wp_handle_upload_prefilter, example: // Example code add_filter( 'wp_handle_upload_prefilter', function($file) { if ( $file['type'] === 'image/svg+xml' ) { $this->sanitize( $file['tmp_name'] ); } } ); It works fine for files uploaded through the Media Library, however, if the file is uploaded programatically, it doesn't go through the filter. The reason I want to programatically upload an image is for testing purposes. I am uploading the file with wp_upload_bits function: $upload = wp_upload_bits( 'xss.svg', null, file_get_contents( $this->svg_path …
Category: Web

Too optimistic results with efficientnet v2 with cifar10

I'm trying to run efficient net with cifar-10 which should get high results, but not 100%. Here is my code: import tensorflow as tf import tensorflow_datasets as tfds import os , sys os.chdir('./models/efficientnetv2') sys.path.append('.') import effnetv2_model # Construct a tf.data.Dataset ds = tfds.load('cifar10', split='train') model = tf.keras.models.Sequential([ #tf.keras.layers.InputLayer(input_shape=[32, 32, 3],name="image"), effnetv2_model.get_model('efficientnetv2-s', include_top=False), tf.keras.layers.Dropout(rate=0.2), tf.keras.layers.Dense(10, activation='softmax'), ]) metrics = [tf.keras.metrics.Precision(), tf.keras.metrics.Recall(), tf.keras.metrics.AUC(),tf.keras.metrics.TopKCategoricalAccuracy(k=1)] dst=tfds.load('cifar10', split='test') model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=metrics) sample=None #take only 100 first samples images=[] labels=[] for i in range(50000): sample=next(iter(ds)) images.append(sample['image']) …
Category: Data Science

Logistic Regression optimal threshold is a negative value

I run the code below: import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn import linear_model import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression from numpy import sqrt from numpy import argmax from sklearn.metrics import roc_curve from sklearn.preprocessing import StandardScaler def standardize(variable): return (variable - np.mean(variable)) / np.std(variable) def normalize(x): return (x-x.min()/(x.max()- x.min())) data.columns = np.arange(len(data.columns)) trainX, testX, trainy, testy=train_test_split(X,y,test_size=0.5,random_state=2, stratify=y) # fit a model model = LogisticRegression(solver='lbfgs') model.fit(trainX, trainy) #yhat = model.predict_proba(testX) yhat = …
Category: Data Science

Category post count is not correct

When I go to Posts > Categories, some categories show that they have a post. See screenshot. But there are no posts linked to that category. When you click on that "1"-number, no posts are shown. This is an issue because my blog page shows the category title and description even if there are no actual posts linked to that category (Wedge-system - see screenshot). This is how I loop over all the categories and show the posts from that …
Category: Web

WP_Error on attribute + term insert

I want to add a product attribute (wc_create_attribute) & assigned terms (wp_insert_term) via the functions.php. Example: $args = array( 'name' => "Color", 'slug' => "color", 'order_by' => "menu_order", 'has_archives' => "", ); wc_create_attribute($args); $add = wp_insert_term( "Blue", 'pa_color', array( 'slug' => "blue" ) ); print_r($add); The wc_create_attribute() works fine, but when the wp_insert_term() runs it throws an error because of “Invalid taxonomy”. When I then reload the page, it works fine because then the taxonomy is not invalid anymore. So …
Category: Web

How to train deformable convolutions?

There is a concept in ML called deformable convolutions, instead of kernelling over rectangle filter, we use kernelling over learned shape. Whilst classic convolution is y(p_0) = sum(w(p_i) * x(p_0 + p_i)), deformable is y(p_0) = sum(w(p_i) * x(p_0 + p_i + d_i)). How to differentiate over d_i if it's a shift in coordinates but not in our space?
Category: Data Science

After form submission want to show success message in the form page

Admin side I submit form to admin-post.php. I want to print success message in the bottom of the form. Iam new in wordpress what i did shown below. admin.php?page=add-products form code <form action="<?php echo admin_url('admin-post.php') ?>" method="post"> <table> <input type="hidden" name="action" value="add_product_from_admin"> <tr><td>Name</td><td><input type="text" name="pr_name" id="pr_name"></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="pr_submit" id="pr_submit" value="Save Products"></td></tr> </table> </form> add_action( 'admin_post_add_product_from_admin', 'add_product_into_data_base' ); function add_product_into_data_base() { //some database operations wp_redirect(admin_url('admin.php?page=add-products&message=success')); }
Category: Web

using logsumexp in softmax

I saw this equation in somebody's code which is an alternative approach to implementing the softmax in order to avoid underflow by division by large numbers. softmax = e^(matrix - logaddexp(matrix)) = E^matrix / sumexp(matrix) logsumexp = scipy.special.logsumexp(matrix, axis=-1, keepdims=True) softmax = np.exp(matrix - logsumexp) I understand that when you log equations that use division you would then subtract, i.e. log(1/2) = log(1) - log(2). However, in the implantation of the code above, shouldn't they also log the matrix in …
Category: Data Science

How to create a complex Gaussian random noise with a specific covariance matrix

I am trying to generate a complex Gaussian white noise, with zero mean and the covariance matrix of them is going to be a specific matrix which is assumed to be given. Assume i to be a point on the grid of x axis, where there are N points on the axis. The problem is to generate a complex valued random noise at each point (let's call the random value at the point i as $y_i$), which obeys Gaussian distribution …
Category: Data Science

Rewriting a subdomain page on one WordPress installation to a parent domain on another

How can I use .htaccess to rewrite a a page on a subdomain to a page on the parent? (E.g. people visiting mysite.com/landingpage will see the content from dev.mysite.com/landingpage)? Ive been working to redesign a WordPress site, using a dev.mysite.com subdomain. The site isn't ready to replace the live WP site yet (mysite.com) but I need to map one of the pages to the old domain and make it public. Since all the work (template,database,etc) is on the subdomain, I …
Category: Web

Comparing performances of different models using hypothesis testing

A common workflow in applied ML is you train different models on some data and evaluate it on a particular test set. I have often seen people just selecting a ML metric based on their requirements and choosing ML models on the basis of that. But is the above process right ? Shouldn't we be ideally doing hypothesis testing and arriving at statistical and practical significance before saying model A > model B simply based on ML metric calculated on …
Category: Data Science

Display all categories but only if they have posts in them that have a specific tag assigned

I have a WooCommerce site and am working on the product tag pages. I want to display every product that is assigned to that tag, and break them up into their individual categories (this bit is working). The only issue I am having is it is displaying every single category, even if 0 products in the current tag have that assigned. <?php $tag_id = get_queried_object(); ?> <div id="product-list" class="product-list"> <?php // Get all products inside the current tag ?> <?php …
Category: Web

Custom page from wp admin area

I would like to display custom page from Wordpress admin area. My plugin code is as follows: add_action('admin_menu', 'apvr_admin_menu'); function apvr_admin_menu(){ add_menu_page(esc_html__("Virtual Reality Viever", APVR_TEXTDOMAIN), esc_html__("Virtual Reality Viever", APVR_TEXTDOMAIN), APVR_CAPABILITY, "apvr_settings", "apvr_settings_page", plugins_url('assets/menu.png', __FILE__)); } function apvr_settings_page(){ include("includes/settings.php"); } This displays a section within Wordpress admin area (Wordpress menu being on the left and top bar): From this section I would like to have an option to redirect to another page (in which there will be no other elements like …
Category: Web

Disable domain redirect

Desired behavior: http://www.situationware.com should stay at www.situationware.com, no registration required. Currently wordpress is automatically redirecting to the Amazon hostname ec2-107-22-241-162.compute-1.amazonaws.com, requesting users register, if I update wp-config.php by uncommenting DOMAIN_CURRENT_SITE I end up with a redirect loop to http://situationware.com/wp-signup.php?new=situationware.com As you'll see below I do have multisite installed as was working a few months ago before any upgrades to 3.6.1. I installed the WordPress MU Domain Mapping plugin, but didn't help and didn't hurt. I wasn't able to add a …
Category: Web

Creating a new prediction for the Keras.io BST model

The Keras.io example of a Transformer-based recommendation system is a great example for me to understanding neural networks in Keras. But how would you use the create_model_inputs() to get a new prediction of a non existing user through model.predict() without feeding array data like .predict(sc.transform(np.array([[0.26, 0.7, 3., 238., 6., 0., 0.,]]))) but by entering the strings/ints to make it more readable and use a variant for user testing? def create_model_inputs(): return { "user_id": layers.Input(name="user_id", shape=(1,), dtype=tf.string), "sequence_movie_ids": layers.Input( name="sequence_movie_ids", shape=(sequence_length …
Category: Data Science

Forward and backward process in pyTorch

When I write a network, do I have to write the whole forward property in nn.Module.forward()? I mean if I do some operations outside the net, does grad correctly flow? For example, I have two networks, in which the output of one is the input of the other(net1 -> midresults -> net2). If I do some operations on midresults(net1 -> midresults -> operations -> net2), can (net1+net2) be trained end to end?
Category: Data Science

Best way to set up "reviewed by" in Wordpress?

I would like to show both "author" (one or more) and "reviewed by" (just one person) for Wordpress posts and pages on my website. This would be for example a situation where an article is written by a content producer but the information has to be reviewed by an MD or other credentialed medical expert. This type of functionality is in my opinion pretty much a must on YMYL (your money, your life) type websites. My current understanding is that …
Category: Web

Discrete wavelet transform - DWT (beginner)

I recently stumbled upon this article : https://www.bportugal.pt/sites/default/files/anexos/papers/wp201612_0.pdf In the paper they use DWT and I am having trouble understanding how to construct them. Does anyone have a guide on where to start learning wavelets and slowly move to DWT? I am a beginner in this part so I am really trying to understand from step 0. I will apply the math in python. I have checked the others threads and the questions are to speicific, so let's try to …
Category: Data Science

Woocommerce inventory

I'm working on woocommerce project and I need to check inventory status via external API before I create order. It is a cash register system in physical store that I can't change. I'm using woocommerce_checkout_order_processed hook to add my logic here but I'm not sure how can I prevent order from saving if invenotry over API changed in meantime. So the flow I need here is: User wants to buy 10 items, adds them to cart User clicks 'Place Order' …
Category: Web

pre_get_post filter returns results when there should not be

I am trying to filter a CPT by an array of post ids using pre_get_post filter within my plugin. Everything works fine when there are post that match the ids, but when there are no post that match the ids I am getting all the post within the CPT that I am trying to filter in return. What I need id there are not post ids found (or post from the post ids) is the archive page to display the …
Category: Web

Traditional Predictive Analytics vs Machine Learning Methods

What is the difference between traditional predictive analytics done using statistics and its tools and, one using machine learning and deep learning? How are we leveraging machine learning and deep learning to make predictive models better? How to decide the boundary for when to use traditional models and, when to use ML and DL? We have a lot of efficient statistical tools available Stata, SPSS. They are easier to use. Also, computationally efficient. Thanks I am unable to find some …
Category: Data Science

Why and how Variational Inference underestimates variance?

I referred to the Quora link here as well, but could not understand clearly. Can anyone please help me understand why and how variational inference underestimates the variance of the true posterior distribution with some theory or mathematical calculations? [EDIT]: Adding my understanding of the Quora answer based on a visualization. The red line is p(x). The green line is q(x), the approximating distribution. The blue line is the KL divergence. When q(x) is less than p(x), the KL divergence …
Category: Data Science

How can I apply an ACF field to a single custom post if it refers to the taxomy of that post type in the rules?

need to hide a div inside custom posts in a given category. I created an ACF True/False field and applied it to the category taxonomy for this post type. But this True/false should work on internal records that refer to the selected category to which ACF True/false is applied. I understand that there must be something like this ... but what exactly, I do not know) : $terms= something here that I don't know..) ; <?php if ( 'yes' == …
Category: Web

Wordpress Install and Database on separate hosting?

I have a situation where it would be ideal to have the database on separate hosting. Just because the host of the current site does not offer mysql. I cannot move the site (for a company) Can I install wordpress on current hosting in a sub domain and have the database on another host? I have never used anything except “localhost” in the wp-config file? Thank you!
Category: Web

Delete Post but retain image of post [WP REST API]

Currently, when I delete a post in my wordpress website, the image is deleted automatically. Which is fine for most cases, however, there are certain posts where I don't want to delete the image from the database such as a post that has the plain website logo (default background image when subscribers don't post image). In such case, how can I delete the post while keeping the image. I'am using the wordpress rest api and issuing the following request (in …
Category: Web

Preventing fitting Regression CNN to the mean when dataset has only few outliers

I am trying to train a CNN for regression on a dataset where most of the points lie around a similar output value. There are however a few outliers that are very important but they are less represented and the trained network thus tends to predict all output values close to the mean of the whole dataset (underfitting). This leads to a somwhat small error (and good precision) because the vast majority of points lie in that range, but the …
Category: Data Science

WooCommerce Custom Tab with ACF Repeater Field

I am using a Repeater of Advance custom field for the content of the my additional custom WooCommerce Tab. The repeater is inside a group field. I manage to display the custom fields that is outside the repeater field. Now the problem is the field inside my repeater field. The repeater field is not displaying. Here is the code I used in my functions.php // Add a Custom Tab add_filter( 'woocommerce_product_tabs', 'dl_custom_product_designer_tab' ); function dl_custom_product_designer_tab( $tabs ) { // ensure …
Category: Web

How do i generate text from ids in Torchtext's sentencepiece_numericalizer?

The torchtext sentencepiece_numericalizer() outputs a generator with indices SentencePiece model corresponding to token in the input sentence. From the generator, I can get the ids. My question is how do I get the text back after training? For example >>> sp_id_generator = sentencepiece_numericalizer(sp_model) >>> list_a = ["sentencepiece encode as pieces", "examples to try!"] >>> list(sp_id_generator(list_a)) [[9858, 9249, 1629, 1305, 1809, 53, 842], [2347, 13, 9, 150, 37]] How do I convert list_a back t(i.e "sentencepiece encode as pieces", "examples to …
Category: Data Science

How to match a user with other users with similar interests based on their attributes?

Information Available Consider, there are 'n' users and they have these attributes and values User A: Row | Attribute a | Attribute b | Attribute c Item 1| 0.593 | 0.7852 | 0.484 Item 2| 0.18 | 0.96 | 0.05 Item 3| 0.423 | 0.886 | 0.156 User B: Row | Attribute a | Attribute b | Attribute c Item 7| 0.228 | 0.148 | 0.658 Item 8| 0.785 | 0.33 | 0.887 Item 9| 0.569 | 0.994 | 0.374 …
Category: Data Science

Populate an array from the loop, and then read the array into JS

On my site I've got a custom post type. Each custom post has a thumbnail of a person, and an extra custom field that has another image in it. I've written code so that when the user hovers over the thumbnail of the person, they can see the alternative thumbnail. This is in JS. Everything is mechanically working fine, (I got wp_enqueue_script and wp_localize_script going with some help from here!) but instead of each persons thumbnail seeing the correct corresponding …
Category: Web

About

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