Applications of Machine Learning for private cloud operations
We continue listing some more scenarios from yesterday's post.
Use case 9) matching customers
Customers may request various resources from the cloud over time. They may be interested in servers, file shares at specific regions. If we help find a buddy for the customer, they may benefit from their common interests.
We could use an advanced classifier like kernel methods and support vector machines to make predictions whether people with a given set of attributes will match or not.
#codingexercise
Find the minimum number of swaps required for arranging pairs adjacent to each other.
eg:
pairs[] = { 1->3, 2->6, 4->5 }
arr[] = {3, 5, 6, 4, 1, 2}
int GetMinSwaps(List<Tuple<int,int>> pairs, List<int> arr, int start, int end) start and end are for the pairs
{
if (arr.Count <= 1)return 0;
if ( start >= arr.Count) return 0;
// no-op
if (arr[start] == pairs.find_match(arr[1])) return GetMinSwaps(pairs, arr, start+2, end);
int index = arr.find(pairs.find_match(arr[0));
Swap(arr, start+1, index);
int a = GetMinSwaps(pairs, arr, start+2, end);
Swap(arr,start+1, index);
index = arr.find(pairs.find_match(arr[1]));
Swap(arr, start, index);
int b = GetMinSwaps(pairs, arr, start+2, end);
Swap(arr, start, index);
return 1 + min(a,b);
}
We continue listing some more scenarios from yesterday's post.
Use case 8) Feature Extraction
We want to find server request patterns from a set which can help with identifying themes that are independently present in various combinations. Like clustering, we are not interested in making predictions but in finding interesting things about the data. Similarly from server usage patterns, we may be able to find multiple underlying causes that combine to create results.
We find a feature matrix from that has a row for each feature and a column for chosen set of server requests. We also find a weights matrix that maps the features to the requests matrix. Each row is a request and each column is a feature. From the data converted into a nested dictionary, we factorize to get the features and the weights matrix.Use case 9) matching customers
Customers may request various resources from the cloud over time. They may be interested in servers, file shares at specific regions. If we help find a buddy for the customer, they may benefit from their common interests.
We could use an advanced classifier like kernel methods and support vector machines to make predictions whether people with a given set of attributes will match or not.
#codingexercise
Find the minimum number of swaps required for arranging pairs adjacent to each other.
eg:
pairs[] = { 1->3, 2->6, 4->5 }
arr[] = {3, 5, 6, 4, 1, 2}
int GetMinSwaps(List<Tuple<int,int>> pairs, List<int> arr, int start, int end) start and end are for the pairs
{
if (arr.Count <= 1)return 0;
if ( start >= arr.Count) return 0;
// no-op
if (arr[start] == pairs.find_match(arr[1])) return GetMinSwaps(pairs, arr, start+2, end);
int index = arr.find(pairs.find_match(arr[0));
Swap(arr, start+1, index);
int a = GetMinSwaps(pairs, arr, start+2, end);
Swap(arr,start+1, index);
index = arr.find(pairs.find_match(arr[1]));
Swap(arr, start, index);
int b = GetMinSwaps(pairs, arr, start+2, end);
Swap(arr, start, index);
return 1 + min(a,b);
}
int RemoveExtraSpaces(stringbuilder input)
{
var words = input.split();
return words.aggregate( (sent, next) => sent + " " + next);
}
Find the sum of bit differences between all pairs in an array of n integers
Int bitdiff(List<int> arr, int n)
{
int total = 0;
For ( int I =0; I < 32; I ++)
{
int count = 0;
for (int j = 0; j <n ; j++)
if (arr[j] & (1 << i))
count++;
total += (count * (n-count) * 2);
}
return total;
}
Find next greater element for every element of an array to its right in O(n)
List<int> GetNextLargest(List<int> arr)
{
var greater = new List<int>(); // stores index
for (int i = 0; i < arr.Count; i++)
{
int next = -1;
for (int j = i+1; j <arr.Count; j++)
{
if (arr[j] > arr[i])
{
next = j;
break;
}
}
greater[i] = next;
}
return greater;
}
Arrange balls in a line so that no two of the same type are together
Void arrange (ref List <ball> candidate, List <int> colornum, int start, int level)
{
For (int I = start, I < colornum.sum (); i++)
Candidate [level] = 0;
for ( int color = 0; color < colornum.count; color++)
If (level > 0 && candidate [level-1] != color && candidate( x => x == color) != colornum [color])
Candidate [level] = color;
If (candidate.length == colornum.sum ())
Print candidate.toString ();
If (I < colornum.sum ())
{
Arrange( ref candidate, colornum, start+1, level+1);
}
Candidate [level] = -1;
}
}
Find next greater element for every element of an array to its right in O(n)
List<int> GetNextLargest(List<int> arr)
{
var greater = new List<int>(); // stores index
for (int i = 0; i < arr.Count; i++)
{
int next = -1;
for (int j = i+1; j <arr.Count; j++)
{
if (arr[j] > arr[i])
{
next = j;
break;
}
}
greater[i] = next;
}
return greater;
}
Arrange balls in a line so that no two of the same type are together
Void arrange (ref List <ball> candidate, List <int> colornum, int start, int level)
{
For (int I = start, I < colornum.sum (); i++)
Candidate [level] = 0;
for ( int color = 0; color < colornum.count; color++)
If (level > 0 && candidate [level-1] != color && candidate( x => x == color) != colornum [color])
Candidate [level] = color;
If (candidate.length == colornum.sum ())
Print candidate.toString ();
If (I < colornum.sum ())
{
Arrange( ref candidate, colornum, start+1, level+1);
}
Candidate [level] = -1;
}
}
No comments:
Post a Comment