dataset split for image classification

I am trying to do image classification for 14 categories (around 1000 images for each cat). And i initially created two folders for training and validation. In this case, do I still need to set a validation split or a subset in a code? or I can use the whole files as train_ds and val_ds by deleting them Folder names in the training and validation directory are same. data_dir = 'trainingdatav1' data_val = 'Validationv1' train_ds = tf.keras.preprocessing.image_dataset_from_directory( data_dir, validation_split=0.1, #is …
Category: Data Science

Error in Validate Field with ACF plugin in Wordpress

I have the following problem when I am validating a field with the Advanced Custom Fields plugin in wordpress. What happens is that the field is validated correctly but the error appears on a new page instead of going out on the same page above the field to which I am validating. The code to validate is the following: function validate_fields_contact() { add_filter('acf/validate_value/name=phone_contact', 'validate_phone_number', 10, 4); } function validate_phone_number($valid, $value, $field, $input) { if (!$valid) { return $valid; } if(!preg_match("/^\+XX(\s|\d){8,12}$/", …
Category: Web

What to do if your adversarial validation show different distributions for an NLP problem?

I was trying to figure out if the test set from a competition is similar to the train set. This was done in a NLP competition, in which I had two columns, tweet and type, and I needed to predict the type of crime the tweet was reporting. So I decided to check if the train set is too different from the test set. This is what I've done so far: # drop the target column from the training data …
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

Training loss decreasing while Validation loss is not decreasing

I am wondering why validation loss of this regression problem is not decreasing while I have implemented several methods such as making the model simpler, adding early stopping, various learning rates, and also regularizers, but none of them have worked properly. any suggestions would be appreciated. here is my code and my outputs: optimizer = keras.optimizers.Adam(lr=1e-3) model = Sequential() model.add(LSTM(units=50, activation='relu', activity_regularizer=tf.keras.regularizers.l2(1e-2), return_sequences=True, input_shape=(x_train.shape[1], x_train.shape[2]))) model.add(Dropout(0.2)) model.add(LSTM(units=50, activation='relu', activity_regularizer=tf.keras.regularizers.l2(1e-2), return_sequences=False)) model.add(Dropout(0.2)) model.add(Dense(y_train.shape[1])) model.compile(optimizer=optimizer, loss='mae') callback = tf.keras.callbacks.EarlyStopping(monitor='loss', patience=3) history = …
Category: Data Science

Contact Form 7 Wordpress, checking a few fields, if empty then invalid

Could someone help me to solve the problem. I would like the system work like bellow. If both fields are empty = invalid. If any of the fields is completed = valid add_filter('wpcf7_validate_text', 'or_input_validation_filter', 20, 2); function or_input_validation_filter($result, $tag) { if ('your-link' == $tag->name) { $your_link = isset($_POST['your-link']) ? trim($_POST['your-link']) : ''; $your_file = isset($_FILES['your-file']) ? trim($_FILES['your-file']['name']) : ''; if($your_link == '' && $your_file == '') { $result->invalidate($tag, "One of the fields has not been completed?"); } } return $result; …
Category: Web

Change pubDate in rss feed in another format

In the default wordpress rss feed the element <pubDate> is <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> and gives a result of <pubDate>Tue, 12 May 2020 12:39:03 +0000</pubDate> how can i change this line to give a result of <pubDate>12/05/2020 12:39:03 +0000</pubDate> (d/m/Y) or <pubDate>12-05-2020 12:39:03 +0000</pubDate> (d-m-Y) but to be valid with RFC-822 ? I tried many variations <pubDate><?php echo mysql2date('r', get_the_time('Y-m-d H:i:s')); ?></pubDate> or <pubDate><?php echo get_post_time( 'd/m/Y …
Category: Web

Validation loss and validation accuracy stay the same in NN model

I am trying to train a keras NN regression model for music emotion prediction from audio features. (I am a beginner in NN and I am doing this as study project.) I have 193 features for training/prediction and it should predict valence and arousal values. I have prepared a NN model with 5 layers: model = Sequential() model.add(Dense(100, activation='elu', input_dim=193)) model.add(Dense(200, activation='elu')) model.add(Dense(200, activation='elu')) model.add(Dense(100, activation='elu')) model.add(Dense( 2, activation='elu')) And this is my loss and optimizer metrics: model.compile( loss = …
Category: Data Science

Model Performance on external validation Set really low?

I am using the LGBM model for binary classification. My train and test accuracies are 87% & 82% respectively with cross-validation of 89%. ROC-AUC score of 81%. But when evaluating model performance on an external validation test that has not been seen before, the model gives a roc-auc of 41%. Can somebody suggest what should be done?
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

Add file upload with validation to custom form

I have a custom contact form page that I am trying to add an upload field that validates filesize and filetype. Before adding the validation everything worked. &lt;?php /* Template Name: Contact-Page-with-upload * * A Custom PHP Contact us page. Add or change form fields on line 28 and in the form itself. * Jquery is used to add/remove Bootstrap has-error class to invalid fields. */ /** * Get Error Class * * @return string; */ function getErrorClass($failedKeys, $key) { …
Category: Web

Why is my validation loss never INcreasing?

I am currently training different neural networks for the binary classification of images. When using the logistic regression, my validation loss never increases, even not after 5000 epochs. I thought that at some point overfitting happens and the validation loss always increases. Does anybody know why this does not happen?
Category: Data Science

How to compare a machine learning model and a rule based model

The difference between machine leaning models and rule based model is that you feed input and output to machine learning models to get rules where you feed input and rules to rule based models to get output. Say you have a dataset with 10k records. You might use 8k of them to build a machine learning model and the rest to validate your model. On the other hand, you would probably use all the 10k records to create a rule …
Category: Data Science

How to add custom regex validation to WPForms password field

I'm using WPForms Pro and I'd like to add custom requirements to the password field on a form. I know that the password field has a password strength requirement setting, but I have specific rules I'd like to enforce, which are: Between 12 and 32 characters At least 1 number At least 1 capital letter At least 1 special character I came up with the following regex for this: ^(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&amp;])[A-Za-z\d@$!%*?&amp;]{12,32}$ and wrote to WPForms support, who told me that they …
Category: Web

Using Z-test score to evaluate model performance

I think I know the answer to this question but I am looking for a sanity check here: Is it appropriate to use z-test scores in order to evaluate the performance of my model? I have a binary model that I have developed with a NN in Keras. I know the size of my (equally balanced) training set and it has a proportion of 0.5 (duh!). I know that with my business use case, false-positives are financially expensive so I'm …
Category: Data Science

What does it mean if the validation accuracy is equal to the testing accuracy?

I am training a CNN model for my specific problem. I have divided the dataset into 70% training set, 20% validation set, and 10% test set. The validation accuracy achieved was 95% and the test accuracy achieved was also 95%. What does this mean? Is this mean that the model is not biased ( not biased to the samples in the validation set ) and its hyperparameters have been fine-tuned correctly? Also, do these results confirm the generalization ability of …
Category: Data Science

How can I calculate de AUC PR of my classifiers in a multiclass scenario?

I'm developing image classifiers in a context with 25k images and 50 classes. The dataset is imbalanced. Some papers recommend AUC PR for comparing the performance of my classifiers in this setting. However, I was not able to find any implementation for calculating this metric for multiclass contexts. How can I calculate it? If you have some piece of code that implements this, it would be very helpfull.
Category: Data Science

jquery.validation.js is not working in woocommerce checkout page form

jQuery("#woocommerce_checkout_form").validate({ highlight: function(element) { (jQuery(element).parent()).parent().addClass("woocommerce-invalid"); (jQuery(element).parent()).parent().removeClass("woocommerce-validated"); }, unhighlight: function(element) { (jQuery(element).parent()).parent().removeClass("woocommerce-invalid"); (jQuery(element).parent()).parent().addClass("woocommerce-validated"); }, submitHandler: function(form) { jQuery.ajax({ type: "POST", data:values, url: jQuery(form).attr('action'), success: function(data){ //alert('ajax load'); //window.location.href = "http://demo7.web.dev1.bl/wp-content/plugins/woocommerce/templates/checkout/checkout.php"; } }); return true; //jQuery(form).ajaxSubmit(); }, rules: { billing_phone: { required: true, minlength:10, maxlength:10, number: true, }, billing_postcode: { required: true, minlength:6, maxlength:6, number: true }, shipping_postcode: { required: true, minlength:6, maxlength:6, number: true } }, messages: { billing_phone: { required: "Enter Phone Number", minlength:"Please 10 Digit Phone Number", maxlength:"Please 10 …
Category: Web

Jquery Validation Engine with Conatct Form 7

I am using contact form 7 and it's working with basic validations. But i have to do some advanced validation. So i have to use https://github.com/posabsolute/jQuery-Validation-Engine. How can i use vaidation engine with Contact form 7?
Category: Web

About

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