Pesquisar

Artigo
· Abr. 26, 2024 3min de leitura

Geo Vector Search #2

Technical surprises using VECTORs
>>> UPDATED

Building my tech. example provided me with a bunch of findings htt I want to share.
The first vectors I touched appeared with text analysis and more than 200  dimensions.
I have to confess that I feel well with Einstein's 4 dimensional world.
7 to 15 dimensions populating the String Theory are somewhat across the border.
But 200 and more is definitely far beyond my mathematical horizon.

So I looked to our Globe and found a vector of (latitude,longitude) with 2 dimension is enough for testing.
A handy table of capitals was found and provided sample test data (shortened).

CAPITAL COUNTRY LATITUDE LONGITUDE
Kabul Afghanistan 34.28N 69.11E
Tirana Albania 41.18N 19.49E
Algiers Algeria 36.42N 03.08E
Pago Pago American Samoa 14.16S 170.43W
Andorra la Vella Andorra 42.31N 01.32E
Luanda Angola 08.50S 13.15E
Saint John's Antigua and Barbuda 17.127N 61.846W
Buenos Aires Argentina 36.30S 60.00W
Yerevan Armenia 40.10N 44.31E
Oranjestad Aruba 12.32N 70.02W
Canberra Australia 35.15S 149.08E
Vienna Austria 48.12N 16.22E
Baku Azerbaijan 40.29N 49.56E
Nassau Bahamas 25.05N 77.20W
Manama Bahrain 26.10N 50.30E
Dhaka Bangladesh 23.43N 90.26E
Bridgetown Barbados 13.05N 59.30W
Minsk Belarus 53.52N 27.30E
Brussels Belgium 50.51N 04.21E

#1
 Loading that TAB separated text file with LOAD DATA (SQL) worked perfect

#2
Transforming the geo coordinates int INT was a minor coding exercises
It resulted in a ClassMethod projected as SQL Procedure used inana UPDATE over the table.

#3
As geo coordinates refer to (0°N,0°W) somewhere in the Atlantic this is just a theoretical base for my vectors.
IRIS supports some VECTOR functions but I found no AddVector() or SubtractVector() function.
so this was done "manually" from the input coordinates.
The need arises from transforming coordinates to a useful base point for later comparing vectors
So you see static BASE coordinates and active WORK coordinates.

Getting the Vector's values is easy with SQL using %EXTERNAL() function
while in ObjectScript I ended up with
        set vectorvalues=##class(%Vector).LogicalToOdbc(vectorvariable) 
this was less impressive for working with Vectors.

#4
Similarity is calculated with VECTOR_COSINE() function.
You calculate the angle between 2 Vectors and COSINE norm it between +1 and -1
The input needs 2 Vectors of the same type and same dimension.
Examples as in documentation work fine if you compose your SQL String as suggested
and TO_VETOR(?,type,size) is OK  with  %SQLStatement  for execution.
BUT:
I tried it with embedded SQL.
Code checking signalled some disagreement but compiled without problem
At runtime it turned out that host variables in TO_VECTOR(:myvec,INT,2) failed
whatever combination of quotes, braces, .... I tried.
So be warned. I returned to  %SQLStatement to get my VCOS done.

UPDATE:  TO_VECTOR(:myvec,INT,2)
     set myvec="1314,-7979" 

Nothing special: Just a plain String with comma-separated values
It seems I couldn't believe that simple approach.
My apologizes to ISC Engineering.

#5
It was a surprise to learn how wide VECTOR_COSINE is spreading.
checking the vector Paris >> Bucuresti  traced half of Middle and East Asia.
So limiting the results to > 0.999 is a good practice in this scenario.

Video

GitHub
 

4 Comments
Discussão (4)1
Entre ou crie uma conta para continuar
Artigo
· Abr. 26, 2024 2min de leitura

Geo Vector Search #1

Geographic use of vector search

The basic idea is to use Vectors in the mathematical sense.
I used geographic coordinates. These are of course only 2-dimensional
but much easier to follow as vectors in text analysis with >200 dimensions.

The example loads a list of worldwide capitals with their coordinates
The coordinates are interpreted as vectors from geographic point 0°N/0 W
(some very wet spot in the Gulf of Guinea, >400 km from the African Coast)
Finding common directions from that spot is a quite theoretical case.
So adjustment to your preferred starting point is implemented.
Now finding similar directions for some target city makes sense.
It's a methematical use of VECTOR_COSINE() function other than text search.

And as this is just 2 dimensional COSINE is just what we (hopefully) learned at school.
So the results are far better to understand: 

  • 1  =  total match, same direction 0° deviation from original
  • 0  = no match at all,  direction points 90° away from original
  • -1 = total opposite direction pointing backward by 180° from original
  •  ~0.999  = quite close to original 

You just get information on the direction, not on the size.
So your vector from Paris to Budapest  points also to Minsk or someplace In Asia

The demo is controlled by a rathrer simple menu:

  Use Geographc Vectors
=========================
     1 - Initialize Tables
     2 - Import Data
     3 - Set Base Location
     4 - Generate Vectors
     5 - Select Target Location
     6 - Show Best Matches
Select Function or * to exit :

for multiple retries, you always restart at

  • #3 set your starting location
  • #4 adjust coordinates to your selected base
  • #5 set your target location  defining your base vector
  • #6 see what's in between or in front of your vector
    • adjust tolerance from -1...+1

GitHub

Video

DemoServer Mgmt Portal
DemoServer WebTerminal
 

3 Comments
Discussão (3)1
Entre ou crie uma conta para continuar
Anúncio
· Abr. 22, 2024

The Global Masters Program will be temporarily PAUSED from April 26th

Access for Global Masters:

Please access Global Masters via
 this link.

Log in using InterSystems SSO ("Login with InterSystems" button on the left). 


At InterSystems, we strive to give you the best quality in everything. Including the realization of our Global Masters program. 

The vendor of this platform has been acquired by another company, and unfortunately, we will no longer be able to continue hosting our esteemed Global Masters program on this platform. We are currently evaluating new platform providers to facilitate the transition of the Global Masters Advocate Hub.

Beginning April 26th, we will temporarily suspend access to the Global Masters program as we transition to a new platform.

FAQ:

YOUR POINTS, BADGES AND LEVEL

All points, badges and achievements will be saved as of April 26th. We will transfer all data to a new platform.

YOUR CONTRIBUTIONS TO DEVELOPER ECOSYSTEM 

During the migration, we will still be counting all contributions to Developer Ecosystems (posts, comments, applications, etc) automatically. These well-deserved points and badges will be added to your profile upon the launch of a new program.

PRIZES

To provide an opportunity to redeem prizes during the migration, we plan to build a special webpage with prizes as soon as possible. However, we encourage you to redeem prizes you had planned to redeem before April 26th (on April 26th prizes will be already unpublished), as this functionality will not be available for some time.

WHAT'S NEXT

All information regarding the upgrade will be published in the Discord and Developer Community channels. We apologize for any inconvenience and will endeavor to complete the migration as soon as possible. 

WHERE TO ASK QUESTION? GLOBAL MASTERS SUPPORT 

Reach out to Olga @Olga Zavrazhnova in DM here or ask questions in a dedicated Global Masters channel on Discord. Let's stay in touch!

WE WILL UPDATE YOU ON THE ESTIMATE DATE OF LAUNCH SOON

We are looking forward to meeting you soon on a new platform!
Sincerely yours, 
Global Masters and Developer Community team

4 Comments
Discussão (4)4
Entre ou crie uma conta para continuar
Pergunta
· Abr. 18, 2024

initial user account

I installed a local docker container instance from here:   intersystemsdc/iris-community

I'm trying to login:    http://localhost:52773/csp/sys/UtilHome.csp

I thought if I used SYSTEM as the initial username, I could login, but I get #822 Access Denied.

Is that the correct username? maybe there's a better location to pull the docker instance.

***************nevermind, figured it out

3 Comments
Discussão (3)3
Entre ou crie uma conta para continuar
Pergunta
· Abr. 11, 2024

Question about InterSystems API (IAM) install from tar file with IRIS running locally

I downloaded IAM-3.4.2.0-5604.tar.gz from the Online Distribution site this morning, it the implementation to install it on our Development environment to see if it is a viable solution. Following the instructions, I have ran into an issue trying to make sure I am entering the information into the prompts correctly.

I have IRIS HealthShare Health Connect 2024.1 running locally using a Local Web Server, so when prompted I have entered the IP Address and port 443 is that correct? 

:>iam-setup.sh
Welcome to the InterSystems IRIS and InterSystems API Manager (IAM) setup script.
This script sets the ISC_IRIS_URL environment variable that is used by the IAM container to get the IAM license key from InterSystems IRIS.
Enter the full image repository, name and tag for your IAM docker image:
intersystems/iam:3.4.1.0
Enter the IP address for your InterSystems IRIS instance. The IP address has to be accessible from within the IAM container, therefore, do not use "localhost" or "127.0.0.1" if IRIS is running on your local machine. Instead use the IP address of your local machine. If IRIS is running in a container, use the IP address of the host environment, not the IP address of the IRIS container:
xxx.xxx.xxx.xxx
Enter the web server port for your InterSystems IRIS instance:
443
Enter the password for the IAM user for your InterSystems IRIS instance:
Re-enter your password:
If local policy requires that HTTPS be used for communication, please provide the full path to your CA Certificate file now. Otherwise hit "Return":
/etc/pki/ca-trust/source/anchors/OSUWMC_CA.pem
If your InterSystems IRIS instance is only accessible via its CSPConfigName URL prefix, please provide the prefix with a trailing slash (/) now. Otherwise hit "Return":

Your inputs are:
Full image repository, name and tag for your IAM docker image: intersystems/iam:3.4.1.0
IP address for your InterSystems IRIS instance: xxx.xxx.xxx.xxx
Web server port for your InterSystems IRIS instance: 443
CA Certificate for HTTPS: /etc/pki/ca-trust/source/anchors/OSUWMC_CA.pem
CSPConfigName URL prefix:
Would you like to continue with these inputs (y/n)?
y
Getting IAM license using your inputs...

Couldn't reach InterSystems IRIS at xxx.xxx.xxx.xxx:443. One or both of your IP and Port are incorrect.

I have verified that...

  • IAM user is enabled
  • /api/iam is enabled

What port should be specified if you are running a Local Web Server/Web Gateway?

Thanks

Scott

9 Comments
Discussão (9)2
Entre ou crie uma conta para continuar