KDE on TF-IDF - sensitive bandwidth

I am clustering text based on TF-IDF features and DBSCAN (density based), and trying to rank points based on their 'belonging' to the cluster. Since my clustering is density based and my points can spread very randomly, I found Kernel Density Estimators relevant. However, the scores of KDE are very sensitive to the choice of bandwidth hyper-parameter, which I could not pre-estimate. Most bandwidth values end up with either infinite score for points outside the cluster, of zero for the …
Category: Data Science

Unable to sanitize in customizer and escape in theme without removing ability for user to use "< br >" to insert a line break

I have been unable to figure out how I can properly sanitize (in the customizer) and escape (in the theme, while allowing the user to use "&lt;" and ">" to insert a '&lt; br >' and add a line break wherever they want. I have an area in my theme's customizer that allows the user to put text in a text box, and it outputs to a main headline area of the site. It works fine, but it does not …
Category: Web

Do I need to encode numerical variables like "year"?

I have a simple time-series dataset. it has a date-time feature column. user,amount,date,job chris, 9500, 05/19/2022, clean chris, 14600, 05/12/2021, clean chris, 67900, 03/27/2021, cooking chris, 495900, 04/25/2021, fixing Using Pandas, I split this column into multiple features like year, month, day. ## Convert Date Coloumn into Date Time type data[&quot;date&quot;] = pd.to_datetime(data[&quot;date&quot;], errors=&quot;coerce&quot;) ## Order by User and Date data = data.sort_values(by=[&quot;user&quot;, &quot;date&quot;]) ## Split Date into Year, Month, Day data[&quot;year&quot;] = data[&quot;date&quot;].dt.year data[&quot;month&quot;] = data[&quot;date&quot;].dt.month data[&quot;day&quot;] = data[&quot;date&quot;].dt.day …
Category: Data Science

Is curl required?

My admin panel is very slow I've tried to debug the issue. I nailed it to the function wp_remote_post and an internal error message thrown by curl on this line return new WP_Error( 'http_request_failed', curl_error( $handle ) ); I wonder what would have happened if I uninstalled curl. Can WordPress use other mechanisms to make http requests or is curl required?
Category: Web

Proper iteration over time series data for LSTM neural network

I’m using the supervised learning method with an LSTM network to predict forex prices. To achieve this I’m using deeplearning4j library but I doubt several points of my implementation. I turned off the mini batch feature, then I created many trading indicators from forex data. The point is to provide random chunks of data to the neural network on every epoch and ensure that after every epoch the network state was cleaned. To achieve this I created a dataset iterator …
Category: Data Science

Machine learning frameworks for tree-based models

Background: Its well known that Pytorch and TensorFlow are currently the most used frameworks for Deep Learning (DL) research. As far as I know, most researchers (applied or theoretical) that contribute to the field of DL usually perform experiments with Pytorch. Specifically, the level of abstraction is just right to try custom architectures or models without having to build everything from scratch. Question: What about research in another popular field of machine learning, tree-based methods and ensembles? I am thinking …
Category: Data Science

News de duplication dataset

I am looking for a news dataset with semantically duplicate news articles tagged. Basically all the news articles which talk about the same story should be grouped. The stories can be worded differently but at a high level talk about the same event. Something like what google news does. Are there tagged news datasets for this ?
Category: Data Science

How do I hide submenus from the top menu bar?

My website is wiki-style and has a lot of pages that should only be reached through links on other pages. Having these all accessible from the top menu bar under their respective headings leads you from dropbox to dropbox as each page has more subpages- a huge inconvenience. I've managed to hide these in computer view by creating a 'dummy menu'. I added a '-' to either side of my menu bar so it looks like part of the design, …
Category: Web

Best Way to Redirect Category to Page and Hide Category

I have a category archive page at: http://mysite.com/news It displays an archive of items from the category 'news-article' I'd like to redirect any requests for http://mysite.com/category/news-article to http://mysite.com/news (so that the former is never directly accessible). Is there a best practice? Should I put a 301 Redirect in my .htaccess file (or use a plugin to do the same)? Or should I use wp_safe_redirect? If yes, which action hook should I use? As in: add_action( 'WHICH_ACTION_HOOK??', 'adam_redirect_news' ); function adam_redirect_news …
Category: Web

Creating a "Delete"-Button for Metadata userspecific

I want to build a dashboard, where a &quot;Trash&quot;-Symbol (Button) is shown. The User has several Accounts to manage in the dashboard. Account 01 Account 02 Account 03 and so on.. In each of this as gravity forms, where userdata is created and saved in the user meta. account01_login account01_target account02_login account02_target are the meta keys for example. Is it possible to build a button, where it is possible to do 2 things, if the button is pressed: Send an …
Category: Web

forcing decision tree use specific features first

My goal it to force some feature used firstly to split tree. Below, the function splitted tree using feature_3 first. For instance, is there a way to force to use feature_2 first instead of feature_3 ? from sklearn import datasets from sklearn.tree import DecisionTreeClassifier from sklearn import tree iris = datasets.load_iris() X = iris.data y = iris.target fit = DecisionTreeClassifier(max_leaf_nodes=3, random_state=0).fit(X,y) text_representation = tree.export_text(fit) print('Graph') print(text_representation)
Category: Data Science

Detect change in performance of new rasa model

I have a rasa nlu model running to detect intents and entities. Whenever a new model is loaded by rasa after training, I want to know how good or bad it is from previous model. What I am planning is , whenever a model is loaded first time, I can test it against some gold standard data and save the output metrics to compare with previous saved metrics. Questions: Is there any event which is loaded first and one time …
Category: Data Science

Incorrect example of applying Bayes theorem

I have been reading the book &quot;The Data Science Design Manual&quot; (by Steven S. Skiena) and I came across an example that explained how the Bayes theorem can be applied that confused me and made me suspect it might be wrong. The example is the following: $$ P(A|B) = \frac{P(B|A)P(A)}{P(B)} $$ Suppose A is the event that person x is actually a terrorist, and B is the result of a feature-based classifier that decides if x looks like a terrorist. …
Category: Data Science

wp_mail() inside AJAX handler never returns

We have an AJAX handler called by jQuery.ajax() that takes a document stored on the server and mails it to the user. At the bottom there is a call to wp_mail like so: $status_wpmail = wp_mail($recipient, $subject, $body, $headers, $filename); Problem is the email never gets sent out, and any code after the wp_mail call never gets parsed, including a debug statement to dump out the value of $status_wpmail. The jqXHR response sent back to the page reports 'success' however. …
Category: Web

Use current class method inside add_submenu_page()

I have a class like below. namespace Inc\Admin; class Admin { public function __construct() { add_action('admin_menu', [$this, 'admin_menu']); } public function admin_menu() { add_submenu_page('sports_info', 'Sports Information', 'Sports Information', 'manage_options', [$this,'sports_info_page'], [$this, 'html_page']); } public function html_page() { //some code } public function sports_info_page() { //some code } } I am getting below errors. Fatal error: Uncaught Error: Object of class Inc\Admin\Admin could not be converted to string Error comes from [$this,'sports_info_page'] of add_submenu_page().
Category: Web

Choosing attributes for k-means clustering

The k-means clustering tries to minimize the within-cluster scatter and maximizing the distances between clusters. It does so on all attributes. I am learning about this method on several datasets. To illustrate, in one the datasets countries are compared based on attributes related to their Human development Index. However some of the attributes are completely unrelated to this dimension, for example total population of countries. How to deal with this attributes? As mentioned before k-means tries to minimize the scatter …
Category: Data Science

Can't see past events on admin dashboard

Wordpress admin dashboard only shows the current and upcoming events, but there's seemingly no way to access the past events through admin dashboard. The event page on admin dashboard (wp-admin/edit.php?post_type=event) tells me that there are 146 events in total but only show 19 (current/upcoming) and there seems to be no way to change filtering/options to show all events. I feel like I have to be missing something incredibly obvious here.
Category: Web

What to do when seed has a big impact on model performance?

I have a training procedure set up for an image recognition task. Each time I train a model, I record training loss, validation loss, validation precision and validation recall. Recently I switched from EfficientNet to a ResNet-based model. Both models are pretrained, so weight initialization is deterministic. With the old model I ran 5 experiments (each on 5-folds) with exactly the same parameters, varying only the seed and got around 0.001 standard deviation for validation loss. With the new model …
Category: Data Science

usage of admin_url() in add_menu_page()

Does anybody have experienced this issue: using admin_url() in add_menu_page() returns an url that contains the domain name twice: add_submenu_page( 'smart-crm', __('WP SMART CRM Documents', 'mytextdomain'), __('Documents', 'mytextdomain'), 'manage_options', admin_url('admin.php?page=smart-crm&amp;p=documenti/list.php'), '' ); My output link is : https://domain.com/domain.com/wp-admin/admin.php?page=smart-crm&amp;p=documenti/list.php any idea?
Category: Web

I am trying to establish a relationship b/n hcanopy & 18 predictors (vv_name & vh_name) using CNN but my model isn't learning. How can I resolve it?

Before building and running the model, I have rescaled and normalized the data. Here is my model - #Build the model from keras_tuner import RandomSearch, BayesianOptimization def build_model(hp): model = keras.Sequential([ keras.layers.Conv1D( filters=hp.Int('conv_1_filter', min_value=16, max_value=256, step=16), kernel_size=hp.Choice('conv_1_kernel', values = [2,3]), activation= hp.Choice('conv_1_activ', values = ['relu', 'sigmoid']), #strides = hp.Int('conv_1_strides', min_value=1, max_value=5, step=1), padding = 'same', input_shape=(18,1)), keras.layers.MaxPooling1D( pool_size = hp.Choice('maxpool_1_kernel', values = [2,3]), padding = 'same', #strides = hp.Int('maxpool_1_strides', min_value=1, max_value=5, step=1), ), keras.layers.Flatten(), keras.layers.Dense( units=hp.Int('dense_1_units', min_value=16, max_value=256, step=16), activation='relu' …
Category: Data Science

301 Redirect all page and post urls from .html to /

I have a current site where all URLs end with .html. I created a new site and the URLs are pretty much the same but without .html. I've been trying codes found here in my .htaccess file and most seem to cause Internal Server Error. http://example.com/page1.html to http://example.com/page1/ http://example.com/page1/page2.html to http://example.com/page1/page2/ My current .htaccess file code is: # BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] …
Category: Web

How to use LSTM for time series data?

I've an ECG data spread over time. The duration for each data is around 3 minutes (approx 180 seconds). Each second around 200 recordings were taken. So total length for each sample is approx 36000. Now how to use this data for lstm. My purpose is to make an encoder-decoder network to encode this data into small size. I'm planning to use reconstruction error for loss function.
Category: Data Science

Any quicker alternative for WP_Query "NOT IN"

I am using the following wp_query to pull up a list of post, and I want to exclude a few categories of a custom taxonomy. It works well, however Query Monitor is telling me that the query is slow. I removed the 'tax_query' part of the query and it sped up. Is there a faster way to exclude these categories? Thanks! My Query: $args = array( 'post_type' =&gt; array( 'recipe' ), 'post_status' =&gt; array( 'publish' ), 'order' =&gt; 'DESC', 'orderby' …
Category: Web

CNN application assessment

I would be glad if someone could give me some hints and assessment for the following project. (I'm relatively new to ML and DL and having only a little theoretical knowledge) My goal is to build a detector for receipt corners in images. I started to create a dataset with images of the receipts with the labels being the 4 corner points of the receipt. My plan is to train a CNN with the dataset and I wonder if you …
Category: Data Science

Clickable product image with hover effect

I have a theme with woocommerce. Some products have more than one photo, and when user hovers over such products, those photos (that are in the photo gallery) will rollover. I want to make the product image clickabe to do that I've used this code, and added to functions.php if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) { /** * Get the product thumbnail, or the placeholder if not set. * * @subpackage Loop * @param string $size (default: 'shop_catalog') * …
Category: Web

how to show records that don't have custom meta value

Running pre_get_posts, I want to order the items by a custom meta value. The problem is that by default this doesn't exist. Only if a user performs a certain action does the meta key/value get added. That being said, even if they don't ever click on the item itself, I would like it to be displayed. Basically the order is the number of clicks an items has received. So, the most clicked item should be first and the items that …
Category: Web

Adding high p-value and low R square features in linear regression model to improve result

I am working on a linear regression problem. The features for my analysis have been selected using p-values and domain knowledge. After selecting these features, the performance of $R^2$ and the $RMSE$ improved from 0.25 to 0.85. But here is the issue, the features selected using domain knowledge have very high p-values (0.7, 0.9) and very low $R^2$ (0.002, 0.0004). Does it make sense to add such features even if your model shows improvement in performance. As far I know, …
Category: Data Science

How to add a secondary button to a settings page with a custom action?

I have written a plugin that interfaces with a third-party mailing API. I have created a settings page for my plugin that includes two buttons: a submit button created with submit_button() which saves the form a "test settings" button that should use the current values from the form without saving them This is what I currently have: echo '&lt;form method="post" action="options.php"&gt;'; settings_fields('myplugin_settings'); do_settings_sections('myplugin'); echo '&lt;p&gt;'; submit_button('Test Settings', '', 'test', false); echo ' '; submit_button(null, 'primary', 'submit', false); echo '&lt;/p&gt;&lt;/form&gt;'; This …
Category: Web

About

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