Dendrogram: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

I am trying to plot a Dendrogram to cluster data but this error is stopping me. My datea is here. I first chose columns to work with: df_euro = pd.read_csv('https://assets.datacamp.com/production/repositories/655/datasets/2a1f3ab7bcc76eef1b8e1eb29afbd54c4ebf86f2/eurovision-2016.csv') samples = df_euro.iloc[:, 2:7].values[:42] country_names = df_euro.iloc[:, 1].values[:42] # Calculate the linkage: mergings mergings = linkage(samples , method = 'complete') # Plot the dendrogram dendrogram( mergings, labels = y, leaf_rotation = 90, leaf_font_size = 6 ) plt.show() But I'm getting this error which I can't understand. I googled it and …
Category: Data Science

Wordpress Multisite Subdomain 404

I have created a multisite wordpress with subdomains (hosting is Bluehost). Everytime I try to access the subdomains (test.example.com) I get a 404 error message. I copied the code to wp-config and .htaccess. I created a wildcard subdomain (*.example.com) and creates a folder in my public_html . Do I have to make changes to DNS records and what are those?
Category: Web

How to use wp_send_json() and output the value with ajax?

Hello Wordpress Developers. I create my own plugins, and I'm stuck about how to call php functions inside class, into javascript ajax functions. For example we have button with ID name clickme: <button id="clickMe">Click Me</button> And then I make a class with functions, example like this: <?php class myFunctions{ function a(){ $test = "Hello World from wp_send_json()"; wp_send_json($test); } } ?> and then I want to output the test variable, using ajax. Example like this: import $ from "jquery"; class …
Category: Web

wp_get_current_user() function not working in Rest API callback function

Consider the following class. <?php class MCQAcademy_Endpoint extends WP_REST_Controller { /** * Register the routes for the objects of the controller. */ public function register_routes() { $version = '1'; $namespace = 'custompath/v' . $version; $base = 'endpointbase'; register_rest_route( $namespace, '/' . $base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => array(), ) ) ); } /** * */ public function get_items( $request ) { $rs = array( 'data' => …
Category: Web

List of words cluster by topics

I have a list of words, these words correspond to labels in news and they are not duplicated. I would like to get a clustering for this list based on topics. I try with wordnet but I don't know how could get it if I only have a list of unique words and not more information. Thank you!
Category: Data Science

Get product categories and add them to a custom taxonomy

I'm working on a WooCommerce webshop. I have divided all my products into categories. Example: Clothing: -Tshirts -Jeans -Etc. Likewise, all brands are also divided into categories. Example: Brands -Brand1 -Brand2 -Etc. I want to copy or mirror the category and sub-categories of "Brands" to a custom taxonomy. So when I have a product in the "Brand 1" category, then this product must be automatically entered into a custom taxonoy with the same name: "Brand 1" The products in woocommerce …
Category: Web

Add php code to wp_print_scripts?

Is there a way to add inline php code to the editor using wp_print_scripts? I'm trying to find a way to display text from a php string into a value of input of a block. Here's my code: function shapeSpace_print_scripts() { ?> <?php $block_yt_url = 'test';?> <script> jQuery(document).ready(function ($) { let $yt_url = false; $(document).on( "click", '#yt_run .acf-button-group', function() { $(".editor-post-publish-button__button").hide(); $(".acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666").css({'height':'inherit','padding':'16px 20px','overflow':'inherit'}); $(".acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666").val(<?php echo $block_yt_url;?>); $('#yt_url .acf-input input').keyup(function(e) { if(e.keyCode == 13) { …
Category: Web

Is it possible to add new vocabulary to BERT's tokenizer when fine-tuning?

I want to fine-tune BERT by training it on a domain dataset of my own. The domain is specific and includes many terms that probably weren't included in the original dataset BERT was trained on. I know I have to use BERT's tokenizer as the model was originally trained on its embeddings. To my understanding words unknown to the tokenizer will be masked with [UNKNOWN]. What if some of these words are common in my dataset? Does it make sense …
Category: Data Science

Restrict user registration to emails on a single domain

I need to allow user registrations only for those with email addresses on a single domain. I have tested multiple regular expressions and this one works well in a regex sandbox environment, but as soon as I put it into my functions.php file, it simply rejects all registrations - even email addresses on the correct domain (with the error message below, so it's definitely this conditional that's breaking it). Am I: a) actually doing something stupid in the regex, even …
Category: Web

How to cluster time series of ordered data?

There are a few hundred time series of a large set of different locations (irregularly distributed) with the following properties: ordered factor (5 levels) between 5 and 25 observations per series lots of missing values within each series temporal and spatial autocorrelation (unknown) temporal frequency The objective is to spatially cluster the time series based on their similarity (of observed value per point in time). What would be adequate methods? The analysis will be carried out in R.
Category: Data Science

previous and next post of same category on singlepost.php

I want to show previous and next posts of same category in wordpress My code is : <?php $prev_post = get_previous_post(); $next_post = get_next_post(); ?> <nav class="post-nav section"> <div class="row no-margin"> <?php // Display the thumbnail of the previous post ?> <div class="col-xs-12 col-sm-6 prev-post" style="padding:0px"> <?php $prevPost = get_previous_post(); $prevthumbnail = get_the_post_thumbnail($prevPost->ID); $post_tile=get_the_title($prevPost->ID); $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($prevPost->ID), 'full' ); ?> <div class="post-nav-thumb" style="background-image: url('<?php echo $thumb['0'];?>')" ></div> <div class="post-nav-content"> <div class="post-nav-subtitle"><?php previous_post_link('%link', 'Prev Post'); ?></div> <h2 class="post-nav-title"><span><?php previous_post_link('%link', $post_tile); …
Category: Web

Dealing with diverse groups in regression

What happens if a certain dataset contains different "groups" that follow different linear models? For example, let's imagine that examining the scatterplot of a certain feature $x_i$ against $y$ we can see that some points follow a linear relationship with a coefficient $\beta_A<0$ while other points clearly have $\beta_B>0$. We can infer that these points belong to two different populations, population $A$ responds negatively to high values of feature $x_i$ while population $B$ responds positively. We then create a categorical …
Category: Data Science

Unserialize Custom Field & Save as Multiple Rows in Wordpress Database

I have a custom field in post_meta table of wordpress database. It's called 'combined'. I want to seperate the values based on key and save them as multiple rows if there are multiple values for the key. My meta_key: Result after I run my code: What I want: My code: add_action( 'init', function() { if ( 'migrate' !== filter_input( INPUT_GET, 'action' ) ) { return; } $query = new WP_Query( [ 'no_found_rows' => true, 'update_post_term_cache' => false, 'fields' => 'ids', …
Category: Web

Predicting Customer Activity Absence

Could you please assist me with to following question? I have a customer activity dataframe that looks like this: It contains at least 500.000 customers and a "timeseries" of 42 months. The ones and zeroes represent customer activity. If a customer was active during a particular month then there will be a 1, if not - 0. I need determine those customers that most likely (+ probability) will not be active during the next 6 months (2018 July-December). Could you …
Category: Data Science

Parse error: syntax error, unexpected ''tax_query'' in wordpress

hi i want to display posts by term. first the code display all the posts: $aProjectArgs = array( 'post_type' => 'uni_project', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'asc' ); so i add another part of code to display posts by term: $aProjectArgs = array( 'post_type' => 'uni_project', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'asc' 'tax_query' => array( array( 'taxonomy' => 'post_tag', 'field' => 'id', 'terms' => 43 ) ) ); but its not working its give …
Category: Web

Updating WordPress core with zero downtime - I mean zero

I have a critical website which is under version control. When I update the core WordPress files I do so locally, then commit the changes. When I do that the live site (obviously) does not even display a maintenance notice, it simply errors out for a few minutes as the core files are deployed, and presumably are either read part way through, or are temporarily incompatible one to the other. I could update from the live admin, and then deploy, …
Category: Web

How to decide who to market? Clustering or Decision Tree?

I am working with a dataset that has enough observations and ~ 10 variables, half of the variables are numeric another half of the variables are categorical with 2-3 levels (demographics) one ID variable one last variable that has sales value, 0 for no sale and bill amount for sale Using this information, I want to understand which segments of my customers to market. I am using R for code but that's not relevant here. :) I am confused about …
Category: Data Science

upload_mimes not accepting CSV

Hi I am adding support for CSV uploads like so : add_filter( 'upload_mimes', function ( $mime_types ) { $mime_types['csv'] = 'text/csv'; return $mime_types; }); How every when I try to upload the file I still get : Sorry, this file type is not permitted for security reasons.
Category: Web

Forecast Model to Estimate Customer Service Call Volume and Appropriate Staff

I am working on a project to predict the proper staffing needed for a customer service team using historical data. I am new to machine learning, and I am not sure if my approach to this problem is the right one. First I saw it as a multiple linear regression, but the more I think of the outcome I want, the more I realize regression is not the solution. I have a sample historical data with these fields: Number of …
Category: Data Science

Using PCA as features for production

I struggle with figuring out how to proceed with taking PCA into production in order to test my Models with unknown samples. I'm using both an One-Hot-Encoding an an TF-IDF in order to classify my elements with various models, mainly KNN. I know i can use the pretrained One-Hot-Encoder and the TF-IDF encoder in order to encode the new elements in order to match the final feature Vector. Since these feature vectors become very large i use an PCA in …
Category: Data Science

add_action insert html

I know I am missing something simple. I am trying to use html to log to footer to learn wp. In theme functions.php: function myLog() { echo 'test'; } In theme footer within the .siteInfo div: <?php add_action( 'wpmu_new_blog', 'myLog' );?> when a new user creates a new site myLog should output html 'test'? Please help, save me many more hours of reading and trials.
Category: Web

Strange characters on wordpress site - Not UTF8 Issue

I've imported WordPress post data onto a new site and noticed I have strange characters showing on pages and Blog posts. It usually shows where apostrophes should be. I've searched multiple solutions to UTF8 & latin1 solutions with success. I've looked at my database and the characters are showing there too.
Category: Web

Confusion on Outliers

I am not able to distinguish outliers: when to go with the std. dev. or when we need to go with the median. My understanding on std. dev. is: if the data point is away from the mean by more than 2 std. dev., we consider that as an outlier. Similarly for the median, we say that any data point that is not in-between Q1 and Q3 is an outlier. So I am confused as to which one to choose. …
Category: Data Science

Text2Slide multiclass classification

I am considering an idea of stitching together a slide deck based on text input, e.g. given: An all-hands presentation with business updates, project timelines, and financial report charts the output could be a deck with slides corresponding to Title, List, Calendar, Pie Chart, Conclusion. I have preexisting slides that are mostly categorized by the "form" ranging from very general like List to more specific like Decision Tree or Venn Diagram. Am I on the right track that this sounds …
Category: Data Science

Cluster Hyperspectral Images in Orange

Orange has a hyperspectral dataset called "liver cirrhosis" and you can visualize the hyperspectral image using the hyperspectral image widget. However, I would like to perform various clustering methods e.g. k-means on the spectra at each pixel and then display those clusters on the hyperspectral image widget like in this photo does anyone know how to do this kind of analysis?
Topic: orange3 orange
Category: Data Science

Menu custom link not working for external site

I've got this header menu in my site (made editing a theme), but i've noticed that the custom links pointing at local anchor section (like #section) correctly navigate in the same page to the desired location, but an external link won't work, even if specifing "open in new tab". I suppose something is preventing the menu link to open, or worse, the external link is not supported in that theme. Since i'm noob, where should i look for the menu …
Category: Web

How to combine data having similar distribution?

I have a collection of time series data with data points of around 2 years of daily data. I am thinking of a way to increase the number of data points in it so that the neural network gets a better understanding of the fluctuations in the data. I am suggesting a hypothesis where I try to cluster similar time-series data following similar distribution, in order to increase the number of data points fed into the neural network. Is this …
Category: Data Science

Get post id outside loop : Notice: Trying to get property of non-object

I am trying to get the post id outside the loop in functions.php.but what error i am getting : Notice: Trying to get property of non-object in functions.php on line 549 function theme_myeffecto_disable() { global $wp_query; $post_id = $wp_query->post->ID; $showreaction = get_post_meta( $post_id, 'post_reaction_show', true ); $showreaction = isset($showreaction) ? $showreaction : true; var_dump($showreaction); } add_action( 'init', 'theme_myeffecto_disable', 20 ); and $showrating always comes false weather it is true or false :(
Category: Web

Identify optimal thresholds for one-vs-one/one-vs-rest ROC-curve for multiclass classification

Say I have a multiclass classification problem with N classes. I have trained a classifier on a training set, I use a validation set and a One-vs-rest ROC-curve to give me N ROC curves. Since the ROC curve is created based on different thresholds of when we classify a sample as $Ci$ or not $Ci$. We can then chose (our) optimal FPR/TRP ratio and get the threshold (t) e.g say t=0.6 we classify a sample as $Ci$ if model_score>=0.6 else …
Category: Data Science

What is the most effective unsupervised ML algorithm to use when outliers are present in data set?

I am analyzing a portfolio of about 225 stocks and have gotten data for each of them based on their "Price/Earnings ratio", "Return on Assets", and "Earnings per share growth". I would like to cluster these stocks based on their attributes into 3 or 4 groups. However, there are substantial outliers in the data set. Instead of removing them altogether I would like to keep them in. What ML algorithm would be best suited for this? I have been told …
Category: Data Science

Conditional clustering

I have a dataset consisting of addresses (points) that have several attributes; one that distinguishes the "sort" of address and one attribute that contains a numerical value. I want to cluster these points based on: their distance from each other the sort of address However, the summed numerical attribute per cluster cannot exceed a certain threshold value. In other words, the system needs to form clusters but needs to stop clustering as soon as the sum of the numerical value …
Category: Data Science

wp_mail doen't send mails whit attachment

On my site I hava two forms witch send email. The one whit no attachment needed is sent correnctly, but the other ony witch has an attachment does not get sent. I am using SMTP config whit Postman SMTP plugin. move_uploaded_file($_FILES["cv"]["tmp_name"],WP_CONTENT_DIR .'/uploads/CV/'.basename($_FILES['cv']['name'])); move_uploaded_file($_FILES["lm"]["tmp_name"],WP_CONTENT_DIR .'/uploads/lm/'.basename($_FILES['lm']['name'])); $attachments = array( WP_CONTENT_DIR ."/uploads/CV/".$_FILES["cv"]["name"], WP_CONTENT_DIR ."/uploads/lm/".$_FILES["lm"]["name"] ); this is the code I use for storeing and reaching the attachments and simpli useing the wp_mail function to send it like this: $sent=wp_mail($s, $subject, $message, $headers,$attachments); On …
Category: Web

Visual composer custom element error

I am creating a custom element where I need to load woo-commerce product categories as dropdown (in visual composer element edit option) but I am getting this error. can someone tell me where is the problem? here is the code: <?php add_shortcode('woo_my_cat_sub_cat_show_element_code','woo_my_cat_sub_cat_show_element_functions'); function woo_my_cat_sub_cat_show_element_functions($atts,$content){ extract(shortcode_atts(array( 'woo_my_cat_list' => '', ),$atts)); ob_start();?> <!-- I will do the frontend here --> <?php return ob_get_clean(); } if(function_exists('vc_map')){ /*** * dynamic fields for the element */ $args = array( 'taxonomy' => 'product_cat', // 'number' => …
Category: Web

Links to previous/next month archives

On the month archive page (using the date.php template), how can I add links for the previous month and next month? For example, viewing January 2022 (/2022/01), I'd like a link to December 2021 (/2021/12) and a link to February 2022 (/2022/02).
Category: Web

About

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