Cluster words into groups of similar meaning (synonyms)

How can words be clustered into groups of similar meaning (synonyms)? I started with pre-trained word embeddings (e.g., Google News), which is great, but not perfect - a limitation arises because the word embeddings are based on surrounding words. This introduces challenging results. For example: polar meanings: word embeddings might find opposites to be similar. Even though these words mean the opposite semantically, they can quite readily be interchanged given the same preceding and following words. For example, "terrible" and …
Category: Data Science

Custom search: Search posts but display parent page in results

I'm using Wordpress 3.5.1 with a modified twentytwelve theme. My main site structure is based on the Smooth Slider plugin (jQuery Cycle). I have Pages that contain only a shortcode (for example, [smoothslider id='4']) to display Posts assigned to a slider. When I do a search on the site it returns result for individual posts only (and not for pages, of course). This is not what I want as there is no slider anymore. Those posts are not supposed to …
Category: Web

setcookie on WordPress Page Template

I am having an issue with setcookie. I need to set a cookie on a page action (form). I have tried on the template file, but not working. then find out if I set it from functions.php with init hook, it's working. then I put condition like if(is_page_template('mytemplate.php')){... then it's not working. how can I do that? here is my code. add_action( 'init', 'hello_my_cookie' ); function hello_my_cookie() { if(is_page_template('mytemplate.php')){ if(isset($_POST['GGmyCookie'])){ setcookie( 'myCookie','Hello Cookie!', time()+3600); } } }
Category: Web

Add image to menu item with ACF

I'm trying to add an image to menu item, can't get it to work. Here is my code. header.php <?php wp_nav_menu( array( 'theme_location' => 'side-menu', 'container_class' => 'fixed-menu', 'fallback_cb' => '', 'link_before' => '<span>', 'lnk_after' => '</span>', 'depth' => 2, 'walker' => new Understrap_WP_Bootstrap_Navwalker(), ) ); ?> And here is the function.php // Header Side Menu function etm_side_menu() { register_nav_menu('side-menu',__( 'Header Side Menu' )); } add_action( 'init', 'etm_side_menu' ); add_filter('wp_nav_menu_objects', 'wp_nav_menu_objects', 10, 2); function wp_nav_menu_objects( $items, $args ) { // …
Category: Web

Loss function to prevent estimator bias

I have a regression problem I'm trying to build a model for: Predicting sales per person (>= 0) depending on some variables. I'm running different model types and gave deep neural networks a try. The loss functions I'm using are mean squared error and mean absolute error (or sometimes a mix). I often run into this issue though, that despite mse and mae are being optimized, I end up with a very strong bias in the prediction, e.g. sum(training_all_predictions) / …
Category: Data Science

How to change <p> in css with a custom theme?

In a WP site developed with a custom theme, I saw that font size of the paragraph tag seems to be defined in /wp-content/themes/nameofcustomtheme/style.css?ver=1.1.11 I have tried to change font-size to 18px in style.css located there, but now the inspector says that is defined by a css file located at /?sccss=1&amp;ver=4.6 And that the font size remains 16px. How could I change the paragraph tag font size?
Topic: css Wordpress
Category: Web

How to overcome importerror for tensorflow

I'm working on ubuntu, and i'm trying to train my python model but i receive the following error Traceback (most recent call last): File &quot;trial.py&quot;, line 2, in &lt;module&gt; import tensorflow as tf ImportError: No module named tensorflow I've tried to install tensorflow via pip install tensorfow and ensure being installed via the following command pip show tensor and this is the output Name: tensorflow Version: 2.6.2 Summary: TensorFlow is an open source machine learning framework for everyone. Home-page: https://www.tensorflow.org/ …
Category: Data Science

wp_delete_comment takes two tries to delete - then deletes all comments

I'm trying to add a button to my comments that allows a user to delete them. I have a form declared like so: &lt;form method=&quot;post&quot;&gt; &lt;input type=&quot;submit&quot; name=&quot;btn-delete&quot; value=&quot;try-delete&quot;&gt; &lt;/form&gt; and above it the following php: &lt;?php if (isset($_POST[&quot;btn-delete&quot;])) { wp_delete_comment(get_comment_ID(), true); } ?&gt; Note this is in my comments.php, and I use the standard API for looping through the comments. When I click on the button (from the input tag), it reloads the page and does nothing. If I …
Category: Web

RAM crashed for XML to DataFrame conversion function

I have created the following function which converts an XML File to a DataFrame. This function works good for files smaller than 1 GB, for anything greater than that the RAM(13GB Google Colab RAM) crashes. Same happens if I try it locally on Jupyter Notebook (4GB Laptop RAM). Is there a way to optimize the code? Code #Libraries import pandas as pd import xml.etree.cElementTree as ET #Function to convert XML file to Pandas Dataframe def xml2df(file_path): #Parsing XML File and …
Category: Data Science

How to get images only attached from edit post page

I have developed a custom wordpress panel with a custom front-end recently. In single post pages there is a slider. I display the result of get_attached_media( 'image' ) function as the images of slider. I told editor that upload only the images you would like to see in slider to post from edit post page, upload other images from the media link on the side menu. The problem is that, if the user uploads an image from media screen, then …
Category: Web

Adding div to WordPress page content

I am wondering if there is a way to add div to specific elements in the WordPress page content? For example, I would want to wrap a div around content starting at a H2 element and ending after an img element. The div should have custom classes assigned to them. Is there anyway to do this? I don't want to have to hard-code the div so that other people can easily edit the page content. Thanks!
Category: Web

Add email addresses to already registered users

my website users register with phone number OTP. That's why they have no email address in their accounts. Today I need email address in user accounts. I use this code to add email address for new user registrations. add_action(&quot;user_register&quot;, function ($user_id) { $user = get_userdata($user_id); if (empty($user-&gt;data-&gt;user_email)) { $args = array( &quot;ID&quot; =&gt; $user-&gt;id, &quot;user_email&quot; =&gt; uniqid() . &quot;@example.com&quot;, ); wp_update_user( $args ); } }); add_filter( 'bnfw_trigger_insert_post', '__return_true' ); But I have about 3000 users that need email address in …
Category: Web

Custom WooCommerce rewrite rules with comma delimiter

I'm trying to troubleshoot a wide-scale problem. I'd like to rewrite default WooCommerce permalinks for categories, to delimiter as commas. Let's take an example: Brand Model Generation Engine Product The permalink structure I'd like to have: /chip-tuning-Ford /chip-tuning-Ford-Focus /chip-tuning-Ford-MK3-FL /chip-tuning-Ford-MK3-FL-1.5TDCi-75kW /chip-tuning-Ford-MK3-FL-1.5TDCi-75kW-Basic-Box I did this via generate_rewrite_rules action, but currently, we have about 4000 categories and 9000 products, so each combination takes a lot of time and space. All rewrite rules by WP default are saved into one field on the …
Category: Web

change pagination url

Currently I’m having URL for pagination pages as: http://www.example.com/category_name/page/2 But I need to change this URL structure as: http://www.example.com/category_name/?page=2 etc. any solution?
Category: Web

Difference between DataSampler and TestAndScore widgets in Orange

I'm trying to figure out the difference between using the data sampler to get a 70/30 train/test split and directly using the test and score widget to do so via random sampling. My workflow as follows This is how my test and score widget looks for the case without the data sampler and this is how my data sampler widget looks I see very different results in the confusion matrix at the end between the two. Using the data sampler, …
Topic: orange3 orange
Category: Data Science

Remove 'type / to choose a block' placeholder

I'd like to remove the placeholder in an empty block 'type / to choose a block'. I often have empty spaces in my drafts as I'm writing and this placeholder clutters everything. I'd just like it empty. Is there a way to remove it with a filter?
Category: Web

Wordpress Memory limit not increasing

I have set 1024M in php.ini file: memory_limit = 1024M I have set it in .htaccess file: &lt;IfModule mod_php7.c&gt; php_value memory_limit 1024M &lt;/IfModule&gt; I have set it in wp-config.php file: define( 'WP_MAX_MEMORY_LIMIT' , '1024M'); define( 'WP_MEMORY_LIMIT', '1024M' ); But I still get the following error on a plugin page in my Wordpress admin area: Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 61440 bytes) in /home/eroticnaughtines/public_html/wp-includes/functions.php on line 4212 And yes, all the files are in …
Category: Web

Self-Attention Summation and Loss of Information

In self-attention, the attention for a word is calculated as: $$ A(q, K, V) = \sum_{i} \frac{exp(q.k^{&lt;i&gt;})}{\sum_{j} exp(q.k^{&lt;j&gt;})}v^{&lt;i&gt;} $$ My question is why we sum over the Softmax*Value vectors. Doesn't this lose information about which other words in particular are important to the word under consideration? In other words, how does this summed vector point to which words are relevant? For example, consider two extreme scenarios where practically the entire output depends on the attention vector of word $x^{&lt;t&gt;}$, and …
Category: Data Science

Understanding output stepAIC

I am using the stepAIC function in R to do a bi-directional (forward and backward) stepwise regression. I do not understand what each return value from the function means. The output is: Df Sum of Sq RSS AIC &lt;none&gt; 350.71 -5406.0 - aaa 1 0.283 350.99 -5405.9 - bbb 1 0.339 351.05 -5405.4 - ccc 1 0.982 351.69 -5400.5 - ddd 1 0.989 351.70 -5400.5 Question Are the values listed under Df, Sum of Sq, RSS, and AIC the values …
Category: Data Science

My CNN image classification model gives good predictions in all but 2 classes. What should I do?

I built a CNN image classifier for a dataset that contains 6 classes. The dataset is balanced in all 6 classes. After training, the model gives pretty good prediction accuracy in all but 2 classes. To elaborate further, let us label these 6 classes with integers from '0' to '5'. The trained model does well in predicting classes from '0' to '3'. But almost 5%-10% of class '4' image is predicted as class '5' and similarly, 5%-10% of class '5' …
Category: Data Science

Next/Previous Product with custom order by price & products inside the product category

How to create next/prev buttons that are price sorted and give results inside the product category you are in? This question has been asked multiple times and despite the multiple threads there wasn't an exact answer. Only relatively close ones that didn't do all of the above. Below you will find my answer which works in my tests so far.
Category: Web

Strange Behavior for trying to Predict Tennis Millionaires with Keras (Validation Accuracy)

I'm trying to make an NN with Keras to predict the ATP players that will get more than US$1 million in prize money based on their weight and height (from a dataset I mined some weeks ago), but I have been getting a weird behavior especially for the validation accuracy. Sometimes it gets to 84-85%, which is reasonable since SVMs and GaussianNB seem to be able to hit only 83.3% at best (check this post for more info), but sometimes …
Category: Data Science

Custom Gutenberg Block: How to return plain HTML with save(), without escaping?

I'm writing a custom Gutenberg editor block. When saving the block I can save simple HTML elements, like in the documentation: return wp.element.createElement('div', blockProps, 'Your block.'); However, I need to return some huge and complicated HTML that I cannot produce in that way. To give you an impression: &lt;div class=&quot;wrapper&quot;&gt;&lt;svg class=&quot;some-svg-image&quot; version=&quot;1.1&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; x=&quot;0px&quot; y=&quot;0px&quot; viewBox=&quot;0 0 600 600&quot; xml:space=&quot;preserve&quot; aria-labelledby=&quot;catTitle catDesc&quot; role=&quot;img&quot;&gt;...&lt;g&gt;...&lt;path&gt;...&lt;/svg&gt;&lt;/div&gt; When I return this as a string, it will be escaped. How can I prevent escaping …
Category: Web

Media library on another server?

I have been searching for a solution to have my media library on another server but i haven't figured out any good solution yet. I don't know if this is possible so let me know if i'm lost here :) Anyway, our setup right now is pretty straight forward, we have a domain and a subdomain, both on a shared hosting. Due to performance issues, we are going to transfer our site to a VPS, but to make the transfer …
Category: Web

Difference between ethics and bias in Machine Learning

I'm confused about the difference between &quot;ethics&quot; and &quot;bias&quot; when those concepts are discussed in the context of Machine Learning (ML). In my understanding, ethical issue in ML is pretty much exactly the same thing as &quot;bias&quot;: say, the model discriminates people of color and this is the same as to say that the model is biased. In short, &quot;ethics is always a bias, but it is not necessarily true that a bias is always an ethical issue&quot;. Is this …
Category: Data Science

How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?

The URL structure I am hoping for is as follows: All posts: /blog/ and /blog/page/2 Categories: /blog/%category%/ and /blog/%category%/page/2 Post: /blog/%category%/%postname%/ Tags: /blog/%tag%/ and /blog/%tag%/page/2 My problem is that I am unable to have both my permalink 'custom structure' and 'category/tag base' with the &quot;blog&quot; prefix, without having page or pagination 404 errors. I am working on a dev site which has no plugins and a custom theme which is not ineterferring. I would like a plugin-free solution which is …
Category: Web

How to match a word from column and compare with other column in pandas dataframe

I have the below dataframe Text Keywords Type It’s a roll-on tube roll-on ball It is barrel barrel barr An unknown shape others it’s a assembly assembly assembly it’s a sealing assembly assembly factory its a roll-on double roll-on factory I have first found out the keywords, and based on the keyword and its corresponding type, it should true or false For example, when the keyword is roll-on , the type should be "ball" or "others" when the keyword is …
Category: Data Science

Image Classification problem for minute defect detection

I am tasked with the problem of finding defects in a compressor wheel.Here is how a good wheel looks like: Here is how a defective wheel looks like ( I have drawn a box around the defective area): I have continuous video feed of the wheels rotating as a data set. I tried training the &quot;goodness&quot; of a wheel using a fasterrcnn_resnet50_fpn model in pytorch. But the results were inaccurate. This is what I fed in the training data with …
Category: Data Science

Bulk-add featured images in posts with no featured image

I have a site with loads of posts (news items). Some posts don't have featured images yet. Adding the images to those posts (few hundreds) is a tedious task. We basically want to add 1 and the same image to all the posts without a featured image. Is there a way to do this in bulk? Like ADD 'this image' to ALL 'posts' (not pages) WHERE 'featured_image' is empty. I really hope there's a plugin for that. Can't find it …
Category: Web

Wordpress permalinks error 404 on IIS

i have enable permalinks on my wordpress site and now every page returns 404 error. The site is hosted in IIS 8.5 the web.config file has the following rule inside &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;directoryBrowse enabled="false"/&gt; &lt;rewrite&gt; &lt;rules&gt; &lt;clear/&gt; &lt;rule name="wordpress" stopProcessing="true"&gt; &lt;match url=".*" /&gt; &lt;conditions logicalGrouping="MatchAll"&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Rewrite" url="index.php" /&gt; &lt;/rule&gt; &lt;/rules&gt; &lt;/rewrite&gt; what can i do to fix that and make permalinks work?
Category: Web

About

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