What metrics work well in unbalanced assemblies?

I wanted to know if there are some metrics that work well when working with an unbalanced dataset. I know that accuracy is a very bad metric when evaluating a classifier when the data is unbalanced but, what about for example the Kappa index? Best regards and thanks.
Category: Data Science

Failed to load resource: the server responded with a status of 431 ()

This error appeared only yesterday. When I try to do anything in admin except adding posts/pages, there is a white screen and chrome console reveals. I can't update wordpress core, can't update/install/delete plugins ... Failed to load resource: the server responded with a status of 431 () No idea what's the issue and how to fix it. Thanks for helping out! UPDATE - this was a Chrome issue - after I cleared my cookies, everything works OK Could somebody explain …
Category: Web

How to define tidy data if there is repeated measures?

Some time ago I read R for Data Sciece and there is the following definition of tidy data: There are three interrelated rules which make a dataset tidy: Each variable must have its own column. Each observation must have its own row. Each value must have its own cell. Back then, the idea seemed quite reasonable but now the concept seems not that consistent to me. In chapter 12 it is said that table1 is tidy and this is how …
Category: Data Science

can't install any wp plugins

We recently moved WP hosts. We backed up WP and imported it to a development site wp.mysite.com to get it all set up. Once everything was done, we switched the DNS and went live with newdomain.com on the new server. It's been running for a while but I now see a problem with plug-ins. The end user wanted to add a plugin but gets a 403 permissions denied error and at the top of the error it lists wp.mysite.com (the …
Category: Web

Creating dynamic content and pages for 1000's of locations

How can I generate dynamic pages on a Wordpress website from information provided in a separate MySQL database? I have a database with Locations and I would like to have a page for each of these created dynamically. For example, I have a database entry for LOCATION1. If the location exists in the database, I would like a page such as www.example.com/LOCATION1/ and for the content to be dynamic, using information from the database.
Category: Web

Model stalls and learning slows down after the first epochs

I have an issue with a model that I'm working on, I cannot show you the model architecture because it's basically confidential research. The model includes Graph convolutional networks and Transformer encoders combined to process and classify both sequences and graphs, I have dropout and layernorm and skip connections everywhere. Optimizer : RAdam with a reducelronplateau scheduler The issue is that the model learns pretty fast in a natural progression in the first 10 to 15 epochs but tends to …
Category: Data Science

How to get php file based on URL in WordPress

I am trying to edit the home page for the wordpress site but I am not able to find the PHP file. The file should be under the theme file and I have checked almost all the file(which is not the correct way) but was not able to find it. Looking for some way through which I can get the exact file name via URL as in CodeIgniter we use ROUTES.PHP, if there is any way. Thanks in advance.
Category: Web

How to Implement a Custom Loss Function with Keras for a Sparse Dataset

My dataset is composed of an idle system that, at some time instants, receives requests. I'm trying to predict these instants through a clock. Since the requests are sparsely distributed (I've forced them to last for a while so they don't get too sparse), I wanted to create a new loss function that would penalize the model if it only gives out a zero prediction for everything. My implementation attempt is just a penalty for the standard logits: def sparse_penalty_logits(y_true, …
Category: Data Science

Training stateful LSTM with different number of sequences

I'm using a stateful LSTM for stock market analysis, and I have varying amounts of data for each stock, ranging from 20 years to just a few weeks (i.e. for newly listed stocks). I use 3 years of data as a minimum for training as I want to create some state within the network. I set a year as my sequence length, so if I have 12 years of data then I will submit 4 batches with 3 sequences in …
Category: Data Science

Plugin with connection to database - Single function

I'm creating a personal plugin with more files and I need to connect to an external database with WPDB. At the moment I'm repeating "new wpdb(...)" in every function, in every file, of my plugin. Is there any way to put this instruction just ONE time?
Topic: wpdb Wordpress
Category: Web

Sum vs mean of word-embeddings for sentence similarity

So, say I have the following sentences ["The dog says woof", "a king leads the country", "an apple is red"] I can embed each word using an N dimensional vector, and represent each sentence as either the sum or mean of all the words in the sentence (e.g Word2Vec). When we represent the words as vectors we can do something like vector(king)-vector(man)+vector(woman) = vector(queen) which then combines the different "meanings" of each vector and create a new, where the mean …
Category: Data Science

Distribution Shift vs Transfer Learning

Transfer learning (TL) is a research problem in machine learning (ML) that focuses on storing knowledge gained while solving one problem and applying it to a different but related problem [1] Distribution Shift The conditions under which the system was developed will differ from those in which we use the system. [2] I consider there is no difference between distribution shift and dataset shift. But between transfer learning and distribution shift? What are the differences? Can we say that transfer …
Category: Data Science

Association Rule Mining across two market baskets

I am quite familiar with Association Rule mining but I need to use it to associate ACROSS two market baskets instead of finding support WITHIN a market basket. Imagine customers come to a Store A and buy a certain number of products. The same customers go to Store B and buy another set of products. I want to associate between the two Stores and not within the Store. So I want to make "A --> B" statements like "Customers that …
Category: Data Science

How to stop wp-editor() overwriting my HTML?

I have the old problem that the WordPress editor overwrites my HTML code. For example, the editor inserts <p> and <br> tags where you don't have them set. The second problem is the editor doesn't show the real source code. If I write some code in the editor, and update, and look afterwards at the source code in the front-end (e.g. with Firefox), it shows there are tags which I can't see in the back-end editor. To suppress the problem, …
Category: Web

Change reminder email date to 14 days before

I want to send the reminder email for a booking (from the Woocommerce Booking plugin) 14 days before the activity instead of the default 1. I have found the following code online and added it to wp-content/themes/flatsome-child/functions.php but none of them seem to trigger or work. add_filter( 'woocommerce_bookings_remind_before_days', 'drop_reminder_days', 10 ); function drop_reminder_days($value) { error_log("===== this is the amount of days ======"); error_log($value); return 14; } add_filter( 'woocommerce_bookings_remind_before_days', function() {return 14;}, 10, 2 ); add_filter( 'woocommerce_bookings_remind_before_days', create_function( '', 'return 3;' …
Category: Web

Evaluation of the preprocessing to make a dataset anonymous

I have a very huge dataset from the NLP area and I want to make it anonymous. Is there any way to check if my pre-processing is correct? Generaly, is there any way to evaluate how good is the pre-processing for the anonyminity? I want to mention that the dataset is really huge, therefore it can be cheched manually.
Category: Data Science

Illustrating the dimensionality reduction done by a classification or regression model

Tl;DR: You can predict something, but how do you explain the prediction? Your usual classification/regression setup Lets say the data is a classic regression/classification problem: several numerical columns, several nominal columns, and an event which we are trying to predict: user1, age:18, wealth:20000, likes:tomatoes, isInBigCity:yes, hasClicked:yes user2, age:25, wealth:24000, likes:carrots , isInBigCity:no , hasClicked:no ... With the help of Random Forests, SVM, Logistic Regression, Deep Neural Network, or some other method we export a model that can output a probability …
Category: Data Science

Nonce fail after second submit attempt

I am refactoring my plugin that resets the WordPress database tables back to their defaults and came across an issue. The form submission itself works fine. However, after the first submit, and if you do not refresh the page and submit the form again, the nonce seems to fail. Perhaps there is someone that fully understands how nonces work as I am not sure what is causing this. I have the necessary check for wp_nonce_field and check_admin_referer on the administration …
Category: Web

Multiple editable content on page

EDIT: I've found out that by using Advanced Custom Fields I can edit multiple fields on a page. Why WP doesn't have this feature by default I'll never know. This is the kind of ability I was looking for that PerchCMS has by default. Thanks for your answers. I'm new to writing websites using Wordpress as a CMS, and in the past I've used a CMS called PerchCMS which allows me to add extra multiple sections by using the php …
Topic: cms Wordpress
Category: Web

Prediction: plugin a corelation table (neuron) into a Time-Series Neuron in Keras/ TF

i am adding more details I have a time series of Babies (1,2,3) showing how many problem they have each week (Born week 1 to week 80) and in which organ (14 organ). There is a separate numeric time-free correlation tables for babies/organs. showing Xtype blood cells per organ per baby -> Causes problems My aim is to predict how many problem will NewBaby (Baby4) have, in which organ, per week Predict this: Week1: 1 problem | Stomach Week1: 1 …
Category: Data Science

How To Use do_shortcode with WooCommerce One Page Checkout

I'm trying to use the WordPress do_shortcode function for the WooCommerce One Page Checkout Plugin which uses shortcode like this: [woocommerce_one_page_checkout template="product-table" product_ids="product, ids, here"]. I can ONLY use this shortcode IF it's in the content editor and it won't allow me to add this to a page template using the do_shortcode function. Their documentation here says: If you wish to display the One Page Checkout Shortcode using WordPress’ do_shortcode() function instead of including the shortcode in a post or …
Category: Web

NaNs in predictions with LSTM

I have an LSTM model that I have trained and tested it with a dataset. Now I want to test it to an other dataset and I use the following snippet: from keras.models import load_model import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.preprocessing import MinMaxScaler from sklearn.metrics import mean_squared_error from sklearn.metrics import mean_absolute_percentage_error model = load_model('lstm.h5') df = pd.read_csv('datasets/Residential_4.csv') data = df['energy_kWh'].values data = data.reshape((-1,1)) scaler = MinMaxScaler(feature_range=(0,1)) data = scaler.fit_transform(data) lookback = 7 …
Category: Data Science

Reduce nonce lifespan

for a personal plugin (nothing going to the public or commercial), I built an AJAX form and its endpoint is a custom endpoint (REST Api). When a certain Page containing my form is accessed, I generate a nonce. Then, the user sends the form, I add the conventional header (X-WP-Nonce) and in the endpoint function I validate the nonce I first created when the page was loaded. I would like my nonce to be short-lived, that is, 12 hours is …
Category: Web

Input shape of dataset in hybrid CNN-SVM classifier

I am working on hybrid CNN-SVM for classification task, where I aim to use CNN for feature extraction and SVM for classification. So after the training of my CNN model as below: import os import numpy as np import matplotlib.pyplot as plt import tensorflow as tf import keras from keras.layers import Dense, Conv2D, InputLayer, Flatten, MaxPool2D (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data() print('Training data: {}, {}'.format(x_train.shape, y_train.shape)) print('Test data: {}, {}'.format(x_test.shape, y_test.shape)) x_train, x_test = x_train / 255.0, x_test / …
Category: Data Science

Is my model overfitting ? Training Acc :93 % test accuracy 82%

I am using LGBM model for binary classification. After hyper-parameter tuning I get Training accuracy 0.9340 Test accuracy 0.8213 can I say my model is overfitting? Or is it acceptable in the industry? Also to add to this when I increase the num_leaves for the same model,I am able to achieve: Train Accuracy : 0.8675 test accuracy : 0.8137 Which one of these results are acceptable and can be reported?
Category: Data Science

admin-ajax Firing Error 400 When Logged In

Ah yes, the ol' admin-ajax error 400 issue. I have looked here and here and here for a solution and none of those fixed my problem. So before this is marked as a duplicate, please just hear me out. My admin-ajax link looks like so: <script type="text/javascript"> var ajaxurl = "https://full-url.com/wp-admin/admin-ajax.php"; </script> My AJAX call looks like this: var data = { action: 'get_events' }; jQuery.ajax({ url: ajaxurl, data: data, type: 'POST', success: function(data){ console.log(data); }, error: function(xhr, ajaxOptions, thrownError) …
Category: Web

Input shape error

I've this item: ['6', '1', '6', '843537', '3', '0', '5', '1006709', '3', '1', '4'] with shape: (11,) but when go to predict with: print(np.array(data).shape) data = np.expand_dims(data, axis=0) print('Predict: ' + model.predict(sc.transform(data))) i get this error: ValueError: Input 0 of layer "sequential_2" is incompatible with the layer: expected shape=(None, 1, 11), found shape=(None, 11) how can I do the fix?
Category: Data Science

Display images in template file

I have one template file for the main page, after creating home page I have added text to check if it reflect changes on my home page or not and it was successfully displaying text. But when I try to add image by clicking on add media option then image is uploaded but not displaying on my page. What piece of code should be used to get this image on my template file or any other suggestions?
Category: Web

PySpark createDataFrame() throws segmentation fault on Mac

I'm trying to learn PySpark. Finally got it installed following the tutorial here: https://sparkbyexamples.com/pyspark/install-pyspark-in-anaconda-jupyter-notebook/ However, even though I am now able to create a spark session (I can access the GUI, create some RDDs, etc.), any time I try to create a DataFrame, no matter how tiny, I get a segmentation fault (when I'm in shell) or my kernel crashes (when I'm in Jupyter notebook). I'm on MacOS Monterey (12.3.1), spark v3.1.2, Python 3.9.11 (conda distribution installed via homebrew), java …
Topic: pyspark
Category: Data Science

Console errors in 6.0-RC1 Widget screen

Sine 6.0-RC1 the following console error appears on the block widgets screen, on Firefox: Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. NotEmpty@https://betatest.opajaap.nl/wp-includes/js/dist/widgets.js?ver=80e98954519d1dad7a91a2248dbc2cc9:1118:7 div Edit@https://betatest.opajaap.nl/wp-includes/js/dist/widgets.js?ver=80e98954519d1dad7a91a2248dbc2cc9:1051:7 Edit@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:12908:7 withToolbarControls</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:12263:7 withInspectorControl</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:12475:26 custom_class_name_withInspectorControl</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:12582:35 withBlockControls</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:36311:33 withDuotoneControls</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:36678:32 withInspectorControls</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:36924:7 queryTopInspectorControls</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-library.js?ver=c0a77efe7e30b81595292ba7bdec3d8f:35990:7 withMoveToWidgetAreaToolbarItem</<@https://betatest.opajaap.nl/wp-includes/js/dist/edit-widgets.js?ver=6d1c3f1e5fbca4e69781de58b399425e:2327:7 FilteredComponentRenderer@https://betatest.opajaap.nl/wp-includes/js/dist/components.js?ver=704ed65a1b8b5c891184113526f15ce4:73834:9BlockListBlock@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:18670:7 withDataAlign</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:12314:7 withBorderColorPaletteStyles</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:32258:7 withColorPaletteStyles</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:34086:7 withFontSizeInlineStyles</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:35312:31 withElementsStyles</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:36324:112 withDuotoneStyles</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:36722:29 withLayoutStyles</<@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:36944:7 FilteredComponentRenderer@https://betatest.opajaap.nl/wp-includes/js/dist/components.js?ver=704ed65a1b8b5c891184113526f15ce4:73834:9 ifCondition/</<@https://betatest.opajaap.nl/wp-includes/js/dist/compose.js?ver=da94d523b115836ddbf0b3b774ddd94a:2201:8 withDispatch/</<@https://betatest.opajaap.nl/wp-includes/js/dist/data.js?ver=38ad563aa39c8f314fe6f6e430d81a69:4316:46 withSelect/</<@https://betatest.opajaap.nl/wp-includes/js/dist/data.js?ver=38ad563aa39c8f314fe6f6e430d81a69:4160:31 @https://betatest.opajaap.nl/wp-includes/js/dist/compose.js?ver=da94d523b115836ddbf0b3b774ddd94a:2236:12 Items@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:31568:7 BlockListItems BlockContextProvider@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:12861:7 UncontrolledInnerBlocks@https://betatest.opajaap.nl/wp-includes/js/dist/block-editor.js?ver=e2ef0c6eb29e06ea9efedec924f1b9a8:31358:7 …
Category: Web

I cannot work out the benefits of a pipeline over a linear sequence of code instructions

I've looked at quite a number of how to 'create a pipeline' instructions, but I have yet to see an explanation of the benefits over what I am showing below. To keep my example code agnostic I'll use simple pseudo-code. So what I've been doing in order to, for example, train a model is... Create functions/methods function get_data(parm1, parm2...) function prepare_data(...) function train_model(...) function test_model(...) Run functions/methods <- this is what I mean by 'linear sequence of code instructions' in …
Category: Data Science

About

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