{"id":27924,"date":"2019-12-17T00:00:00","date_gmt":"2019-12-16T23:00:00","guid":{"rendered":"https:\/\/blexin.com\/creare-un-modello-per-il-machine-learning-con-ml-net\/"},"modified":"2021-05-20T18:46:17","modified_gmt":"2021-05-20T16:46:17","slug":"how-to-create-a-model-for-machine-learning-with-ml-net","status":"publish","type":"post","link":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/","title":{"rendered":"How to create a model for Machine Learning with ML.NET"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" data-attachment-id=\"27894\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image00-17-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&amp;ssl=1\" data-orig-size=\"1024,608\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image00-17\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?resize=1024%2C608&#038;ssl=1\" alt=\"\" class=\"wp-image-27894\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png 1024w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17-980x582.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17-480x285.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s continue from the previous&nbsp;<a href=\"https:\/\/www.blexin.com\/en-US\/Article\/Blog\/Is-Machine-Learning-a-programmable-washing-machine-55\" target=\"_blank\" rel=\"noreferrer noopener\">article<\/a>, talking about&nbsp;<strong>features<\/strong>, the properties we use as input to our model in order to build a prediction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In every Machine Learning course, it\u2019s evident what we want to predict: the flat price per square meter, the taxi tips in New York, etc. But in our specific case (and more in general), do we know what we want to extract from our data? Are our&nbsp;<strong>features<\/strong>&nbsp;good enough?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A good feature has a known value at prediction time: we can\u2019t create a model with a full set of data and instead make a prediction with missing information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s come back to our data:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"581\" data-attachment-id=\"27898\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image01-13-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-13.png?fit=665%2C581&amp;ssl=1\" data-orig-size=\"665,581\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image01-13\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-13.png?fit=665%2C581&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-13.png?resize=665%2C581&#038;ssl=1\" alt=\"\" class=\"wp-image-27898\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-13.png 665w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image01-13-480x419.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 665px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s suppose we want to make a prediction on a match that player X will play tomorrow. The only&nbsp;<strong>features<\/strong>&nbsp;we know today are: the player\u2019s age, his (her) role, the match date, and his (her) belonging to the home team.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Everything else is unknown: how many minutes he (she) will play, how many goals or self-goals he (she) will score, if he (she) will receive a yellow or a red card, if the home team will win, etc. This information is usually called&nbsp;<strong>labels<\/strong>: everything we want to predict.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the last article, we did not insert the player\u2019s identity and the teams\u2019 names as&nbsp;<strong>features<\/strong>&nbsp;in our&nbsp;<strong>dataset<\/strong>. Does the probability that X will score a goal or receive a card depend on his (her) history or is an absolute number that is not related to his (her) own identity?<br>Another question: do these probabilities depend on player X belonging to team Y and not to team Z anymore?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Even after years of studying Statistics, these questions remain too complex to be answered. I decided to recover the identities in our dataset to show you another classical technique in data preparation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We suppose, for the sake of simplicity, to have data concerning only five players, labeled with a number range from 1 to 5. We associate a five-dimensional array (that is the total number of players) and not the player&#8217;s ID to each row in our&nbsp;<strong>dataset<\/strong>. This array has all its elements equal to zero except the one corresponding to its ID. Again, it\u2019s an example of<strong>&nbsp;one-hot-encoding<\/strong>, a technique we talked about in the previous article, optimizing the execution time and efficiency of our Machine Learning algorithms.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"264\" data-attachment-id=\"27900\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image02-12-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-12.png?fit=890%2C264&amp;ssl=1\" data-orig-size=\"890,264\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image02-12\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-12.png?fit=890%2C264&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-12.png?resize=890%2C264&#038;ssl=1\" alt=\"\" class=\"wp-image-27900\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-12.png 890w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image02-12-480x142.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 890px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To create a&nbsp;<strong>sparse column<\/strong>&nbsp;(another name used to indicate such columns), we need to pre-process our data to extract all the keys and create a dictionary with them. This dictionary must be available at the prediction time and must not change compared to the one used in our model\u2019s training.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What if we add a new player to the original data and want to build a prediction for him (her)? We don\u2019t have his (her) key. A classical technique is to add, from the beginning, a key for an unknown player (in our example one for each role) and associate to them the average values of the other&nbsp;<strong>features<\/strong>. Adding more data, we can create a new dictionary version and use it to train our model again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How can we manage a&nbsp;<strong>sparse column<\/strong>? Especially if we have thousands of players? Only a library can help us to solve such a big problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">ML.NET allows us to enrich our .NET applications with Machine Learning<strong>&nbsp;features<\/strong>, both for online and offline scenarios.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Starting from the Microsoft .NET learning portal (<a href=\"https:\/\/dotnet.microsoft.com\/learn\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;https:\/\/dotnet.microsoft.com\/learn&nbsp;<\/a>), it\u2019s possible to access to the Machine Learning section.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"359\" data-attachment-id=\"27903\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image03-11-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-11.png?fit=1179%2C413&amp;ssl=1\" data-orig-size=\"1179,413\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image03-11\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-11.png?fit=1024%2C359&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-11.png?resize=1024%2C359&#038;ssl=1\" alt=\"\" class=\"wp-image-27903\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-11-1024x359.png 1024w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-11-980x343.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image03-11-480x168.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On Linux and macOS we can install the ML.NET CLI (Command Line Interface) while on Windows it\u2019s available an extension called ML.NET Model Builder for Visual Studio.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1019\" height=\"301\" data-attachment-id=\"27905\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image04-12-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-12.png?fit=1019%2C301&amp;ssl=1\" data-orig-size=\"1019,301\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image04-12\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-12.png?fit=1019%2C301&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-12.png?resize=1019%2C301&#038;ssl=1\" alt=\"\" class=\"wp-image-27905\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-12.png 1019w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-12-980x289.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image04-12-480x142.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1019px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"856\" height=\"526\" data-attachment-id=\"27907\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image05-11-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image05-11.png?fit=856%2C526&amp;ssl=1\" data-orig-size=\"856,526\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image05-11\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image05-11.png?fit=856%2C526&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image05-11.png?resize=856%2C526&#038;ssl=1\" alt=\"\" class=\"wp-image-27907\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image05-11.png 856w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image05-11-480x295.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 856px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Starting from a .NET Core, Console Application, we can access to a contextual menu called&nbsp;<strong>Machine Learning<\/strong>&nbsp;as shown in the following image:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"536\" data-attachment-id=\"27910\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image06-10-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image06-10.png?fit=1510%2C790&amp;ssl=1\" data-orig-size=\"1510,790\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image06-10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image06-10.png?fit=1024%2C536&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image06-10.png?resize=1024%2C536&#038;ssl=1\" alt=\"\" class=\"wp-image-27910\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image06-10-980x513.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image06-10-480x251.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This menu starts a wizard that leads us to choose one among a series of typical scenarios:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"401\" data-attachment-id=\"27912\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image07-10-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image07-10.png?fit=1252%2C490&amp;ssl=1\" data-orig-size=\"1252,490\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image07-10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image07-10.png?fit=1024%2C401&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image07-10.png?resize=1024%2C401&#038;ssl=1\" alt=\"\" class=\"wp-image-27912\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image07-10-1024x401.png 1024w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image07-10-980x384.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image07-10-480x188.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The custom scenario is what we need for our example to have more flexibility. We can load the dataset from an input csv file, choose the<strong>&nbsp;label<\/strong>&nbsp;for our predictions, and choose the&nbsp;<strong>features<\/strong>&nbsp;among those available.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"459\" data-attachment-id=\"27914\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image08-8-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image08-8.png?fit=1430%2C641&amp;ssl=1\" data-orig-size=\"1430,641\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image08-8\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image08-8.png?fit=1024%2C459&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image08-8.png?resize=1024%2C459&#038;ssl=1\" alt=\"\" class=\"wp-image-27914\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image08-8-980x439.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image08-8-480x215.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When we start a project from scratch, such an approach will rarely produce a working model. We need to test our procedure step-by-step. Therefore, let\u2019s start by installing a NuGet package called Microsoft.ML<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"947\" height=\"204\" data-attachment-id=\"27916\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image09-7-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image09-7.png?fit=947%2C204&amp;ssl=1\" data-orig-size=\"947,204\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image09-7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image09-7.png?fit=947%2C204&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image09-7.png?resize=947%2C204&#038;ssl=1\" alt=\"\" class=\"wp-image-27916\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image09-7.png 947w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image09-7-480x103.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 947px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Starting from the .csv file containing all the data and from the names chosen in the header, let\u2019s define the following two classes in our code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\npublic class PlayerData\n{\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(0)]\n\u00a0\u00a0\u00a0\u00a0public int Id;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(1)]\n\u00a0\u00a0\u00a0\u00a0public float Age;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(5)]\n\u00a0\u00a0\u00a0\u00a0public string AwayTeam;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(6)]\n\u00a0\u00a0\u00a0\u00a0public float Year;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(7)]\n\u00a0\u00a0\u00a0\u00a0public float Month;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(8)]\n\u00a0\u00a0\u00a0\u00a0public float Day;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(10)]\n\u00a0\u00a0\u00a0\u00a0public float Minutes;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(12)]\n\u00a0\u00a0\u00a0\u00a0public string HomeTeam;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(18)]\n\u00a0\u00a0\u00a0\u00a0public float IsHomeTeam;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(19)]\n\u00a0\u00a0\u00a0\u00a0public float IsDefender;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(20)]\n\u00a0\u00a0\u00a0\u00a0public float IsMidfield;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(21)]\n\u00a0\u00a0\u00a0\u00a0public float IsForward;\n\u00a0\u00a0\u00a0\u00a0&#x5B;LoadColumn(22)]\n\u00a0\u00a0\u00a0\u00a0public float IsNoRole;\n}\n\u00a0\npublic class PlayerDataPrediction\n{\n\u00a0\u00a0\u00a0\u00a0&#x5B;ColumnName(&quot;Minutes&quot;)]\n\u00a0\u00a0\u00a0\u00a0public float Minutes;\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">PlayerData is the class corresponding to the input data, and its properties match the dataset columns. The LoadColumn attribute shows the dataset column indexes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PlayerDataPrediction represents a class having the properties we want to predict. Everyone is preceded by a ColumnName attribute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Every ML.NET operation starts with the creation of an instance of the MLContext class. Conceptually, it\u2019s similar to the DbContext class in Entity Framework: a context for the execution of every Machine Learning activity. The constructor takes as a parameter an integer number as seed for the pseudo-random number generator for internal use. The use of the same seed in our experiments makes the MLContext deterministic: its results will be reproducible in future experiments.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nvar mlContext = new MLContext(seed: 0);\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Operations leading to the generation of a Model are:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Loading data<\/li><li>Extracting and manipulating data<\/li><li>Running the Model training<\/li><li>Saving the Model<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">ML.NET uses the IDataView interface to define the pipeline used for reading and manipulating the input data. IDataView loads textual files (.csv) or real-time data (for example from a SQL database or a log file).<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nIDataView dataView = mlContext.Data.LoadFromTextFile&lt;playerdata&gt;(dataPath, hasHeader: true, separatorChar: &#039;,&#039;);\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">This instruction loads a .csv file available at the dataPath path, stating that its first row contains a header and that the separator character is a comma.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The transformation pipeline starts stating which will be the label among the available data columns.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nvar pipeline = mlContext.Transforms.CopyColumns(outputColumnName: &quot;Label&quot;, inputColumnName: &quot;Minutes&quot;)\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">and then showing which are the categorical columns on which to use&nbsp;<strong>OneHotEncoding<\/strong>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: &quot;AwayTeamEncoded&quot;,\u00a0\u00a0 inputColumnName: &quot;AwayTeam&quot;))\n\u00a0\n.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: &quot;IdEncoded&quot;, inputColumnName: &quot;Id&quot;))\n\u00a0\n.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: &quot;HomeTeamEncoded&quot;, inputColumnName: &quot;HomeTeam&quot;))\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We proceed concatenating all the&nbsp;<strong>features<\/strong>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n.Append(mlContext.Transforms.Concatenate(&quot;Features&quot;, \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;IdEncoded&quot;, &quot;AwayTeamEncoded&quot;, &quot;HomeTeamEncoded&quot;, \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;Age&quot;, &quot;Year&quot;, &quot;Month&quot;, &quot;Day&quot;,&quot;IsHomeTeam&quot;,&quot;IsDefender&quot;, \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&quot;IsMidfield&quot;, &quot;IsForward&quot;, &quot;IsNoRole&quot;)\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">and finally executing the model\u2019s training choosing an algorithm in the library among the available ones:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n.Append(mlContext.Regression.Trainers.Sdca()));\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">The algorithm we used is called&nbsp;<strong>Stochastic Dual Coordinate Ascend (SDCA)<\/strong>. Why we choose this one? Simply because it\u2019s the only one not raising an exception with the input data we passed. Why do other algorithms fail? Maybe because our data are still not correctly normalized and optimized.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fact that SDCA is working it\u2019s not enough to conclude that the model will be usable in the prediction phase. We need to know which is its accuracy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The model is created and saved with the following instruction:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nvar model = pipeline.Fit(dataView);\nmlContext.Model.Save(model, dataView.Schema, &quot;model.zip&quot;);\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"986\" height=\"192\" data-attachment-id=\"27921\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/attachment\/image10-5-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image10-5.png?fit=986%2C192&amp;ssl=1\" data-orig-size=\"986,192\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image10-5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image10-5.png?fit=986%2C192&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image10-5.png?resize=986%2C192&#038;ssl=1\" alt=\"\" class=\"wp-image-27921\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image10-5.png 986w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image10-5-980x191.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image10-5-480x93.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 986px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Too simple, isn\u2019t it? Are you curious to know if we\u2019ll succeed in predicting how many minutes will the player X in his (her) next match starting from the available&nbsp;<strong>features<\/strong>? You will read it in my next article where I will show you the techniques to be used to create a sample of data to evaluate the model\u2019s performances.<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>After analyzing the importance of data for the Machine Learning, let\u2019s see how to create a data model according to our requirements<\/p>\n","protected":false},"author":196716245,"featured_media":27894,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_crdt_document":"","inline_featured_image":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[688637524],"tags":[688637381,688637450,688637452],"class_list":["post-27924","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-en","tag-azure-en","tag-cloud-en","tag-machinelearning-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to create a model for Machine Learning with ML.NET - Blexin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a model for Machine Learning with ML.NET - Blexin\" \/>\n<meta property=\"og:description\" content=\"After analyzing the importance of data for the Machine Learning, let\u2019s see how to create a data model according to our requirements\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/\" \/>\n<meta property=\"og:site_name\" content=\"Blexin\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-16T23:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-20T16:46:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"608\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Salvatore Sorrentino\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Salvatore Sorrentino\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/\"},\"author\":{\"name\":\"Salvatore Sorrentino\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/354db2bc97cac71c2ceeca21a92d5bed\"},\"headline\":\"How to create a model for Machine Learning with ML.NET\",\"datePublished\":\"2019-12-16T23:00:00+00:00\",\"dateModified\":\"2021-05-20T16:46:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/\"},\"wordCount\":1209,\"image\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-17.png?fit=1024%2C608&ssl=1\",\"keywords\":[\"Azure\",\"Cloud\",\"Machinelearning\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/\",\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/\",\"name\":\"How to create a model for Machine Learning with ML.NET - Blexin\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-17.png?fit=1024%2C608&ssl=1\",\"datePublished\":\"2019-12-16T23:00:00+00:00\",\"dateModified\":\"2021-05-20T16:46:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/354db2bc97cac71c2ceeca21a92d5bed\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-17.png?fit=1024%2C608&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/image00-17.png?fit=1024%2C608&ssl=1\",\"width\":1024,\"height\":608},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/how-to-create-a-model-for-machine-learning-with-ml-net\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blexin.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a model for Machine Learning with ML.NET\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/\",\"name\":\"Blexin\",\"description\":\"Con noi \u00e8 semplice\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blexin.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/354db2bc97cac71c2ceeca21a92d5bed\",\"name\":\"Salvatore Sorrentino\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a6ec0dc827d2acaa55df9dbf1007e23f6fcb8c9436df52ab48274bb2221085bf?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a6ec0dc827d2acaa55df9dbf1007e23f6fcb8c9436df52ab48274bb2221085bf?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a6ec0dc827d2acaa55df9dbf1007e23f6fcb8c9436df52ab48274bb2221085bf?s=96&d=identicon&r=g\",\"caption\":\"Salvatore Sorrentino\"},\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/author\\\/salvatore-sorrentinoblexin-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create a model for Machine Learning with ML.NET - Blexin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/","og_locale":"en_US","og_type":"article","og_title":"How to create a model for Machine Learning with ML.NET - Blexin","og_description":"After analyzing the importance of data for the Machine Learning, let\u2019s see how to create a data model according to our requirements","og_url":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/","og_site_name":"Blexin","article_published_time":"2019-12-16T23:00:00+00:00","article_modified_time":"2021-05-20T16:46:17+00:00","og_image":[{"width":1024,"height":608,"url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1","type":"image\/png"}],"author":"Salvatore Sorrentino","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Salvatore Sorrentino","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#article","isPartOf":{"@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/"},"author":{"name":"Salvatore Sorrentino","@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/354db2bc97cac71c2ceeca21a92d5bed"},"headline":"How to create a model for Machine Learning with ML.NET","datePublished":"2019-12-16T23:00:00+00:00","dateModified":"2021-05-20T16:46:17+00:00","mainEntityOfPage":{"@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/"},"wordCount":1209,"image":{"@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1","keywords":["Azure","Cloud","Machinelearning"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/","url":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/","name":"How to create a model for Machine Learning with ML.NET - Blexin","isPartOf":{"@id":"https:\/\/blexin.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#primaryimage"},"image":{"@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1","datePublished":"2019-12-16T23:00:00+00:00","dateModified":"2021-05-20T16:46:17+00:00","author":{"@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/354db2bc97cac71c2ceeca21a92d5bed"},"breadcrumb":{"@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#primaryimage","url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1","contentUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1","width":1024,"height":608},{"@type":"BreadcrumbList","@id":"https:\/\/blexin.com\/en\/blog-en\/how-to-create-a-model-for-machine-learning-with-ml-net\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blexin.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to create a model for Machine Learning with ML.NET"}]},{"@type":"WebSite","@id":"https:\/\/blexin.com\/en\/#website","url":"https:\/\/blexin.com\/en\/","name":"Blexin","description":"Con noi \u00e8 semplice","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blexin.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/354db2bc97cac71c2ceeca21a92d5bed","name":"Salvatore Sorrentino","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a6ec0dc827d2acaa55df9dbf1007e23f6fcb8c9436df52ab48274bb2221085bf?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a6ec0dc827d2acaa55df9dbf1007e23f6fcb8c9436df52ab48274bb2221085bf?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a6ec0dc827d2acaa55df9dbf1007e23f6fcb8c9436df52ab48274bb2221085bf?s=96&d=identicon&r=g","caption":"Salvatore Sorrentino"},"url":"https:\/\/blexin.com\/en\/author\/salvatore-sorrentinoblexin-com\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image00-17.png?fit=1024%2C608&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pcyUBx-7go","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/27924","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/users\/196716245"}],"replies":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/comments?post=27924"}],"version-history":[{"count":6,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/27924\/revisions"}],"predecessor-version":[{"id":31955,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/27924\/revisions\/31955"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/media\/27894"}],"wp:attachment":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/media?parent=27924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/categories?post=27924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/tags?post=27924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}