Month: August 2024
Tag search not showing all photos
Hi!
When i search for a picture with a tag the result is only showing a few pictures.
I have around 1000 photos with this tag. I tried with and without hash sing. Both is not working.
Br
Hi! When i search for a picture with a tag the result is only showing a few pictures. I have around 1000 photos with this tag. I tried with and without hash sing. Both is not working. Br Read More
How to choose a single element randomly from a vector
A=[2 3 4 5];
How do I choose any one variable from the vector A randomly each time.A=[2 3 4 5];
How do I choose any one variable from the vector A randomly each time. A=[2 3 4 5];
How do I choose any one variable from the vector A randomly each time. rand, randi MATLAB Answers — New Questions
جلب الحبيب ألمانيا🟡34310995 :973 +🟡سحر الجلب و سحر الزواج 🟡 السعودية 🟡 البحرين
جلب الحبيب ألمانيا🟡34310995 :973 +🟡سحر الجلب و سحر الزواج 🟡 السعودية 🟡 البحرين
جلب الحبيب ألمانيا🟡34310995 :973 +🟡سحر الجلب و سحر الزواج 🟡 السعودية 🟡 البحرين Read More
جلب الحبيب بإسمه ( 🟡34310995 :973 +🟡 ) علاج سحر التفريق
جلب الحبيب بإسمه ( 🟡34310995 :973 +🟡 ) علاج سحر التفريق
جلب الحبيب بإسمه ( 🟡34310995 :973 +🟡 ) علاج سحر التفريق Read More
A drift, not a change, from Windows.Forms Control.VisibleChanged Event to mnemonic responsive emotio
A MMC snap-in for “Zertifikate” is no conclusion. Press ok would be an obvious normal approach for A next step. The motion is silence. The courageous pink animals computer will never be heard. Of from. . . it is easier to stumble with the HelpProvider Issue past ok, done, minimize to tasktray. . .
than choose from the spam email headers list.
A MMC snap-in for “Zertifikate” is no conclusion. Press ok would be an obvious normal approach for A next step. The motion is silence. The courageous pink animals computer will never be heard. Of from. . . it is easier to stumble with the HelpProvider Issue past ok, done, minimize to tasktray. . .than choose from the spam email headers list. Read More
My mail rules do not run automatedly
I have a rule that to move some junk mail to junk box base on sender mail address.
The rule is on top of all rules.
The rule can is working when I run the rule manually by clicking “Run rule now”.
The rule switch is on and blue.
My inbox is flooded by these junk mail everyday, I have run the rule manually. Please
I have a rule that to move some junk mail to junk box base on sender mail address.The rule is on top of all rules.The rule can is working when I run the rule manually by clicking “Run rule now”. The rule switch is on and blue. My inbox is flooded by these junk mail everyday, I have run the rule manually. Please Read More
جلب الحبيب خاضع ذلائل – 0966983 0096654 – السعودية
جلب الحبيب خاضع ذلائل – 0966983 0096654 – السعودية
السعودية
قطر
البحرين
الإمارات
عُمان
الكويت
جلب الحبيب خاضع ذلائل – 0966983 0096654 – السعوديةالسعوديةقطرالبحرينالإماراتعُمانالكويت Read More
Boost RAG Performance: Enhance Vector Search with Metadata Filters in Azure AI Search
In a Retrieval-Augmented Generation (RAG) setup, user-specified filters, whether implied or explicit, can often be overlooked during vector searches, as the vector search primarily focuses on semantic similarity.
In some scenarios, it’s essential to ensure that specific queries are answered exclusively using a predefined (sub)set of the documents. By using “metadata” or tags, you can enforce the type of documents that should be used for each type of user query. This can even turn into a security overlay policy when each users queries are tagged with their credentials / auth level with filters so that their queries are answered with documents at their auth level.
When RAG data consists of numerous separate data objects (e.g., files), each data object can be tagged with a predefined set of metadata. These tags then can serve as filters during vector or hybrid search. Metadata can be incorporated into the search index alongside vector embeddings and subsequently used as filters.
In this blog, we will demonstrate an example implementation…
For the sake of demonstration, in this blogpost will use Wikipedia articles of movies as our documents. We will than tag these movie files with metadata such as genre, releaseYear, and director, and later use this metadata to filter on RAG generations.
Please note that an LLM can also be used to “classify” the documents before they are uploaded to the search index for deployment at a larger scale. When a user enters a prompt, we can use an additional LLM call to classify the user prompt (match a set of metadata) and later use it to filter out results. Blogpost demonstrates a simpler use-case where RAG documents (the wikipedia pages saves as pdf files and pre-tagged with the movie metadata…
1. Classify documents and tag with metadata
movies = [
{“id”: “1”, “title”: “The Shawshank Redemption”, “genre”: “Drama”, “releaseYear”: 1994, “director”: “Frank Darabont”},
{“id”: “2”, “title”: “The Godfather”, “genre”: “Crime”, “releaseYear”: 1972, “director”: “Francis Ford Coppola”},
{“id”: “3”, “title”: “The Dark Knight”, “genre”: “Action”, “releaseYear”: 2008, “director”: “Christopher Nolan”},
{“id”: “4”, “title”: “Schindler’s List”, “genre”: “Biography”, “releaseYear”: 1993, “director”: “Steven Spielberg”},
{“id”: “5”, “title”: “Pulp Fiction”, “genre”: “Crime”, “releaseYear”: 1994, “director”: “Quentin Tarantino”},
{“id”: “6”, “title”: “The Lord of the Rings: The Return of the King”, “genre”: “Fantasy”, “releaseYear”: 2003, “director”: “Peter Jackson”},
{“id”: “7”, “title”: “The Good, the Bad and the Ugly”, “genre”: “Western”, “releaseYear”: 1966, “director”: “Sergio Leone”},
{“id”: “8”, “title”: “Fight Club”, “genre”: “Drama”, “releaseYear”: 1999, “director”: “David Fincher”},
{“id”: “9”, “title”: “Forrest Gump”, “genre”: “Drama”, “releaseYear”: 1994, “director”: “Robert Zemeckis”},
{“id”: “10”, “title”: “Inception”, “genre”: “Sci-Fi”, “releaseYear”: 2010, “director”: “Christopher Nolan”}
]
2. Creating the Azure AI Search index…
We need to create an Azure AI search index which will have the metadata fields as “searchable” and “filterable” fields. Below is the schema definition we will use.
First define the schema in JSON….
{
“name”: “movies-index”,
“fields”: [
{ “name”: “id”, “type”: “Edm.String”, “key”: true, “filterable”: false, “sortable”: false },
{ “name”: “title”, “type”: “Edm.String”, “filterable”: true, “searchable”: true },
{ “name”: “genre”, “type”: “Edm.String”, “filterable”: true, “searchable”: true },
{ “name”: “releaseYear”, “type”: “Edm.Int32”, “filterable”: true, “sortable”: true },
{ “name”: “director”, “type”: “Edm.String”, “filterable”: true, “searchable”: true },
{ “name”: “content”, “type”: “Edm.String”, “filterable”: false, “searchable”: true },
{
“name”: “contentVector”,
“type”: “Collection(Edm.Single)”,
“searchable”: true,
“retrievable”: true,
“dimensions”: 1536,
“vectorSearchProfile”: “my-default-vector-profile”
}
],
“vectorSearch”: {
“algorithms”: [
{
“name”: “my-hnsw-config-1”,
“kind”: “hnsw”,
“hnswParameters”: {
“m”: 4,
“efConstruction”: 400,
“efSearch”: 500,
“metric”: “cosine”
}
}
],
“profiles”: [
{
“name”: “my-default-vector-profile”,
“algorithm”: “my-hnsw-config-1”
}
]
}
}
Then run the following script to create the index with a REST API call to Azure AI Search service…
RESOURCE_GROUP=”[your-resource-group]”
SEARCH_SERVICE_NAME=”[search-index-name]”
API_VERSION=”2023-11-01″
API_KEY=”[your-AI-Search-API-key”
SCHEMA_FILE=”movies-index-schema.json”
curl -X POST “https://${SEARCH_SERVICE_NAME}.search.windows.net/indexes?api-version=${API_VERSION}”
-H “Content-Type: application/json”
-H “api-key: ${API_KEY}”
-d @${SCHEMA_FILE}
Once the Azure AI Search index is created confirm in the portal that the metadata fields are marked as filterable and searchable…
3. Embed and upload document chunks to the Azure AI Search index with their metadata
The documents we will use are the wikipedia pages for the movies saved as pdf files. To integrate the documents to LLM’s in a RAG patter first we will “pre-process” the documents. The below code first opens a specified PDF file with extract_text_from_pdf function , reads its content using the PdfReader class, and extracts the text from each page, combining all the text into a single string. The normalize_text function takes a text string and removes any unnecessary whitespace, ensuring the text is normalized into a single continuous string with spaces. The chunk_text function then takes this normalized text and splits it into smaller chunks, each no larger than a specified size (default 6000 characters). This is done by tokenizing the text into sentences and grouping them into chunks while ensuring each chunk does not exceed the specified size, making the text easier to manage and process in smaller segments.
# Function to extract text from a PDF
def extract_text_from_pdf(pdf_path):
text = “”
with open(pdf_path, “rb”) as file:
reader = PdfReader(file)
for page in reader.pages:
text += page.extract_text() + “n”
return text
# Function to normalize text
def normalize_text(text):
return ‘ ‘.join(text.split())
# Function to chunk text into smaller pieces
def chunk_text(text, chunk_size=6000):
sentences = sent_tokenize(text)
chunks = []
current_chunk = []
current_length = 0
for sentence in sentences:
if current_length + len(sentence) > chunk_size:
chunks.append(‘ ‘.join(current_chunk))
current_chunk = [sentence]
current_length = len(sentence)
else:
current_chunk.append(sentence)
current_length += len(sentence)
if current_chunk:
chunks.append(‘ ‘.join(current_chunk))
return chunks
We hen embed each chunk and upload the embedding along with document metadata to the previously created Azure AI Search index.
4. Unfiltered Vector Search
First let’s make a vector search with a relatively generic prompt which will match multiple document chunks…Notice the explicit filter statement “The movie was cast in 2010”. Note the vector search cannot successfully interpret the stated filter and incorrect results (movies that were cast long before 2010) are returned too in the search result.
# Generate embedding for the plot prompt
plot_prompt = “An individual faces insurmountable odds and undergoes a transformative journey,
uncovering hidden strengths and forming unexpected alliances. Through resilience and cunning,
they navigate a world filled with corruption, betrayal, and a fight for justice,
ultimately discovering their true purpose. The movie was cast in 2010″
prompt_embedding_vector = generate_embeddings(plot_prompt)
payload = {
“count”: True,
“select”: “title, content, genre”,
“vectorQueries”: [
{
“kind”: “vector”,
“vector”: prompt_embedding_vector,
“exhaustive”: True,
“fields”: “contentVector”,
“k”: 5
}
],
# “filter”: “genre eq ‘Drama’ and releaseYear ge 1990 and director eq ‘Christopher Nolan'”
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
results = response.json()
print(“Results with pre-filter:”)
for result in results[‘value’]:
print(result)
else:
print(f”Error: {response.status_code}”)
print(response.json())
Results without pre-filter:
{‘@search.score’: 0.83729386, ‘title’: ‘The Shawshank Redemption’, ‘genre’: ‘Drama’, ‘content’: ‘…’}
{‘@search.score’: 0.83415884, ‘title’: ‘The Shawshank Redemption’, ‘genre’: ‘Drama’, ‘content’: ‘…’}
{‘@search.score’: 0.8314112, ‘title’: ‘Inception’, ‘genre’: ‘Sci-Fi’, ‘content’: ‘…’}
{‘@search.score’: 0.8308051, ‘title’: ‘The Lord of the Rings: The Return of the King’, ‘genre’: ‘Fantasy’, ‘content’: ‘…’}
5. (pre)Filtered Vector Search
Next, add a filter to the vector search…The filter is defined as any document chunk whose releaseYear metadata value (int32) is greater than 2010. In this case only the correct search result, document chunks from the movie “Inception” are returned.
payload_with_release_year_filter = {
“count”: True,
“select”: “title, content, genre, releaseYear, director”,
“filter”: “releaseYear eq 2010”,
“vectorFilterMode”: “preFilter”,
“vectorQueries”: [
{
“kind”: “vector”,
“vector”: prompt_embedding_vector,
“exhaustive”: True,
“fields”: “contentVector”,
“k”: 5
}
]
}
Results with pre-filter:
{‘@search.score’: 0.8314112, ‘title’: ‘Inception’, ‘genre’: ‘Sci-Fi’, ‘releaseYear’: 2010, ‘director’: ‘Christopher Nolan’, ‘content’: ‘…’}
{‘@search.score’: 0.83097535, ‘title’: ‘Inception’, ‘genre’: ‘Sci-Fi’, ‘releaseYear’: 2010, ‘director’: ‘Christopher Nolan’, ‘content’:’…’}
{‘@search.score’: 0.83029956, ‘title’: ‘Inception’, ‘genre’: ‘Sci-Fi’, ‘releaseYear’: 2010, ‘director’: ‘Christopher Nolan’, ‘content’: ‘…’}
{‘@search.score’: 0.82646775, ‘title’: ‘Inception’, ‘genre’: ‘Sci-Fi’, ‘releaseYear’: 2010, ‘director’: ‘Christopher Nolan’, ‘content’: ‘…’}
{‘@search.score’: 0.8255407, ‘title’: ‘Inception’, ‘genre’: ‘Sci-Fi’, ‘releaseYear’: 2010, ‘director’: ‘Christopher Nolan’, ‘content’: ‘…’}
Conclusion:
This blog presented a simple scenario where document chunks are embedded and uploaded to an Azure Search Index with document metadata as searchable and filterable fields.
The concept can be extended such that an additional llm query step can be used to “classify” user prompts and infer the metadata that will be applied for pre/post filtering the vector search matched chunks. Again documents themselves can be tagged with metadata using an LLM call rather than relying on static human annotation as demonstrated in this example.
References:
Filters in vector queries documentation
Create a vector query in Azure AI Search documentation
Hope you enjoyed the content. Let me know any comments / feedback below…
Ozgur Guler
July 24, Istanbul
Microsoft Tech Community – Latest Blogs –Read More
I want to export geometry generated in MATLAB, in abaqus for further FEM analysis. Can any one suggest me how to export geometry for abaqus ?
I had prepared a tool to generate user defined geometry of brick. Now I want to to use that tool to generate various geometries for analysis to be done in abaqus.I had prepared a tool to generate user defined geometry of brick. Now I want to to use that tool to generate various geometries for analysis to be done in abaqus. I had prepared a tool to generate user defined geometry of brick. Now I want to to use that tool to generate various geometries for analysis to be done in abaqus. geometry export, export to abaqus MATLAB Answers — New Questions
Dynamics 365 App for Outlook is not supported Cross Tenant
Hello, I am referring to the disclaimer here which clearly says that Dynamics 365 App for outlook is not supported when the excahange online is on a tenant separate from the Dynmics 365 Sales tenant. This seems to be true even after properly registering the Dynamics 365 as an application in the Azure Tenant of the Exchange Online instance and then configuring the profile etc. all correctly. It is mentioned that the incoming-outgoing emails and appt/contact/task sync will all work through server-side synchronization. But when will this be available for Dynamics 365 App for Outlook in cross-tenant scenario for customers ? As most customers prefer to have their exchange on a dedicated usually the corp hq tenant for better management and then all business apps in different separate tenants based on region/department/child companies ? Please also suggest if there are any workarounds. And kindly give me any pointers to other forums that will be more appropriate for this question, just in case…. Many Thanks
https://learn.microsoft.com/en-us/power-platform/admin/connect-exchange-online-server-profile-oauth
Hello, I am referring to the disclaimer here which clearly says that Dynamics 365 App for outlook is not supported when the excahange online is on a tenant separate from the Dynmics 365 Sales tenant. This seems to be true even after properly registering the Dynamics 365 as an application in the Azure Tenant of the Exchange Online instance and then configuring the profile etc. all correctly. It is mentioned that the incoming-outgoing emails and appt/contact/task sync will all work through server-side synchronization. But when will this be available for Dynamics 365 App for Outlook in cross-tenant scenario for customers ? As most customers prefer to have their exchange on a dedicated usually the corp hq tenant for better management and then all business apps in different separate tenants based on region/department/child companies ? Please also suggest if there are any workarounds. And kindly give me any pointers to other forums that will be more appropriate for this question, just in case…. Many Thanks https://learn.microsoft.com/en-us/power-platform/admin/connect-exchange-online-server-profile-oauth Read More
Unable to recreate k-means clustering example
As per title, i’m unable to recreate the following example (k-means clustering – MATLAB kmeans – MathWorks Italia), the k means clustering of Fisher’s iris dataset.
This is the code in question
load fisheriris
X = meas(:,3:4);
figure;
plot(X(:,1),X(:,2),’k*’,’MarkerSize’,5);
title ‘Fisher”s Iris Data’;
xlabel ‘Petal Lengths (cm)’;
ylabel ‘Petal Widths (cm)’
rng(1); % For reproducibility
[idx,C] = kmeans(X,3);
x1 = min(X(:,1)):0.01:max(X(:,1));
x2 = min(X(:,2)):0.01:max(X(:,2));
[x1G,x2G] = meshgrid(x1,x2);
XGrid = [x1G(:),x2G(:)]; % Defines a fine grid on the plot
idx2Region = kmeans(XGrid,3,’MaxIter’,1,’Start’,C);
figure;
gscatter(XGrid(:,1),XGrid(:,2),idx2Region,…
[0,0.75,0.75;0.75,0,0.75;0.75,0.75,0],’..’);
hold on;
plot(X(:,1),X(:,2),’k*’,’MarkerSize’,5);
title ‘Fisher”s Iris Data’;
xlabel ‘Petal Lengths (cm)’;
ylabel ‘Petal Widths (cm)’;
legend(‘Region 1′,’Region 2′,’Region 3′,’Data’,’Location’,’SouthEast’);
hold off;
An error occurs at line 16 involving the kmeans function
Error in Kmeans_dimostrativo (line 16)
[idx,C] = kmeans(X,3);
So i started digging in the kmeans function
function [label, mu, energy] = kmeans(X, m)
% Perform kmeans clustering.
% Input:
% X: d x n data matrix
% m: initialization parameter
% Output:
% label: 1 x n sample labels
% mu: d x k center of clusters
% energy: optimization target value
% Written by Mo Chen (sth4nth@gmail.com).
label = init(X, m);
n = numel(label);
idx = 1:n;
last = zeros(1,n);
while any(label ~= last)
[~,~,last(:)] = unique(label); % remove empty clusters
mu = X*normalize(sparse(idx,last,1),1); % compute cluster centers
[val,label] = min(dot(mu,mu,1)’/2-mu’*X,[],1); % assign sample labels
end
energy = dot(X(:),X(:),1)+2*sum(val);
function label = init(X, m)
[d,n] = size(X);
if numel(m) == 1 % random initialization
mu = X(:,randperm(n,m));
[~,label] = min(dot(mu,mu,1)’/2-mu’*X,[],1);
elseif all(size(m) == [1,n]) % init with labels
label = m;
elseif size(m,1) == d % init with seeds (centers)
[~,label] = min(dot(m,m,1)’/2-m’*X,[],1);
end
The following error messages are the ones relative to the kmeans function
Error using randperm
K must be less than or equal to N.
Error in kmeans>init (line 25)
mu = X(:,randperm(n,m));
Error in kmeans (line 11)
label = init(X, m);
I honestly don’t know the reason for the errors, i took the script directly from the website.As per title, i’m unable to recreate the following example (k-means clustering – MATLAB kmeans – MathWorks Italia), the k means clustering of Fisher’s iris dataset.
This is the code in question
load fisheriris
X = meas(:,3:4);
figure;
plot(X(:,1),X(:,2),’k*’,’MarkerSize’,5);
title ‘Fisher”s Iris Data’;
xlabel ‘Petal Lengths (cm)’;
ylabel ‘Petal Widths (cm)’
rng(1); % For reproducibility
[idx,C] = kmeans(X,3);
x1 = min(X(:,1)):0.01:max(X(:,1));
x2 = min(X(:,2)):0.01:max(X(:,2));
[x1G,x2G] = meshgrid(x1,x2);
XGrid = [x1G(:),x2G(:)]; % Defines a fine grid on the plot
idx2Region = kmeans(XGrid,3,’MaxIter’,1,’Start’,C);
figure;
gscatter(XGrid(:,1),XGrid(:,2),idx2Region,…
[0,0.75,0.75;0.75,0,0.75;0.75,0.75,0],’..’);
hold on;
plot(X(:,1),X(:,2),’k*’,’MarkerSize’,5);
title ‘Fisher”s Iris Data’;
xlabel ‘Petal Lengths (cm)’;
ylabel ‘Petal Widths (cm)’;
legend(‘Region 1′,’Region 2′,’Region 3′,’Data’,’Location’,’SouthEast’);
hold off;
An error occurs at line 16 involving the kmeans function
Error in Kmeans_dimostrativo (line 16)
[idx,C] = kmeans(X,3);
So i started digging in the kmeans function
function [label, mu, energy] = kmeans(X, m)
% Perform kmeans clustering.
% Input:
% X: d x n data matrix
% m: initialization parameter
% Output:
% label: 1 x n sample labels
% mu: d x k center of clusters
% energy: optimization target value
% Written by Mo Chen (sth4nth@gmail.com).
label = init(X, m);
n = numel(label);
idx = 1:n;
last = zeros(1,n);
while any(label ~= last)
[~,~,last(:)] = unique(label); % remove empty clusters
mu = X*normalize(sparse(idx,last,1),1); % compute cluster centers
[val,label] = min(dot(mu,mu,1)’/2-mu’*X,[],1); % assign sample labels
end
energy = dot(X(:),X(:),1)+2*sum(val);
function label = init(X, m)
[d,n] = size(X);
if numel(m) == 1 % random initialization
mu = X(:,randperm(n,m));
[~,label] = min(dot(mu,mu,1)’/2-mu’*X,[],1);
elseif all(size(m) == [1,n]) % init with labels
label = m;
elseif size(m,1) == d % init with seeds (centers)
[~,label] = min(dot(m,m,1)’/2-m’*X,[],1);
end
The following error messages are the ones relative to the kmeans function
Error using randperm
K must be less than or equal to N.
Error in kmeans>init (line 25)
mu = X(:,randperm(n,m));
Error in kmeans (line 11)
label = init(X, m);
I honestly don’t know the reason for the errors, i took the script directly from the website. As per title, i’m unable to recreate the following example (k-means clustering – MATLAB kmeans – MathWorks Italia), the k means clustering of Fisher’s iris dataset.
This is the code in question
load fisheriris
X = meas(:,3:4);
figure;
plot(X(:,1),X(:,2),’k*’,’MarkerSize’,5);
title ‘Fisher”s Iris Data’;
xlabel ‘Petal Lengths (cm)’;
ylabel ‘Petal Widths (cm)’
rng(1); % For reproducibility
[idx,C] = kmeans(X,3);
x1 = min(X(:,1)):0.01:max(X(:,1));
x2 = min(X(:,2)):0.01:max(X(:,2));
[x1G,x2G] = meshgrid(x1,x2);
XGrid = [x1G(:),x2G(:)]; % Defines a fine grid on the plot
idx2Region = kmeans(XGrid,3,’MaxIter’,1,’Start’,C);
figure;
gscatter(XGrid(:,1),XGrid(:,2),idx2Region,…
[0,0.75,0.75;0.75,0,0.75;0.75,0.75,0],’..’);
hold on;
plot(X(:,1),X(:,2),’k*’,’MarkerSize’,5);
title ‘Fisher”s Iris Data’;
xlabel ‘Petal Lengths (cm)’;
ylabel ‘Petal Widths (cm)’;
legend(‘Region 1′,’Region 2′,’Region 3′,’Data’,’Location’,’SouthEast’);
hold off;
An error occurs at line 16 involving the kmeans function
Error in Kmeans_dimostrativo (line 16)
[idx,C] = kmeans(X,3);
So i started digging in the kmeans function
function [label, mu, energy] = kmeans(X, m)
% Perform kmeans clustering.
% Input:
% X: d x n data matrix
% m: initialization parameter
% Output:
% label: 1 x n sample labels
% mu: d x k center of clusters
% energy: optimization target value
% Written by Mo Chen (sth4nth@gmail.com).
label = init(X, m);
n = numel(label);
idx = 1:n;
last = zeros(1,n);
while any(label ~= last)
[~,~,last(:)] = unique(label); % remove empty clusters
mu = X*normalize(sparse(idx,last,1),1); % compute cluster centers
[val,label] = min(dot(mu,mu,1)’/2-mu’*X,[],1); % assign sample labels
end
energy = dot(X(:),X(:),1)+2*sum(val);
function label = init(X, m)
[d,n] = size(X);
if numel(m) == 1 % random initialization
mu = X(:,randperm(n,m));
[~,label] = min(dot(mu,mu,1)’/2-mu’*X,[],1);
elseif all(size(m) == [1,n]) % init with labels
label = m;
elseif size(m,1) == d % init with seeds (centers)
[~,label] = min(dot(m,m,1)’/2-m’*X,[],1);
end
The following error messages are the ones relative to the kmeans function
Error using randperm
K must be less than or equal to N.
Error in kmeans>init (line 25)
mu = X(:,randperm(n,m));
Error in kmeans (line 11)
label = init(X, m);
I honestly don’t know the reason for the errors, i took the script directly from the website. k-means clustering, statistics MATLAB Answers — New Questions
Compressed file KQL for endpoint
Hi,
Based on my understanding of AlertEvidence schema for KQL, there are columns for filename and folderpath. However, my query results in empty filename and folderpath. I am wondering could it be because the files that are detected with virus are zip or rar files and so KQL does not return any values for filename and folderpath? Can someone enlighten me on this?
thank you in advanced!
Hi, Based on my understanding of AlertEvidence schema for KQL, there are columns for filename and folderpath. However, my query results in empty filename and folderpath. I am wondering could it be because the files that are detected with virus are zip or rar files and so KQL does not return any values for filename and folderpath? Can someone enlighten me on this?thank you in advanced! Read More
Notes in Excel
I like to use notes in Excel but somehow I’ve managed to disable them. How do I reenable them?
I like to use notes in Excel but somehow I’ve managed to disable them. How do I reenable them? Read More
Why does Edge keep signing me out?
This happens probably a few times a week and it’s getting really annoying. I’m signed out from my own account for no reason.
This happens probably a few times a week and it’s getting really annoying. I’m signed out from my own account for no reason. Read More
How to receive an full binary data using mqtt callback function
I have sent a binary blob (for example 4k) from C++ app by mqtt mosquitto. In matlab only a chunk of sending data is received. This chunk is limited by the first zero byte which is in the blob. How to receive a full message?
Short code snippest below:
mqttClient = mqttclient("tcp://127.0.0.1");
mySub = subscribe(mqttClient, "topic", Callback=@MsgCallvBack)
%
function MsgCallvBack(topic, data)
fprintf("topic=%s, data size=%un", topic, numel(char(data)));
endI have sent a binary blob (for example 4k) from C++ app by mqtt mosquitto. In matlab only a chunk of sending data is received. This chunk is limited by the first zero byte which is in the blob. How to receive a full message?
Short code snippest below:
mqttClient = mqttclient("tcp://127.0.0.1");
mySub = subscribe(mqttClient, "topic", Callback=@MsgCallvBack)
%
function MsgCallvBack(topic, data)
fprintf("topic=%s, data size=%un", topic, numel(char(data)));
end I have sent a binary blob (for example 4k) from C++ app by mqtt mosquitto. In matlab only a chunk of sending data is received. This chunk is limited by the first zero byte which is in the blob. How to receive a full message?
Short code snippest below:
mqttClient = mqttclient("tcp://127.0.0.1");
mySub = subscribe(mqttClient, "topic", Callback=@MsgCallvBack)
%
function MsgCallvBack(topic, data)
fprintf("topic=%s, data size=%un", topic, numel(char(data)));
end mqtt MATLAB Answers — New Questions
Error using fit>iFit Too many start points. You need 2 start points for this model
Dear all
I have created this function to do implement a fitting to some data:
function [fitresult,gof]=Fit(s,mag,in_mag,in_cond)
if round(in_mag(1))==1 && round(in_mag(end))==-1
fitting_function=’cos(2*atan(exp((x-x0)/Delta)))’;
elseif round(in_mag(1))==-1 && round(in_mag(end))==1
fitting_function=’cos(2*atan(exp(-(x-x0)/Delta)))’;
end
ft=fittype(fitting_function,’independent’,’x’,’dependent’,’y’);
opts=fitoptions(‘Method’,’NonlinearLeastSquares’);
opts.Display=’Off’;
opts.StartPoint=in_cond;
[fitresult,gof]=fit(space,mag,ft,opts);
When trying to fit some data:
initial_conditions=[1 1];
[fitresult,gof]=Fit(some_column_vector,other_column_vector,another_column_vector,initial_conditions’);
where "some_column_vector", "other_column_vector", and "another_column_vector" are 1000×1 arrays.
I received the following error:
Error using fit>iFit
Too many start points. You need 2 start points for this model.
Any ideas on what could be happening here?Dear all
I have created this function to do implement a fitting to some data:
function [fitresult,gof]=Fit(s,mag,in_mag,in_cond)
if round(in_mag(1))==1 && round(in_mag(end))==-1
fitting_function=’cos(2*atan(exp((x-x0)/Delta)))’;
elseif round(in_mag(1))==-1 && round(in_mag(end))==1
fitting_function=’cos(2*atan(exp(-(x-x0)/Delta)))’;
end
ft=fittype(fitting_function,’independent’,’x’,’dependent’,’y’);
opts=fitoptions(‘Method’,’NonlinearLeastSquares’);
opts.Display=’Off’;
opts.StartPoint=in_cond;
[fitresult,gof]=fit(space,mag,ft,opts);
When trying to fit some data:
initial_conditions=[1 1];
[fitresult,gof]=Fit(some_column_vector,other_column_vector,another_column_vector,initial_conditions’);
where "some_column_vector", "other_column_vector", and "another_column_vector" are 1000×1 arrays.
I received the following error:
Error using fit>iFit
Too many start points. You need 2 start points for this model.
Any ideas on what could be happening here? Dear all
I have created this function to do implement a fitting to some data:
function [fitresult,gof]=Fit(s,mag,in_mag,in_cond)
if round(in_mag(1))==1 && round(in_mag(end))==-1
fitting_function=’cos(2*atan(exp((x-x0)/Delta)))’;
elseif round(in_mag(1))==-1 && round(in_mag(end))==1
fitting_function=’cos(2*atan(exp(-(x-x0)/Delta)))’;
end
ft=fittype(fitting_function,’independent’,’x’,’dependent’,’y’);
opts=fitoptions(‘Method’,’NonlinearLeastSquares’);
opts.Display=’Off’;
opts.StartPoint=in_cond;
[fitresult,gof]=fit(space,mag,ft,opts);
When trying to fit some data:
initial_conditions=[1 1];
[fitresult,gof]=Fit(some_column_vector,other_column_vector,another_column_vector,initial_conditions’);
where "some_column_vector", "other_column_vector", and "another_column_vector" are 1000×1 arrays.
I received the following error:
Error using fit>iFit
Too many start points. You need 2 start points for this model.
Any ideas on what could be happening here? fitting MATLAB Answers — New Questions
华纳公司娱乐注册【QQ1398654119】
1.作为老街本土企业,、奉献,十余年的商业运营优势。
2.集团不仅成为东城品牌经济发展的引领者,更是成为带动时尚产业升级。
3.整合时尚产业链、引领时尚高端产业先机。
4.打造持续创新商业运营模式的“一站式”服务机构。
5.更是成为了用实力运营城市的城市运营商。腾龙将继续肩负这份责任与担当,为云南的发展不断贡献自身力量!
1.作为老街本土企业,、奉献,十余年的商业运营优势。2.集团不仅成为东城品牌经济发展的引领者,更是成为带动时尚产业升级。3.整合时尚产业链、引领时尚高端产业先机。4.打造持续创新商业运营模式的“一站式”服务机构。5.更是成为了用实力运营城市的城市运营商。腾龙将继续肩负这份责任与担当,为云南的发展不断贡献自身力量! Read More
Properties of Taskbar Shortcuts
I am unable to find the Properties option when I right-click on some taskbar shortcuts and I want to change their icons. The only option available is to unpin them from the taskbar. What could I be overlooking?
I am unable to find the Properties option when I right-click on some taskbar shortcuts and I want to change their icons. The only option available is to unpin them from the taskbar. What could I be overlooking? Read More
Learn User Interface (UI) Design for Windows 11
I recently got a new HP computer with the Windows 11 operating system as a Christmas gift. I was previously using Windows 8.1 with a layout resembling Windows 7. Transitioning to the new Windows 11 interface feels somewhat foreign to me, almost like navigating an Apple interface. Can you recommend any tutorials or books that can help ease me into the Windows 11 interface from my familiarity with Windows 8.1? I’m currently unsure how to properly shut down the computer, aside from pressing the physical power button. The new laptop is an HP model, and I’m sending this message from my Windows 8.1 laptop because I’m not sure how to access this platform from my Windows 11 device. Thank you for your assistance. – Jon
I recently got a new HP computer with the Windows 11 operating system as a Christmas gift. I was previously using Windows 8.1 with a layout resembling Windows 7. Transitioning to the new Windows 11 interface feels somewhat foreign to me, almost like navigating an Apple interface. Can you recommend any tutorials or books that can help ease me into the Windows 11 interface from my familiarity with Windows 8.1? I’m currently unsure how to properly shut down the computer, aside from pressing the physical power button. The new laptop is an HP model, and I’m sending this message from my Windows 8.1 laptop because I’m not sure how to access this platform from my Windows 11 device. Thank you for your assistance. – Jon Read More
How to Generate HEIC Thumbnails in Windows 11 Using nCache
Lately, I’ve switched to using HEIC images to conserve storage space, and I’m quite satisfied with the format’s quality and compression benefits. However, I’ve encountered an issue with the extended loading time of thumbnails when I access a folder containing HEIC images. While I expect the initial load to take some time, it’s frustrating that every time I reopen the folder, the HEIC thumbnails are reloaded from scratch.
I’m looking for a solution in Windows 11 that can cache HEIC thumbnails to enable quick access to the folder contents after the initial load.
I store the images on my hard drive, so I anticipate they should load swiftly. Despite having thumbnail caching enabled in my Windows settings, it doesn’t seem to be functioning properly.
Here are the system specifications:
– Device: HP Envy 17 2023
– Processor: 13th Gen Intel(R) Core(TM) i7-1355U, 1.70 GHz
– RAM: 32.0 GB
– OS: Windows 11 Pro 22H2
– Storage: 1TB SSD
I appreciate any guidance or assistance in resolving this issue.
Lately, I’ve switched to using HEIC images to conserve storage space, and I’m quite satisfied with the format’s quality and compression benefits. However, I’ve encountered an issue with the extended loading time of thumbnails when I access a folder containing HEIC images. While I expect the initial load to take some time, it’s frustrating that every time I reopen the folder, the HEIC thumbnails are reloaded from scratch. I’m looking for a solution in Windows 11 that can cache HEIC thumbnails to enable quick access to the folder contents after the initial load. I store the images on my hard drive, so I anticipate they should load swiftly. Despite having thumbnail caching enabled in my Windows settings, it doesn’t seem to be functioning properly. Here are the system specifications:- Device: HP Envy 17 2023- Processor: 13th Gen Intel(R) Core(TM) i7-1355U, 1.70 GHz- RAM: 32.0 GB- OS: Windows 11 Pro 22H2- Storage: 1TB SSD I appreciate any guidance or assistance in resolving this issue. Read More