Last active
March 16, 2021 13:29
-
-
Save ginomessmer/f960071174edf647e3ac44acce7099eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using Microsoft.ML; | |
using Microsoft.ML.Data; | |
var dataPath = Path.Combine(Environment.CurrentDirectory, "skills.csv"); | |
var mlContext = new MLContext(); | |
var dataView = mlContext.Data.LoadFromTextFile<SkillData>(dataPath, ',', true); | |
const string featuresColumnName = "Features"; | |
var pipeline = mlContext.Transforms | |
.Concatenate(featuresColumnName, "Windows", "Linux", "MobileDevelopment", "WebAPIs", "Cloud", "IoT", "Android") | |
.Append(mlContext.Clustering.Trainers.KMeans(featuresColumnName, numberOfClusters: 2)); | |
var model = pipeline.Fit(dataView); | |
var predictor = mlContext.Model.CreatePredictionEngine<SkillData, ClusterPrediction>(model); | |
var prediction = predictor.Predict(new SkillData | |
{ | |
Android = 1, Cloud = 5, IoT = 1, Linux = 4, | |
MobileDevelopment = 4, | |
WebAPIs = 5, Windows = 5 | |
}); | |
Console.WriteLine("Cluster: {0}", prediction.PredictedClusterId); | |
Console.WriteLine("Distances: {0}", string.Join(" ", prediction.Distances)); | |
Console.ReadLine(); | |
public class SkillData | |
{ | |
[LoadColumn(0)] public string Name; | |
[LoadColumn(1)] public float Windows; | |
[LoadColumn(2)] public float Linux; | |
[LoadColumn(3)] public float MobileDevelopment; | |
[LoadColumn(4)] public float WebAPIs; | |
[LoadColumn(5)] public float Cloud; | |
[LoadColumn(6)] public float IoT; | |
[LoadColumn(7)] public float Android; | |
} | |
public class ClusterPrediction | |
{ | |
[ColumnName("PredictedLabel")] public uint PredictedClusterId; | |
[ColumnName("Score")] public float[] Distances; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name | Windows | Linux | MobileDevelopment | WebAPIs | Cloud | IoT | Android | C++ | C# | Java | JavaScript | Kotlin | Python | Go | iOS | Ich vertraue anderen | Ich mache schnell Freunde | Ich sorge mich 2 | Ich bearbeite Aufgaben erfolgreich | Ich werde nicht schnell w�tend | Ich genie�e gro�e Parties und Versammlungen | Ich mag es aufzur�umen | Geschlecht | Ich bin zu Fremden eher... | Ich trinke eher... | Geburtsjahr | Web Entwicklung | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Gino | 4 | 4 | 5 | 5 | 5 | 1 | 1 | 1 | 5 | 2 | 4 | 1 | 1 | 1 | 1 | 3 | 3 | 4 | 4 | 4 | 3 | 4 | Männlich | introvertiert | Kaffee | 1999 | 4 | |
Isabell | 3 | 4 | 4 | 4 | 3 | 2 | 5 | 1 | 3 | 5 | 3 | 3 | 4 | 1 | 1 | 3 | 5 | 3 | 4 | 3 | 2 | 1 | Weiblich | extrovertiert | Tee | 1999 | 4 | |
Imke | 4 | 3 | 5 | 4 | 5 | 5 | 5 | 4 | 5 | 3 | 3 | 3 | 4 | 3 | 5 | 4 | 3 | 1 | 4 | 3 | 1 | 3 | Weiblich | introvertiert | Tee | 1999 | 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment