on-internet

How can I cluster a large dataset based on similarity?

I would like to cluster a huge dataset into clusters based on similarity. How can I approach this problem? I have tried MinBatchK means and DBSCAN, but I am not getting great results. The problem I am facing with MinBatchKMeans is I have to specify the number of clusters beforehand and with DBSCAN most are classified as noise. Can someone please guide me on how to approach this problem? I am using TFIDF to convert text into vectors. For example, when I am using a dataset of 80,000 records, it takes around 2-3 hours to form a cluster of size 500. This makes it very difficult to find optimal num

Join the discussion →

unsupported data type: &[] error on GORM field where custom Valuer returns nil?

I was trying to create a GORM model for a postgres database, containing a type with a custom Scanner and Valuer that converts a string slice to and from a string, to be saved as a single database column. If the slice is either empty or nil, I want the database column to also be nil (as opposed to an empty string). type MultiString []string func (s *MultiString) Scan(src interface{}) error { str, ok := src.(string) if !ok { return errors.New("failed to scan multistring field - source is not a string") } *s = strings.Split(str, ",") return nil } func (s MultiString) Value() (driver.Value, error)

Join the discussion →

Mapping issues from Sqlalchemy to Pydantic - from_orm failed

I'm trying to get my result dictonary from sqlalchemy automatically to the Pydantic output for Fastapi to maps using the from_orm method, but I always get a validation error. File "pydantic\main.py", line 508, in pydantic.main.BaseModel.from_orm pydantic.error_wrappers.ValidationError: 2 validation errors for Category name field required (type=value_error.missing) id field required (type=value_error.missing) If I create the objects with the Pydantic schema myself and add them to the list, the method works. What would I have to change for from_orm to work? Did I possibly miss something in the d

Join the discussion →

How to implement pagination for PagerDuty API results in my Power Query code

My company uses Power BI and we are trying to get incidents data from PagerDuty API. I have been struggling to find a way to get all the data but I am not knowledgeable about PowerBI, PowerQuery, or dealing with APIs. I am in a database role. I used Get Data option in Power BI and selected Web as data source. Entered My API link, and passed the headers. The result I get is limited to 25 by default, I can change it to up to 100 but my main issue is with not being able to get next set of results. I need to have some kind of loop to increase the offset parameter and refresh the query. My current

Join the discussion →

How to make a MongoDB Upsert truly idempotent?

I want to insert a document into a MongoDB in an idempotent way. The explanation provided by the MongoDB documentation, and also here on SO, is to use the upsert=True modifier. However, to my understanding, this does not guarantee idempotence, because an already existing document could be modified. The operation I am looking for is as follows: If the document, identified by some key, does not exist, insert it. If a document with the given key already exists, there are two things that might happen: The existing document and the provided document are exactly the same. Then, return the same resul

Join the discussion →

Xcode 12 GM runs into infinite loop

I am developing an iOS app and it works well on Xcode 11.7, but when I run the same code in Xcode 12 and when I enter a UIPageViewController, the app runs into an infinite loop and the cpu usage shows 99%. Here is a screenshot I made after pause the app in debugger. It shows Application violated contract by causing UIApplicationMain() to return. This incident will be reported.

Join the discussion →

Use svg image as map layer for mapbox GL JS

How do I use SVG image as the base map for mapbox GL JS ? I know, that OpenLayers and Leaflet provide such opportunity for developers. Leaflet: var svgUrl = 'image.svg', imageBounds = [[0, 0], [100, 100]]; L.imageOverlay(svgUrl , imageBounds).addTo(map); OpenLayers: var svgUrl = 'image.svg', var imgLayer = new ImageLayer({ source: new Static({ url: svgUrl, projection: projection, imageExtent: extent, imageLoadFunction: function (image, src) { image.getImage().src = src; image.getImage().width = olExtent.getWidth(extent); image.getImage().height = olExtent.getHeight(extent); }, }), }); map.addL

Join the discussion →

XBRL / Finstr issue with SEC EDGAR data in R

I am trying to download the XBRL data from the SEC site, using the finstr package in R. The vignette references Apple financial statements from 2013-14. I am going after Abbott (CIK 1800) for mine. I've looked through the data records on the SEC site and the submission is in this folder: https://www.sec.gov/Archives/edgar/data/1800/000110465920023904 The Apple xml file is named aapl-20140927.xml (the CIK followed by the submission date). I've gone into the file through a browser and identified the relevant data. The Abbott xml file that has the same info is named abt-20191231x10k59d41b_htm.xml

Join the discussion →

Lazy-load imports from barrel file in Jest

I'm using React and have a file tree like this: src/ common/ common-comp1/ common-comp1.js common-comp1.test.js index.js common-comp2/ common-comp2.js common-comp2.test.js index.js index.js app/ app-comp1/ app-comp1.js app-comp1.test.js index.js app-comp2/ app-comp2.js app-comp2.test.js index.js index.js All of the index.js files are barrel files that export * from '...';. I have path aliases set up so that I can import CommonComp1 from 'common'; in src/app/app-comp1/app-comp1.js. Unfortunately, this loads/transforms the code from src/common/common-comp2/* as well, even though app-comp1.js doe

Join the discussion →

Can I perform a post hoc on principal component analysis (PCA)?

I performed a PCA on my data, and I have four principal components. However, it is very difficult to interpret my results with principal components. Therefore, I was wondering can I do a post hoc, by taking the variable with the highest variance in PC1 (say X1) and the variable with the highest variances in PC2 (say X2) and perform a regression analysis, with an outcome variable y, to test their association? (i.e., lm(Y~X1+X2)) Here's an example: I have four independent variables: memory test, cognition test, attention test, and processing speed test. I have one dependent variable, brain conne

Join the discussion →

Does the nuget package Microsoft.Data.SqlClient work with Entity Framework?

My application runs on .NET framework 4.7 and I'm using Entity Framework 6.1.3. Currently, my code uses some classes from the namespace System.Data.SqlClient such as SqlParameter. I want to switch to Microsoft.Data.SqlClient. However, I'm not sure if EF6 is compatible with Microsoft.Data.SqlClient. This is an old article from Microsoft, it says that EF Core, EF 6 etc. haven’t yet made the transition to the new provider Microsoft.Data.SqlClient. So, I'm a bit confused. Everything has been working well with System.Data.SqlClient for the below code public async Task<ICollection<int>> GetChildCust

Join the discussion →

Error “Target class controller does not exist” when using Laravel 8

Here is my controller: <?php namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; class RegisterController extends Controller { public function register(Request $request) { dd('aa'); } } As seen in the screenshot, the class exists and is in the correct place: My api.php route: Route::get('register', 'Api\RegisterController@register'); When I hit my register route using Postman, it gave me the following error: Target class [Api\RegisterController] does not exist. How can I fix it? Thanks to the answers, I was able to fix it. I decided to use the

Join the discussion →

Grant access for all all tables in Postgres

How to grant all table privileges to all schemas in a Postgres database to a user/role? The below command grants only to specific schema not whole database. GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name TO username; For example, Database: test Schema : schema1, schema2 inside test table : schema1.table1,schema1.table2,schema2.table1,schema2.table2 How to provide all table privileges to all tables found in all schemas found inside Database.

Join the discussion →

How do I find the 100 most different points within a pool of 10,000 points?

I have a set of 10,000 points, each made up of 70 boolean dimensions. From this set of 10,000, I would like to select 100 points which are representative of the whole set of 10,000. In other words, I would like to pick the 100 points which are most different from one another. Is there some established way of doing this? The first thing that comes to my mind is a greedy algorithm, which begins by selecting one point at random, then the next point is selected as the most distant one from the first point, and then the second point is selected as having the longest average distance from the first

Join the discussion →

How to get data from an XML which has two root nodes in XSLT

This is the XML i have: <?xml version="1.0" encoding="UTF-8"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>9.90</price> <year>1988</year> </cd> </catalog> <catalog> <cd> <title>Stop</title> <artist>Sam Brown</artist> <country>UK</country> <company>A and M</company> <price>8.90</price> <year>1988</year> </cd> <cd> <title>Bridge of Spies</title> <a

Join the discussion →

JK-flip flop using gate level description gives me a timing error

I'm still playing in the lowest Verilog level (gate level). I found this post: https://electronics.stackexchange.com/questions/390661/is-it-possible-to-create-a-working-jk-flip-flop-using-gate-level-description-in In that, I could understand that should work the idea, and I could solve to have a Master-Slave JK Flip-Flop for use it as a frequency divider. I use Icestorm toolchain. Yosys is not complaining, but Next-PNR is giving me this error: ERROR: timing analysis failed due to presence of combinatorial loops, incomplete specification of timing ports, etc. This is my code: module syncRX(clk,

Join the discussion →

Algorithm for calculating the most cost-effective chemical mix

The problem I have four different chemicals and I know the fraction of the following compounds in each of them as follows: |------------------|---------|---------|---------|---------|---------| | Name | ZrO2 | Al2O3 | SiO2 | Na2O | Price | |------------------|---------|---------|---------|---------|---------| | AZS | 30% | 50% | 13% | 1.8% | 328.95 | |------------------|---------|---------|---------|---------|---------| | Fine salt | 25% | 30% | 43% | 0.2% | 203.95 | |------------------|---------|---------|---------|---------|---------| | ZDCF | 63% | 1% | 33% | 0.4% | 789.47 | |--------------

Join the discussion →

Azure build pipeline path filter to only include particular file extension

I'm working on creating build pipeline in Azure DevOps. I want to trigger it against master branch but only when commit has changes under src/Project/tds/Serialization.Master/ Project - this project contains only .item files If the commit includes any other files together with .item then this pipeline shouldn't trigger, tried path exclude BDD Scenario 1 Given | I've changes for src/Project/tds/Serialization.Master/* Then | build pipeline should trigger Scenario 2 Given | I've changes for src/Project/tds/Serialization.Master/* And | I've changes for src/Foundation/* Then | build pipeline should

Join the discussion →

How to md5 the video track (only) in ffmpeg

I have a .mov file with a video and several audio tracks. To md5 the entire file I can do: [pdev@d ~]$ md5sum 1_TRAILER_HD_2CH_ES419_ENSUB_16X9_178_2398_DIGITAL_FINAL.mov 042f0e177fe25f562079cc07208ec446 Though when I try doing the same thing in ffmpeg, I get a different value: $ ffmpeg -i 1_TRAILER_HD_2CH_ES419_ENSUB_16X9_178_2398_DIGITAL_FINAL.mov -f md5 - MD5=74bd904f1edb4eb1368040e2792d7497 0kB time=00:01:59.11 bitrate= 0.0kbits/s speed=2.36x frame= 2867 fps= 56 q=-0.0 Lsize= 0kB time=00:01:59.57 bitrate= 0.0kbits/s speed=2.35x video:23222700kB audio:22421kB subtitle:0kB other streams:0kB

Join the discussion →

Valgrind is reporting "Use of uninitialised value of size 4" when using strlen

I'm trying to use Valgrind on Raspberry Pi. I am analyzing the following program: #include <string> #include <cstring> int main() { std::string blaat = "blaat"; const char * buf = blaat.c_str(); size_t l = 0; l = strlen(buf); printf("string size %u\n", l); } Compile: g++ -g -Wall -O0 test.cpp Analyze (valgrind-3.16.1): valgrind --leak-check=yes ./a.out Result: ==29572== ==29572== Conditional jump or move depends on uninitialised value(s) ==29572== at 0x4866210: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so) ==29572== ==29572== Conditional jump or move depends on uninitialised value(s)

Join the discussion →

How to check if left click is clicked in text field in tkinter?

What I am trying to do is that I have highlighted text and this highlight can't be removed with left click (for example: there is self.text.tag_remove("match","1.0",END), which removes the highlight, but it will remove it immediately without even showing the highlight in the first place), so I want to remove highlight under the condition of left clicking in text widget. Here is part of my code which I think might be helpful: def Find(self): count=IntVar() s=self.text.search(self.entry.get(),'1.0',stopindex=END,count=count) self.text.tag_configure("match",background='yellow') end=f'{s}+{count.g

Join the discussion →

Why I can not copy a content of register to another one in "always" block?

I have this code that is working perfectly: module syncRX(clk, signal, detect); input clk, signal; output reg [7:0] detect = 0; reg [7:0] delay = 0; //wire clk_1khz; freq_div div(.clk(clk), .clk_1khz(clk_1khz)); always @(posedge signal) begin detect <= detect + 1; delay <= 0; end always @(posedge clk_1khz) begin delay <= delay + 1; end endmodule // top module freq_div(input clk, output reg clk_1khz); reg [12:0] count = 0; always @(posedge clk) begin if(count == 6000) begin clk_1khz <= ~clk_1khz; count <= 0; end else count <= count + 1; end endmodule The problem appears when I change the line d

Join the discussion →

how can I disable multiple instances of a python script?

I made a python program and I want to disable the option to launch it multiple times in parallel. I searched the web and found that I need to do it with socket and ports, but I didn't find any example of how to do it(I know the steps, but I need to search every step on google and I am not so sure how to start). I also found that there might be libraries that can do that but to specific operating systems. My script only targets Windows 10, so I need to find a library that does that to Windows if there is one. Do you know such libraries or can you give a more detailed example of how to make this

Join the discussion →

Encoding multiple columns in pandas

I have some doubts regarding encoding (I am not familiar with tasks like these) categorical variables in order to use them as parameters in a model like logistic regression or SVM. My dataset looks like the following: Text Symbol Note Account Age Label There is a red car ! red John 24 1 My bag was very expensive ? orange Luke 36 0 Where are my keys? @ red Red 58 1 I promise: I will never let you go! ... green Aoife 28 0 In 'Text', there are stored comments from users in a community. 'Symbol' includes the most used symbol by a user. 'Note' represents its level (green is more experienced; red is

Join the discussion →

Convert a "table1"-table to pdf-friendly format

I have a table with descriptive statistics I generated using the table1 package (I used it since it can produce descriptive statistics for both categorical and continuous variables). The issue I'm having is that table1 only produce tables in HTML-format. I'd like to transform my table1-table to a kable-table (or equivalent) so I knit my markdown to a pdf-file. I tried the following code library(table1) library(kable) tb <- table1(reformulate(colnames(df)), data=df, output = "latex") kable(tb, caption = "Descriptive statistics") But this produces an empty table looking like this: Does anyone kn

Join the discussion →
Older stories