Should batch normalization make my eval inference so dependent on the batch size?

I am using pytorch, and the relevant piece of code is below, from my .forward call: class ModelDense(nn.Module): def __init__(self, raw_features, n, features): super(ModelDense, self).__init__() self.linear_pre = nn.Linear(raw_features, features) self.batchnorm_pre = nn.BatchNorm1d(features) self.tower = ResTowerDense(n, features) self.value_linear1 = nn.Linear(features, features) self.value_batchnorm = nn.BatchNorm1d(features) self.value_linear2 = nn.Linear(features, 1) def forward(self, x, mask0, mask1): y = self.tower(self.batchnorm_pre(self.linear_pre(x))) v = torch.sigmoid(self.value_linear2(self.value_batchnorm(F.relu(self.value_linear1(y))))) Here 'self.tower' is a tower of residual blocks. The output in question is 'v', which is just a sigmoid activation. After training …
Category: Data Science

Using a pipeline and transforming data with imputing and OneHotEncoding performs worse than get_dummies

I'm still in the process of learning, so I'm sorry if this doesn't make much sense. I'm doing Kaggle learns micro courses, and to work with missing tabular data we learned about using pipelines with imputers for numerical data and OneHotEncoding for categorical data. On the other hand, we also learned about using just pd.get_dummies which from my understanding just works as OneHotEncoding (please, correct me if I'm wrong about this). However, using just pd.get_dummies seems to give me better …
Category: Data Science

Do not allow users to create new posts and pages

I'm defining a new user role called Proofreader and as the name says, users of this group should be able to read and also edit the posts and pages. But I do not want them to create new ones. With my custom post types I can set a capability create_post -> create_{cpt_name} and set it to false for this user group. In the backend they now don't see the add button, but can still edit the posts. That's exactly what …
Category: Web

Displaying data from custom table

Just looking for a bit of advice on how to handle this: In the past (many moons ago) when I did the occasional php/mysql work, it was relatively easy to pull/display data from a table using the table header in the "WHERE" query. (i.e. SELECT * FROM 'table' WHERE 'column-name' = 'query'). The tables would have columns for each piece of information such as email, phone, address, etc. I am currently working on a project using a table that was …
Category: Web

What is the Zhang's rule?

I'd been doing some reading on Association Rule Mining and bumped into a Kaggle dataset where a competitor had applied Zhang's rule. I would like to know what it is. I tried to look for it online, and most of the hits revolve around some Chinese emperor by that name whol ruled China. And the other things arn't really relevant. If there is anything that you can share about it, like its significance that'd be great. There's also no tag …
Category: Data Science

Missclassfication of Hand Generated Signals

I have two types of time series accelerometer data from two kinds of machines - one is very fast (Type A) and another one is relatively slow in terms of number of peaks/movement (Type B). I have tried various models on the RMS values of the x y z values - like time series KNN, RISE, and even a decision tree based on the features extracted from these two types of signals. These models give fairly good results too. Now …
Category: Data Science

Why does admin_body_class not work?

I'm trying to add the body class of the current user role to both the frontend and the admin backend. Why does admin_body_class not work for admin? The comment to this question does not work: How to insert the current user's role into the body class in the admin backend This works for the front end in the theme's functions.php file: add_filter("body_class", function($classes) { global $current_user; foreach ($current_user->roles as $user_role) { $classes[] = "role-{$user_role}"; } return $classes; }); This does …
Category: Web

A/B Testing (Binomial Distribution vs Random Distribution)

When performing an A/B test for the number of clicks for users viewing (each view is an impression) two variants of an ad, a binomial distribution can be assumed where each variant has a constant click-through rate. Example: Two Ads, -> Ad one has 1000 impressions and 20 clicks, CTR is 2%; -> Ad two has 900 impressions and 30 clicks, CTR is 3.3%. Test whether there is a difference between Click Through Rate (CTR) between Ads one and two. …
Category: Data Science

Learning Python for Data Science

Is it necessary to learn Python from square one if your ultimate goal is to use it for data science? I have used R a lot for data science. But could I learn Python sufficiently well just by looking at other data science problems and their Pythonic approaches?
Topic: python
Category: Data Science

Multi-label classification with nested features

I need to perform a multi-label classification. I have three features and they are nested. I am unsure how to combine this or what kind of classification algorithm would be best. Some multi level neural network as shown here seems good, but the nested features don't seem to be taken into account there. I present the nested features (X) and labels (Y) in the two datasets below: one subject ID can have one or more features and one or more …
Category: Data Science

Can't log into wordpress site - I have made a new user and still cant access

I recently took over website management for my company but I can not access 1 of our sites. The user name and password provided by the last management team does not work. I refrenced my Wp-Config to determine which SQLdb was being used. Then accessed phpMyAdmin and reviewed the wp_user table for the db and the user they provided was not even listed. I edited the existing admin user password (using MD5) and still could not log in with that …
Category: Web

How does the datasampler widget's cross-validation option of Orange software work?

I use a datasampler widget to split a dataset (train and test) with the cross-validation selection. I wonder how it works because some points did not seem clear to me. Question 1: As seen in the figure, I split the data into five subsets (each has 20 observations). Then, I selected one of the subsets (remaining data) to test the models, which means the four subsets are used for training. At this point, while the algorithms build a model, are …
Category: Data Science

Dynamic creation of sklearn pipeline

I am trying to create an automatic pipeline builder functionality that takes into account a large set of conditions such as the existence of missing values, the scale of numerical features, etc., and automatically creates a scikit-learn pipeline instead of having to manually create them every time. I'm aware of pipeline.steps.append() functionality that allows to assign new pipeline steps dynamically. However it seems to be not allowed to initialize an empty pipeline to start appending to; doing the following yields …
Category: Data Science

Check if current page is using blocks (Gutenberg) or is legacy

Is there a way to know if a page is using Gutenberg or not? The use case is migrating an old post to Gutenberg and letting crafted pages just render themselves with blocks but add some wrapping around old pages which probably won't be migrated since they're just text (Privacy policy and those). They need to coexist at least for a while. A block editor page can usually be just rendered with <?php get_header(); while (have_posts()) : the_post(); the_content(); endwhile; …
Category: Web

How can I display these posts in ascending order?

I am trying to display some posts in ascending order beginning with the first created and ending with the most recently created post. Any help is appreciated. Here is my code: <?php $numofmebers = '-1'; if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1; $count_post = 0; query_posts( array( 'posts_per_page' => '-1', 'post_type' => 'coach-instructor' ,'post_status' => 'publish') ); while ( have_posts()) : the_post(); $count_post++; endwhile; if ( $node->instructor_pagination == "Single Page" ) {$node->instructor_page_num = -1;} query_posts( array('posts_per_page' => "$node->instructor_page_num", 'paged' => …
Category: Web

Proper Way to Modify Plugin

What is the best way to modify a plugin? I frequently want to make small changes to one or two functions within a large plugin. This is easily done, but I have to use comments to mark my changes and modify the plugin again after an update. Ideally I'd like to leave the plugin alone and make my changes elsewhere, much like we do with themes and child themes. Can I make a plugin that requires the parent plugin and …
Category: Web

How should I write the conclusion when doing the same hypothesis on two different subjects and get different results?

I am doing a research trying to find if there's a correlation between twitter sentiments and sales and I'm doing it on two different companies. They are in the same industry and direct competitors. The time span is quarterly from Q1 2014 to Q4 2021 (28 data points each). I found the quarterly sales numbers easily because they are public companies. For twitter, I collected the tweets with Twitter Premium API v1.1 full archive search. I will not say the …
Topic: statistics
Category: Data Science

How to determine the "total number of relevant documents" in calculatiion of Recall in Precision and Recall if it's not known? Can it be estimated?

On Wikipedia there is a practical example of calculating Precision and Recall: When a search engine returns 30 pages, only 20 of which are relevant, while failing to return 40 additional relevant pages, its precision is 20/30 = 2/3, which tells us how valid the results are, while its recall is 20/60 = 1/3, which tells us how complete the results are. I absolutely don't understand how one can use the Precision and Recall in real/life scenario of total number …
Category: Data Science

Would like to use hook or filters to customize email templates

I hired a contractor to help me with my site a few years ago when I didn't have the coding experience that I do today. The contractor ended up making new templates for almost every email, and they are all out of date. I started making updates to them when I realized I should just be making the custom changes in the functions.php page so I don't have to go through updating a billion templates each time WooCommerce makes an …
Category: Web

How to prevent to create same url of post, if the previous was deleted?

Let's say I'm creating a post, it's URL will be: www.example.com/posts/test-article so far so good. Then, I delete it and also remove from trash bin. Again, I create with the same title, and the URL will be: www.example.com/posts/test-article that's no good, I would like to get: www.example.com/posts/test-article1 and so on. How to achieve that?
Category: Web

Woocommerce custom taxonomy filtering

Hey guys here's the situation: We have a woocommerce site hooked up with woocommerce product filters - the filter works perfectly on category pages, however, we have a custom taxonomy template for taxonomies we have added to the site. For example if you were to have a WC site selling apples, you have multiple different categories of apples but you also have a custom taxonomy of apple colour. For the apple color archive page, the filters that work on category …
Category: Web

Convolutional Neural network learning curve results

Working on a convolutional neural network with 6 classes and about 1500 image per class. The model that works best for me has given the results below, in previous models I have worked on has given much smoother results and the validation isn't as jittery, now it does start to smoothen towards the end with 0.99 for both validation and training. At some epochs the training gives and accuracy of 1.0 but again towards the end it remained at 0.99 …
Category: Data Science

Handling Imbalanced Datasets in Orange

I work in the medical domain, so class imbalance is the rule and not the exception. While I know Python has packages for class imbalance, I don't see an option in Orange for e.g. a SMOTE widget. I have read other threads in Stack Exchange regarding this, but I have not found an answer to how to tackle class imbalance in Orange without resorting to Python programming. Thanks
Category: Data Science

Stride in time series classification/regression using neural networks

When dealing with time series in neural networks, we use windows with a size and a stride as input. Is it advantageous to train such a neural network with a stride that is smaller than the stride used during inference, e.g. using stride 1 for training, but stride 25 during inference? Since the network is then trained with more windows, it should theoretically be more robust than if I train it with stride 25 and thus fewer windows. Is that …
Category: Data Science

Is it possible to save more than one image to an option?

The following code allows you to upload multiple images but only one is saved to the option. Can multiple images be saved to the option as an array or would I have to create separate controls? $wp_customize->add_section("slider",array( 'title'=>"Slider", 'description'=>"Choose the images for the slider", 'priority'=>'36' )); //images $wp_customize->add_setting("slider[images]",array( 'default'=>"", 'type'=>"option" )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize,"slider[images]",array( 'label'=>__("Images","adaptive-framework"), 'section'=>"slider", 'settings'=>"slider[images]" )));
Category: Web

stratified segment-grouped k-fold cross-validation

I have a music numerical data (2282 rows × 173 columns) to predict the target sad, happy, angry, relaxed. Now one of the attribute is segment_id and I want to group the data according to segment_id and apply stratified CV. How can I do it? I have 26 segments and each segment appear at least 50 times or more in the data set. I have no idea where to start? Could someone give me some hints? If you need further …
Category: Data Science

Growth Edge in Link Prediction

I have 2 CSV files representing edge in social networks in 2 consecutive generations. I am trying to predict future edges. My initial tough is to train a linear regression on the first generation with some indicators like Adar Index or Cosine Similarity between the node of the edge I am trying to predict. I can not run all the combinations possible between 2 nodes, so I was wondering how many edges I need to add between 2 generations? Is …
Category: Data Science

Trying to get_adjacent_post - in same category not working

this is my first time here. I need my previous and next posts to show only posts on the same category. But I don't know how to do it. This is the code in my template (called Valenti) it is in a file called core.php /********************* CLEAN NEXT/PREVIOUS LINKS *********************/ if ( ! function_exists( 'cb_previous_next_links' ) ) { function cb_previous_next_links() { $cb_previous = get_adjacent_post( false, '', true ); $cb_next = get_adjacent_post( false, '', false ); if ( ( $cb_next != …
Category: Web

How to create index (sql) to a meta_key?

I am new in programming, and the sql is absolutely stranger for me. I create today a new meta_key on my multisite, but when I use this in a query, my site will be horrible slow... I read (here: https://css-tricks.com/finding-and-fixing-slow-wordpress-database-queries/), that need for me creating a sql index for the meta_key, and this will doing incredibly faster my site... So here this sql command: CREATE INDEX wp_postmeta_csstricks ON wp_postmeta (meta_key) If my meta_key is _my_first_meta, I can use this code?: …
Category: Web

What methods to create singular content classification from inconsistent inbound info?

I am attempting to aggregate professional profile info from multiple sources, imposing a consistent taxonomy. Specifically, the current problem is how to impose a preferred taxonomy on profiles with inconsistent or absent in-bound taxonomy terms. Primary source of profile info is biography pages on people's employer websites. Some of those sites choose to state employees' multiple specialist topics, some make only narrative biographies available, some both. I have collected all available info, using Python's Scrapy, in to CSV files - …
Category: Data Science

404/500 error on content images if Referer header is from another domain

Not very familiar with WordPress so I'm not sure what's causing this. Essentially, we have a few image assets stored under wp-content. When we access some assets (i.e. cmssubdomain.apex.com/wp-content/image.png) we are getting some peculiar behavior around the Referer request header: It works if accessed without the Referer header It works if accessed with the Referer header as long as the value matches the cms subdomain It fails once the Referer header is set to a value different than the subdomain …
Category: Web

About

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