StackOverflow.com

VN:F [1.9.22_1171]
Rating: 8.9/10 (12 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

Impact of nulls in xgboost

18 November 2025 @ 6:34 pm

I have a data set in which state is a one-hot encoded variable. Some states are allowed to use all predictors, some states are not allowed to use certain predictors. If I null out those variables as appropriate for a state, what can I say about the impact of those nulled variables on the output for a state that is not allowed to use them? My opinion is that the model will learn about nulls (which do occur) in other states where the variable is typically not null, but the actual impact of the variable will be miniscule. SHAP doesn't necessarily agree with my opinion, indicating that there is a non-trivial impact of wholly nulled variables on the output of a state. Mathematically, is it reasonable to say there will be NO impact of passing nulls in states where the variable is restricted?

GAM OAuth 2.0 + Keycloak

18 November 2025 @ 6:28 pm

I have successfully implemented OAuth 2.0 authentication between GAM and Keycloak. Login works perfectly. What already works: ✅ Full OAuth 2.0 authentication ✅ Login and redirection working ✅ User data (email, name) being retrieved What I need: Automatically assign a role to the user in GAM after logging in via Keycloak Question: How should I configure GAM (OAuth 2.0 Authentication Type) so that, when logging in through Keycloak, the user automatically receives a specific role?

how to include regression table in PDF?

18 November 2025 @ 6:27 pm

This is related to another post where I had problems including a ggplot together with a regression table; fixed the ggplot part, so splitting out the regression table issue. I can generate the pdf with a modelsummary generated table without problems with knitr. Using the same Rmd, and looking at the generated tex file, I see that exams does not seem to run the modelsummary call for some reason. What's going on? First the Rmd. ```{r, results = "hide"} library(modelsummary) # library(exams) # uncomment for simple knit to pdf questions <- list() questions[[1]] <- "is 1 true?" questions[[2]] <- "is 2 true?" solution = list() solution[[1]] = TRUE solution[[2]] = FALSE ``` Question ======== Here is some output ```{r} m = lm(speed ~ dist, cars) m ``` ```{

How to automatically run a section of code with different parameter combinations

18 November 2025 @ 6:27 pm

I'm attempting to write some code in order to do some analyses on ecological data. What I'm currently doing is calculating the diversity index for certain stretches of a stream. I have a data frame of information for 5 stream sections (Site), over three periods of time (Survey), and the diversity is calculated from the number (Count) of each species (Species) we caught at whatever site during whatever survey. This is the code I'm currently running. library(tidyverse) library(vegan) # SHANNON DIVERSITY ---- # Species count by survey and site count_sum_norun <- df %>% group_by(Survey, Site, Species) %>% summarise(Count = sum(Count))%>% ungroup ## SPECIFY survey and site ---- sp_count <- count_sum_norun %>% filter(Survey == 1, Site == "B") ## Calculate Diversity ---- shannon_diversity_vegan <- diversity(sp_count$Count, index="shannon") this is an example of my starting dataframe:

Upgrading project to .NET 10 breaks Scalar support when using document transformers

18 November 2025 @ 6:23 pm

I'm currently in the process of upgrading to .NET 10 from .NET 9, but unfortunately as usual the documentation of breaking changes seems to be lacking when it comes to certain functionality and features. I am using Scalar and as such I am applying a number of transforms to my documents, mainly to perform path modification for when we deploy our application to Kubernetes under a subdomain and also to add bearer authentication support. In my Program.cs, I have the following defined where akspath is just a string variable that comes from config: builder.Services.AddOpenApi("my-api", options => { options.AddDocumentTransformer<BearerSecuritySchemeTransformer>(); if (!string.IsNullOrWhiteSpace(aksPath) && !builder.Environment.IsDevelopment()) { options.AddDocumentTransformer<UrlPrefixTransformer>(); } });

Form with nested arrays and groupform

18 November 2025 @ 6:18 pm

Any idea what I am doing wrong? I need to set it up where I have Events that contain a FormGroup and it has Dates as another Array of FormGroup. What am I doing wrong? <div class="control-row"> <div class="control-column"> <div formArrayName="events"> @for (eve of eventsForArr.controls; let i = $index; track $index) { <div [formGroupName]="i"> <input hidden formControlName="eventId" > <input hidden formControlName="title" > <input formControlName="detail" /> </div> @for (date of datesForArr.controls; let j = $index; track $index) { <div formArrayName="dates"> <div [formGroupName]="j"> <input hidden formControlName="dateId" > <input formControlName="eventDate" > <input formControlN

How do I Download Poppler and Tesseract Programatically with PowerShell

18 November 2025 @ 6:13 pm

Right now, I have two folders, poppler and tesseract, which contain all the necessary information. I set them as such: pytesseract.tesseract_cmd = path_to_tesseract #and convert_from_path(file_path, poppler_path = POPPLER_PATH) However, this doesn't work in production, because they take up so much space in my folder. What I need, is to somehow download them both somewhere relative to the pip installs, so I don't need to set a path for either. Right now, I have a PowerShell script which pip installs everything I need. I should be able to download Tesseract and Poppler at the same time as the rest of my pip installs. $libraries = @( "pdf2image", # turnIntoImage() "pytesseract" ) foreach ($lib in $libraries) { Write-Host "Installing $lib..." pip install $lib } # Add code here which downloads Poppler and Tesseract

Kotlin script - can't run if full path contains space

18 November 2025 @ 6:05 pm

Kotlin compiler is located in C:\kotlinc\bin, when trying to run any script that is located in a path with space - it fails with message "InvalidPathException: Illegal char <:> at index 2: /H:/My%20Drive/...". Doesn't matter if I use relative path, just file name, full path, with or without parenthesis - the only fix is to move kotlin AND the script to location without space char in it. Tested in windows powershell and git bash. How is it possible that such basic bug exists or how to solve it?

Publish VS project fails on system.net.http 4.2.0.0 not found in SQL Server even though other projects use it

18 November 2025 @ 5:42 pm

I have several visual studio projects that have been published to SQL Server 2014 (yes old I know - legacy software) that use System.Net.Http v4.2.0.0 so I know that the assembly has been created at some point in time. I have now created another project but when I try to deploy I get the dreaded error System.Net.Http, version=4.2.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog. I'm not sure why this is happening - don't know enough about .NET assemblies to understand where to look in VS or what the proper solution is. I have read all the posts I can find but nothing is clearly referencing this issue, or at least not one that is making sense to me. It looks like I need to create the assembly again - which seems odd to me. Does anyone know how to fix this?

The animation of the avatar, text and icons is uneven

18 November 2025 @ 5:33 pm

When scrolling the page, the opacity of the Icon or Text widgets is animated when the SliverAppBar disappears or appears. This happens automatically. If you set the "bottom" widget in the SliverAppBar, the Icon and Text widgets move somewhat unevenly and slow down relative to the widget in the "bottom" property—essentially, the top of the SliverAppBar changes in height. However, the CircleAvatar widget (including the red border) animates differently than the Icon or Text widgets. Its opacity does not change at all. When using the "bottom" widget, the movement animation occurs differently: if the avatar is in the "title" property, the avatar's size remains unchanged, but if the avatar is in the "actions" property, it scales, unlike the Icon. What should I do to make the CircleAvatar widget (including the red border) animate like the Icon and Text widgets—with opacity changes and no scaling (in the actions property in