tax_query showing no results

I'm creating a music database site with two custom post types: tracks and albums. I've linked the tracks to their respective albums with a custom taxonomy for the album's slug. On each album page, I'm trying to get a tracklist of the album by retrieving all tracks with a dub_album_slug taxonomy that matches the slug of the current album. Here's my code for that query: global $post; $post_slug = $post->post_name; $args = array ( 'post_type' => 'dub_track', 'tax_query' => array( …
Category: Web

What to do if the model is not performing well on a validation dataset

I am trying to use different ML classifiers for binary classification (SVM, logistic regression,DNN). The dataset used for training contains 333 columns and about 2000 rows. The classes being slightly unbalanced, I am using SMOTE to account for that. Even though the roc curves of all the classifiers are showing an AUC of more than 90%, once I provide a validation dataset, the model can barely predict correctly 30 % of the objects classified. The model is trained and tested …
Category: Data Science

Order properties should not be accessed directly

This code: foreach ($order->meta_data as $row) { if ($row->key == 'tid') { $tid = $row->value; break; } } within the function function function_name($order_id, $checkout = null) { global $woocommerce; $order = new WC_Order($order_id); foreach ($order->meta_data as $row) { if ($row->key == 'tid') { $tid = $row->value; break; } } if (!empty($tid)) { ... } } add_action('woocommerce_order_status_changed', 'function_name'); triggers the PHP notice "Order properties should not be accessed directly" and I don't know what's the problem. I run Woocommerce 3.0.8 and …
Category: Web

Remove all messages, when untrash a post

I'm trying to replace default untrash message to my own with error class. admin_notices do everything as expected, but even if I return empty messages array in bulk_post_updated_messages filter, I'm still see notice, but with empty content with Edit link. According to wp-admin/edit.php, messages generating based on $bulk_counts, but bulk_post_updated_messages filter returns $bulk_messages only and even if I change this array, nothing happened. How to access $bulk_counts? $bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts ); $bulk_counts = array_filter( $bulk_counts ); ... …
Category: Web

How to construct the document-topic matrix using the word-topic and topic-word matrix calculated using Latent Dirichlet Allocation?

How to construct the document-topic matrix using the word-topic and topic-word matrix calculated using Latent Dirichlet Allocation? I can not seem to find it anywhere, even not from the author of LDA, M.Blei. Gensim and sklearn just work, but I want to know how to use the two matrices to construct the document topic-matrix (Spark MLLIB LDA only gives me the 2 matrices and not the document-topic matrix).
Category: Data Science

Get Third Level Categories WooCommerce

I am trying to get third Level WooCommerce categories. Here follows my source code: $args = array( 'hierarchical' => 1, 'show_option_none' => '', 'hide_empty' => 0, 'parent' =>18, 'taxonomy' => 'product_cat' ); $subcats = get_categories($args); echo '<div class="wooc_sclist">'; foreach ($subcats as $sc) { $link = get_term_link($sc->slug, $sc->taxonomy); echo '<ul><a href="' . $link . '">' . $sc->name . '</a>'; $args2 = get_term(array( 'hierarchical' => 0, 'hide_empty' => false, // 'taxonomy' => 'product_cat' )); $subsubCats = get_categories($agrs2); foreach ($subsubCats as $subsubCats) { …
Category: Web

Best metric to evaluate model probabilities

i'm trying to create ML model for binary classification problem with balanced dataset and i care mostly about probabilities. I was trying to search web and i find only advices to use AUC or logloss scores. There is no advices to use Brier score as evaluation metric. Can i use brier score as evaluation metric or there is some pitfalls within it? As i can understand if i will use logloss score as evaluation metric the "winner one" model will …
Category: Data Science

Comparing Dataset - Should I use the same Test dataset?

I am training ML CNN model. I want to compare different images dataset. The dataset all have different characteristics (Translated or not, Rotated or not, etc.). I do not modify the ML model between the different dataset training. Should I use the same Test dataset to compare them ? This dataset would not be changed through the testing and would contain data that can't be found else where. It would not be more suited for a specific training dataset. Or …
Category: Data Science

how to get value of a select box in custom widget wordpress

I am trying to make a custom widget. My codes are as follows: class techno_widget extends WP_Widget { function __construct() { parent::__construct( 'techno_widget', __('Recent Full Post', 'techno_widget_domain'), array( 'description' => __( 'A full post will be appeared on Sidebar', 'techno_widget_domain' ), ) ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); $blog-title = $instance['blog-title']; echo $args['before_widget']; if ( ! empty( $title ) ) echo $args['before_title'] . $title . $args['after_title']; echo $instance['blog-title']; echo $args['after_widget']; } …
Category: Web

What kind of statistical test can be performed in a recommender system dataset that predicts the ratings for the movies?

The dataset consists of 1000s of users and users and each row of the dataset consist of user_id,movie_id and ratings the user provides to the movie. eg. 1,56,5 In my experiment i am calculating the mse and precision using collabarative filtering model. The error comes from difference in predicted and actual ratings. I want to conduct a statistical test now. Which statistical model is to performed and how? Thanks in advance.
Category: Data Science

What is an efficient clustering approach for grouping multivariate timeseries data into optimally persistent states?

I have a length 200000 time series of six dimensional data describing the evolution of a chaotic dynamical system. I am exploring ways to partition the state space of the data into minimally interacting regions; I want the least transitions from cluster to another in my time series. Other than not being interested in the trivial case of only 1 cluster I have no restrictions on cluster number though I expect it to be small (K<6 say). The purpose of …
Category: Data Science

How to run Javascript popup modal in a loop?

So I have this popup modal: HTML: <h2>Modal Example</h2> <!-- Trigger/Open The Modal --> <button id="myBtn">Open Modal</button> <!-- The Modal --> <div id="myModal" class="modal"> <!-- Modal content --> <div class="modal-content"> <span class="close">×</span> <p>Some text in the Modal..</p> </div> </div> Script: <script> // Get the modal var modal = document.getElementById("myModal"); // Get the button that opens the modal var btn = document.getElementById("myBtn"); // Get the <span> element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks the …
Category: Web

Creating a subcommand for custom wp-cli command

I'm toying around with writing custom wp-cli commands. I have successfully created a simple command, wp-cli theme save which runs a script to backup the site's theme files: <?php class Save_Command extends WP_CLI_Command { /** * Create a tarball of current active theme and save it to wp_themes directory in the user's config directory. * * @synopsis */ public function __invoke($args = array(), $assoc_args = array()) { exec ( 'wpst' ); } } WP_CLI::add_command( 'theme save', 'Save_Command' ); This code …
Category: Web

Similarity coloring of a self organizing map

I have implemented the algorithm to train self organizing maps in Python and it seems to be working well. I checked with some labeled data and the maps are learning the topology well. Here are some images: I am calculating a Unified Distance Matrix for visualization which does not seem to be working well as seen in the 2nd image. I believe that similarity coloring as seen in the world poverty map developed by Prof. Kaski and Prof. Kohonen would …
Category: Data Science

How do I set up a webhook?

I have a simple script that sends Slack messages, runs reports and does other things. I would like this script to run directly based after users purchase something on my site. I do NOT want to build this functionality using WordPress, my goal is to have loosely coupled systems. ENTER WEBHOOKS. Webhooks sound exactly like what I want. Something happens on WordPress and then it pings my reporting server. WordPress advertises a webhooks feature at https://en.support.wordpress.com/webhooks/ it states this there …
Category: Web

How to add attention mechanism to my sequence-to-sequence architecture in Keras?

Based on this blog entry, I have written a sequence to sequence deep learning model in Keras: model = Sequential() model.add(LSTM(hidden_nodes, input_shape=(n_timesteps, n_features))) model.add(RepeatVector(n_timesteps)) model.add(LSTM(hidden_nodes, return_sequences=True)) model.add(TimeDistributed(Dense(n_features, activation='softmax'))) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) model.fit(X_train, Y_train, epochs=30, batch_size=32) It works reasonably well, but I intend to improve it by applying attention mechanism. The aforementioned blog post includes a variation of the architecture with it by relying on a custom attention code, but it doesn't work my present TensorFlow/Keras versions, and anyway, to my …
Category: Data Science

Windows Setup: Error establishing a database connection

I have MySQL 8.0.12, PHP v7.3.2 64Bit and Apache 2.4.38 64Bit installed. In theory I have everything that is needed to run WordPress locally. Through MySQL Workbench, I have tried the Host, Port, User and Password I have set up in wp-config.php and I am able to connect without any problems. For some reason however, when I navigate to my site's wp-admin/install.php I get the following: In my hosts file, I have dev.nativeleaf.co.uk set up to point at 127.0.0.1, along …
Category: Web

Why DQN but no Deep Sarsa?

Why is DQN frequently used while there is hardly any occurrence of Deep Sarsa? I found this paper https://arxiv.org/pdf/1702.03118.pdf using it, but nothing else which might be relevant. I assume the cause could be the Ape-X architecture which came up the year after the Deep Sarsa paper and allowed to generate an immense amount of experience for off-policy algorithms. Does it make sense or is their any other reason?
Category: Data Science

Custom Simulator for Deep Reinforcement Learning

I am trying to develop a control method for a specific process in industry. I have a time-series of data for the process and want to develop a prediction model base on attention mechanism to estimate the output of the system. After development of the prediction model, I want to design a controller based on Deep Reinforcement Learning to learn policies for process optimization. But I need a simulated environment to test and train my DRL algorithm on it. How …
Category: Data Science

How to exclude labels from certain categories in a shortcode?

Good afternoon. There is a shortcode [alltags] that displays ALL site tags on a separate page of the site in alphabetical order with a letter. function wph_alltags_shortcode( $atts, $content ) { $posttags = get_tags(); $output = ''; if ( $posttags ) { $output = '<dl class="alltags">'; foreach ( $posttags as $tag ) { $l = mb_strtoupper( mb_substr( $tag->name, 0, 1, 'UTF-8'), 'UTF-8' ); if ( $L != $l ) { if ( $L ) $output .= '</dd>'; $L = $l; …
Category: Web

Automatically search and replace link in content (pages/posts)?

The users of my site mainly share documents by inserting links into content (pages/posts) using the built in editor. These files include everything from pdfs to word documents. The users currently get/copy these links from a php file manager like FileRun. My goal is to have the users instead use a path from mapped network drive such as \testdrive\Folder1\Folder2\test.txt. The following function has been written to handle replacing the mapped network drive files to an internet link such as "http://page.test.org/files/". …
Category: Web

Clustering with maximum weight and distance conditions

I have a set of weighted 2D points (coordinates x, y and weight w for each sample). I want to cluster these samples using minimum number of clusters, with the following conditions: Use the least number of clusters The sum of weighted distances (distance to the centroid * weight) for each point inside the cluster should not exceed a certain value w_max The maximum distance between any point in the cluster and the cluster centroid should not exceed a certain …
Topic: clustering
Category: Data Science

In which situation should we consider a dataset as imbalanced?

I'm facing a problem about making a classification on a dataset. The target variable is binary (with 2 classes, 0 and 1). I have 8,161 samples in the training dataset. And for each class, I have: class 0: 6,008 samples, 73.6% of total numbers. class 1: 2,153 samples, 26.4% My questions are: In this case, should I consider the dataset I used as an imbalanced dataset? If it was, should I process the data before using RandomForest to make a …
Category: Data Science

Static and dynamic feature for hybrid modle

I would like to make a hybrid model in this way : I have a question about input data. My dynamic input is like [ [ [5],[4],[7] ],[ [7],[5],[7] ],...]. So shape is (400,3,1). But I don't know how the shape should be for my static input. I'm thinking something like this [ [1],[2],...], shape is (400,1). So for this sequence [ [5],[4],[7] ] in LSTM, i have this [1] in static_input. Do you think it's good?
Category: Data Science

Constant trend for test error

I'm using keras functional API in order to model a multi-input/multi-output relation in the form (y1,y2) = f(x1,x2,x3). I have a really simple architecture composed by 2 hidden layer of 64 nodes and one hidden layer of 16 nodes. The code is implemented as follow # split into train and test datasets x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25) print(x_train.shape, x_test.shape, y_train.shape, y_test.shape) n_features = x_train.shape[1] # ----------------------------------------------------------------------- inputs = keras.Input(shape=(n_features,)) dense = layers.Dense(64, activation="relu") x = dense(inputs) x …
Category: Data Science

Get posts with multiple meta values

I have a ACF select field which takes multiple value. Now I want to use get_posts() to get those custom posts. My arguments look like this: $party = 'test1'; $function = 'test1, test2'; $args = array( 'numberposts' => -1, 'post_type' => 'event', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'party', 'compare' => '=', 'value' => $party, ), array( 'key' => 'function', 'compare' => 'IN', 'value' => array($function), ) ) ); $items = get_posts($args); But this does not work! …
Category: Web

Custom Post Type canonical link / pagination redirecting to root

I have inherited an existing site and have recently been asked to make some changes. They have 'renamed' the default post as 'latest-news' using this 'my_new_default_post_type': <?php add_action( 'init', 'my_new_default_post_type', 1 ); function my_new_default_post_type() { register_post_type( 'post', array( 'labels' => array( 'name_admin_bar' => _x( 'Post', 'add new on admin bar' ), ), 'public' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'map_meta_cap' => true, 'hierarchical' => false, 'rewrite' => array('slug' => 'latest-news','with_front' => false), 'query_var' => true, …
Category: Web

Clustering of multi-label data

The dataset consists of 1) a set of objects and 2) a set of labels, which are used to describe the objects. For the moment, for simplicity sake, each label can be marked as either true or false (In a more complex setup, each label will have a value of 1-10). But, not all the labels are actually applied to all the objects (in principle, all the labels can and should be applied across all the objects, but in practice, …
Category: Data Science

Return only Count from a wp_query request?

Is it possible with the standard build-in tools in Wordpress to get wp_query to only return the count of an query? Right now, I’ve a query which has several meta_queries but what the only thing I’m interested in is the actually count of the query. I know that I can use the found_posts property but the query itself generates a big overhead by query SELECT * and thus returns the whole object. I could just as easy query the DB …
Category: Web

Take a custom taxonomy value and save as a standard Product Tag

I'm trying to find a way to take a custom taxonomy value, and add it as a tag to that same product. Long story short: a third party CRM only respects woo native categories & tags, so we'd like to take three custom taxonomy values and save them as tags. For instance, if a product is a Ganni dress in UK size 10 and has a 'style profile' of Romantic, then the three custom tax values retrieved will be 'ganni', …
Category: Web

Hide download button from audio player

[embed width="28"]http://audio.itunes.apple.com/apple-assets-us-std-000001/AudioPreview91/v4/e7/e0/fb/e7e0fbfb-5582-ee65-6a81-823b5ecf9186/mzaf_5076836927047056840.plus.aac.p.m4a[/embed] Since WordPress was updated to version 4.7, the audio player changed: after pressing the play icon, the play button now comes with other options, "download" and "mute". I want to hide those, and turn back to the simple play - pause Below is the image: In the past, after playing 'play', only the 'pause' button appeared as seen in the image below: I want it back. Any idea on how to do this?
Category: Web

Using sklearn knn imputation on a large dataset

I have a large dataset ~ 1 million rows by 400 features and I want to impute the missing values using sklearn KNNImputer. Trying this off the bat I hit memory problems, but I think I can solve this by chunking my dataset... I was hoping someone could confirm my method is sound and I haven't hit any gotchas. The sklearn KNNImputer has a fit method and a transform method so I believe if I fit the imputer instance on …
Category: Data Science

Song playlist recommendation system

I want to build a recommender system to suggest similar songs to continue a playlist (similar to what Spotify does by recommending similar songs at the end of a playlist). I want to build two models: one based on collaborative filtering and another one, a content-based model, to compare their results and choose the best one. Now, I have two questions: Where can I find a dataset with useful data for this type of work? How can I measure the …
Category: Data Science

How to suppress "Estimator fit failed. The score on this train-test" warning message?

I am working on hyper-tuning random forest classifier with following parameters in random search CV In [100]: # defining model Model = RandomForestClassifier(random state=1) # Parameter grid to pass in RandomSearchCV param grid = { "n_estimators": [200,250,300], "min_samples_leaf": np.arange(1, 4), "max_features": [np.arange(0.3, 0.6, 0.1),'sqrt'],"max_samples": np.arange(0.4, 0.7, 0.1)} #Calling RandomizedSearchcV randomized_cv = RandomizedSearchCV(estimator=Model, param distributions=param grid, n_iter=10, n_jobs = -1, scoring=metrics.make_scorer(metrics.recall_score)) #Fitting parameters in RandomizedSearchcv randomized cv.fit(X train, y train) print ("Best parameters are {} with CV score={}:" .format (randomized_cv.best params_,randomized_cv.best_score_)) …
Category: Data Science

How to train a machine learning model for named entity recognition

I cannot find any sources about the architectures of machine learning models to solve for NER problems. I vaguely knows it is a multiclass classification problem, but how can we format our input to feed into such multiclass classifier? I know the inputs must be annotated corpus, but how can we feed that chunk of pairs of (word, entity label) into the classifier? Or, how do you feature-engineer such corpus to feed into ML models? Or, in general, how can …
Category: Data Science

About

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