Performance of Triplet loss network vs multiclass classification

I am training a triplet loss based classification network and a normal multiclass classification network on some image data. In my case, the triplet loss network performs worse than the multiclass network. I have tried changing layers, neurons, margin, etc. for the triplet loss network, but the multiclass network still performs better. Are there any cases where the triplet loss network can perform worse than normal multiclass classification? If no, what are the possible things I can look at to …
Category: Data Science

wpdb get_results() returns only 2 rows

I am trying to create custom admin widget to present how many users has registered within last days. I have created function as below: function mdbootstrap_add_dashboard_recent_users(){ global $wpdb; $query = " SELECT count(*) as counter, DATE(wp_users.user_registered) as regdate FROM wp_users GROUP BY DATE(wp_users.user_registered) ORDER BY DATE(wp_users.user_registered) desc"; $posts = $wpdb->get_results($query,OBJECT); print_r( $posts); } However for some reason it's returning only 2 rows: Array ( [0] => stdClass Object ( [counter] => 1 [regdate] => 2016-01-12 ) [1] => stdClass Object …
Category: Web

Order WP_Query by The Order of an Array in Tax_Query

I have a wp_query that uses tax_query to which I pass an array of taxonomy term IDs. I'd like to order my results based on the order of that array but can't get it to work and searching has got me nowhere. Example code below for reference. So this code actually orders the results by tax terms (dumb luck?) but the tax terms aren't in the same order as $term_array. I've tried all the logical options for the 'orderby' parameter …
Category: Web

SSL for mapped subdomains in multisite (no plugins)

WP multisite network based on subdomains, and domain mapping to my customer domain names without a plugin (I'm on WP 4.6.x). SSL cert for the server, so the base network domain does come up with green padlock -- but I do not cover my customer's domains - they currently get forced to http. I need to have all my customer's domains come up with https, green padlock -- without having to install a separate SSL cert for each domain. What …
Category: Web

Reduce multiclass classification targets to binary classification targets in scikit-learn

I would like to reduce multiclass classification targets to binary classification targets. Ideally, this mapping would happen within scikit-learn so the same transformation applies during both training and prediction. I looked at transforming the prediction target (y) documentation but did not see something that would work. Ideally, it would be a classifier version of TransformedTargetRegressor. Something like this mapping: targets_multi = {'A', 'B', 'C', 'D'} targets_binary = {0: {'A', 'B'}, 1: {'C', 'D'}}
Category: Data Science

In which way GAN generator transforms the data(for transforming a noise to the data)?

I have the problem: I understood how GAN works in general, but I need information how it work detailed. The part I don't understand is how the random noise at input is transformed to data on the output(the math side of that process). If anybody knows answer for the question please say it or at least say in which side I need google the question.
Category: Data Science

Custom field on Quick Edit using select/dropdown - almost working right but not showing currently selected value

I'm new to WP plugin programming but have been tasked with the following. GOAL: Create a plugin that does all the following: Set up default chat departments for each domain. Create custom field using select dropdown to allow choosing alternate chat department for each page. Create custom column in Quick Edit to show selected chat department. Column must be sortable. Allow selection of alternate chat department on each page via Quick Edit screen (and optionally via regular edit screen which …
Category: Web

Create field of Custom Post Types

I am using below code to create Custom Post Types. $supports = array( 'title', // post title 'editor', // post content 'author', // post author 'thumbnail', // featured images 'excerpt', // post excerpt 'custom-fields', // custom fields 'comments', // post comments 'revisions', // post revisions 'post-formats', // post formats ); $labels = array( 'name' => _x('news', 'plural'), 'singular_name' => _x('news', 'singular'), 'menu_name' => _x('news', 'admin menu'), 'name_admin_bar' => _x('news', 'admin bar'), 'add_new' => _x('Add New', 'add new'), 'add_new_item' => __('Add …
Category: Web

Optimally sample from multiple distributions

I have two datasets both of the form from the table below. I am interested in downselecting from dataset A by sampling from the distribution of values from dataset B. However, I want to consider both the Distance and Duration when downselecting such that the distribution of both parameters in my end-product from dataset A matches as best as possible the distribution of these parameters from dataset B. Anyone have suggestions for tools (preferably in python) that would help me …
Category: Data Science

update_option is not working!

I am writing a plugin and I need to use the update_option function to update an array I have stored as an option in WP. For the admin panel I used the settings API but for this portion I need to use the update_option directly. I have simplified my code so all it is currently doing is reading in the option, adding an element to the returned array, and updating the option with the modified array. But when I read …
Category: Web

Batch processing with variable length sequences

I have a lot of time series with different lengths. I would like to know what are the best practices to fit them to a Bidirectional LSTM model. The problem is a Binary Classification of Sequence to Sequence. So for every time step, I want to predict the binary class. Currently, I create a tensor for each data frame with the shape of (1, None, #Features). Then I fit every tensor separately to the model. Is it better to combine …
Category: Data Science

Forecasting future point with partial future data already available

Working on a forecast model that should output an End of monthly value, the interesting part is that we already have partial (90%) of that data available at the prediction point (max 30 days away). The purpose is to take into account the current monthly trend and project that out until the end of the month, but also take into consideration that we already know those future points with 90% confidence. For example: Let's say we're in the 3rd day …
Topic: forecasting
Category: Data Science

Get all comments of author's posts

Hello I have multi author website. I want to display all comments of posts created by author in author page. Please help me. I found this code but fatal error <?php $args = array( 'author' => AUTHOR_ID, 'posts_per_page' => 500, //Don't use -1 here ); $the_query = new WP_Query( $args ); if($the_query->have_posts() ) : ?> <?php while ( $the_query->have_posts() ) : ?> <?php $nested_args = array( 'post_id' => get_the_ID() ); $comments_query = new WP_Comment_Query; $comments = $comments_query->query( $nested_args ); if …
Category: Web

Why do we use +1 and -1 for marginal decision boundaries in SVM

While using support vector machines (SVM), we encounter 3 types of lines (for a 2D case). One is the decision boundary and the other 2 are margins: Why do we use $+1$ and $-1$ as the values after the $=$ sign while writing the equations for the SVM margins? What's so special about $1$ in this case? For example, if $x$ and $y$ are two features then the decision boundary is: $ax+by+c=0$. Why are the two marginal boundaries represented as …
Topic: svm
Category: Data Science

please help, i got an error while trying to my data, i got an error like x and y must be thesame size

import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.read_csv('housing.csv') data.drop('ocean_proximity', axis=1, inplace = True) data.head() longitude latitude housing_median_age total_rooms total_bedrooms population households median_income median_house_value 0 -122.23 37.88 41.0 880.0 129.0 322.0 126.0 8.3252 452600.0 1 -122.22 37.86 21.0 7099.0 1106.0 2401.0 1138.0 8.3014 358500.0 2 -122.24 37.85 52.0 1467.0 190.0 496.0 177.0 7.2574 352100.0 3 -122.25 37.85 52.0 1274.0 235.0 558.0 219.0 5.6431 341300.0 4 -122.25 37.85 52.0 1627.0 280.0 565.0 259.0 3.8462 342200.0 …
Category: Data Science

Can part of my WordPress website be headless?

Just to set the scene I have a client that has a wordpress site with a mixture of "static" pages and woocommerce shop. The product catalogue has approx "86,000" products in it. This number may include variation though it is massive. The client relies heavily on product filtering functionality for users to get to the correct products. Using WP AJAX to do this has proven really slow. After a bit of research I think the best way to perform the …
Category: Web

Is there way to toggle the publish date display?

I am interested in changing our WP dashboard so that I can choose whether an individual Post will include the publish date or not. Is there a way to do it without a plug-in and insert code that maybe creates a checkmark or something like that in the Post dashboard that can toggle the publish date display? Thank you in advance!
Category: Web

SSL certificate breaks CSS (in combination with W3TC)

Dear StackExchange community, I am struggling with the following problem and simply cannot find a solution: I have installed a SSL certificate but it causes the CSS of my website to break when the plug-in "W3TC" is activated (example: https:// www.planetofsuccesscom/blog/). Here's how I installed the certificate and how I tried fixing the problem: Deactivated W3TC Updated my site URL to https within the WordPress dashboard (Settings » General and updating your WordPress and site URL address fields) Redirected http …
Topic: ssl Wordpress
Category: Web

Looking for a ML algorithm to predict a path based on millions of data

I have a dataset with following data format: 3 -> a -> b -> c -> d -> ikd a -> c -> 3 -> dk -> 2 -> l2i Each row represents a path from start to end. Let's take the first row as an example. The start point is 3 and the endpoint is ikd. I have millions of rows like that. And each row may have a different length. What I want to do is let users …
Category: Data Science

Sampling Highly Imbalanced Large Dataset

I am working on a model which will run monthly on 8M users. I've snapshot-wise data in training set, eg: Jan, 21 Snapshot : 8M Total : 233 Positives Rest Negative Feb, 21 Snapshot : 8M Total : 599 Positives Rest Negative March, 21 Snapshot : 8M Total : 600 Positives Rest Negative April, 21 Snapshot : 8M Total : 750 Positives Rest Negative similarly till March, 2022 I'm keeping March, 2022 as test set, which has 2000 positive labels …
Category: Data Science

unable to pass X_train and y_train in my regressor variable. i got a ValueError

import pandas as pd import numpy as np import matplotlib.pyplot as plt data = pd.read_csv('housing.csv') data.drop('ocean_proximity', axis=1, inplace = True) data.head() longitude latitude housing_median_age total_rooms total_bedrooms population households median_income median_house_value 0 -122.23 37.88 41.0 880.0 129.0 322.0 126.0 8.3252 452600.0 1 -122.22 37.86 21.0 7099.0 1106.0 2401.0 1138.0 8.3014 358500.0 2 -122.24 37.85 52.0 1467.0 190.0 496.0 177.0 7.2574 352100.0 3 -122.25 37.85 52.0 1274.0 235.0 558.0 219.0 5.6431 341300.0 4 -122.25 37.85 52.0 1627.0 280.0 565.0 259.0 3.8462 342200.0 …
Category: Data Science

WordPress Reset password Strength set to medium

I have been looking for an answer for a few days digging through hooks and actions. I just cane seem to find a way to turn down the strength on the reset password page not sure if its through woo-commerce or WP I have tried the following add_filter( 'woocommerce_min_password_strength', 'reduce_woocommerce_min_strength_requirement' ); function reduce_woocommerce_min_strength_requirement( $strength ) { return 2; } add_filter( 'wc_password_strength_meter_params', 'reduce_strength_meter_settings' ); function reduce_strength_meter_settings( $data ) { return array_merge( $data, array( 'min_password_strength' => 2, 'i18n_password_hint' => 'Change Hint here' …
Category: Web

I need to plot only training curve in the fastai library using the learner.recorder.plot_losses() function . FASTAI devs pls help

I have a task where I need to only plot the training loss and not the validation loss of the plot_losses function in the fastai library with learner object having recorder class, but I am not able to properly implement the same. I am using the fastai v1 for this purpose due to project restrictions. Here is the github code for the same: class Recorder(LearnerCallback): "A `LearnerCallback` that records epoch, loss, opt and metric data during training." def plot_losses(self, skip_start:int=0, …
Category: Data Science

How to read a table from MySQL work bench in colab

I have referred to various articles on Stack Overflow and external sources but somehow am unable to get answer for this. I would like to read a table from MySQL workbench database into a dataframe in colab. $1^{st}$ Method: In this method, first line of code is successfully executed. Note: I have hidden database, table and password name for security reasons. Source - USER = 'root' PASSWORD = 'PASSWORD' DATABASE = 'DATABASE' TABLE = 'TABLE' connection_string = f'mysql+pymysql://root:PASSWORD/DATABASE' engine = …
Topic: colab sql
Category: Data Science

Regularizing the intercept

I am reading The Elements of Statistical Learning and regarding regularized logistic regression it says: "As with the lasso, we typically do not penalize the intercept term" and I am wondering in which situations you would penalize the intercept? Looking at regularization in general, couldn't one think of scenarios where penalizing the intercept would lead to a better EPE (expected prediction error)? Although we increase the bias wouldn't we in some scenarios still reduce the EPE? EDIT It might be …
Category: Data Science

Why calculating how much removed sentences with most contributing words to the result helps to show that a model is "*faithful*"?

I don't understand how the calculation score taking out the sentences where the words contribute the most of to the result helps to show to what extent a model is "faithful" to a reasoning process. Indeed, a faithfulness score was proposed by Du et al. in 2019 to verify the importance of the identified contributing sentences or words to a given model’s outputs. It is assumed that the probability values for the predicted class will significantly drop if the truly …
Category: Data Science

What is the best way to cache pages on Wordpress

I have a site with many custom queries. Some take many seconds to load a page. To solve that issue, I have been using a caching plugin. The issue is, my caching plugin does not cache a page until I click it once. I'd prefer to do this entire process without a plugin if possible. If the plugin route is the best way to go, I'd love to know that too. I have an idea that this is how it …
Category: Web

Event Organiser - Add text search for Calendar view

As it stands, the Calendar View shows filters for Categories and Venues. I need a 'filter' for text search. We are looking for ability to search by topic, rather than category, for example - otherwise we have a huge number of categories - one for each topic - that is unwieldy. (I would like this option for setting up event displays in the sidebar - so I could have sidebars for functional areas tied to particular pages) Does such a …
Category: Web

How do I design a random forest split with a "not sure" category?

Let's say I have data with two target labels, A and B. I want to design a random forest that has three outputs: A, B and Not sure. Items in the Not sure category would be a mix of A and B that would be about evenly distributed. I don't mind writing the RF from scratch. Two questions: What should my split criterion be? Can this problem be reposed in a standard RF framework?
Category: Data Science

NNs for fitting highly oscillatory functions

in a scientific computing application of neural networks, I have to maximize several neural networks with scalar output with respect to a target/loss function (coming from a weak form of a PDE). It is known from theoretical considerations that typically the functions that would be optimal with respect to the target function (i.e. the maximizers) are extremly oscillatory functions. I suppose that this is the reason, why - according to my first numerical experiments - typical network architectures, initializations and …
Category: Data Science

Event Organiser - Display Current Event Date for Recurring Events

In the event display, if it's a recurring event, the 'current' date (date selected from calendar - not today's date) for the event does not display - only next date/dates. I need to add a simple line above the Next info that simply says 'Date:' with the current event's date/time being displayed. (Exactly as is displayed for one-time-only events) I tried using eo_get_current_occurrence_of but couldn't seem to get to where I needed to get. I don't see this function being …
Category: Web

Hook "wp_trash_post" executing multiple time in case of bulk trash products

I am currently using hook wp_trash_post to trigger my custom API when a WooCommerce Product is trashed. This is working fine for the case of single trash. But, in case of Bulk trash this event is executing multiple times. for example if 3 products are selected to trash then this event will trigger 3 times. I need different event for Bulk Trash which will execute one time but having all of product ids.Hopefully it is clear to understand. Please Help!
Category: Web

About

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