Događaj
Izgradite inteligentne aplikacije
17. mar 23 - 21. mar 23
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahOvaj pregledač više nije podržan.
Nadogradite na Microsoft Edge biste iskoristili najnovije funkcije, bezbednosne ispravke i tehničku podršku.
Learn how to get started with DataFrames, which are two-dimensional data structures for storing and manipulating data. DataFrames help with preparation of data for a machine learning model. DataFrames can also be used for data manipulation unrelated to machine learning.
In most cases, accessing DataFrame is as simple as referencing the Microsoft.Data.Analysis NuGet package.
dotnet add package Microsoft.Data.Analysis
DataFrames make it easy to load tabular data. Create a comma-separated file called housing-prices.csv with the following data.
Id,Size,HistoricalPrice,CurrentPrice
1,600f,100000,170000
2,1000f,200000,225000
3,1000f,126000,195000
4,850f,150000,205000
5,900f,155000,210000
6,550f,99000,180000
Start by loading the data into a DataFrame.
using System.IO;
using System.Linq;
using Microsoft.Data.Analysis;
// Define data path
var dataPath = Path.GetFullPath(@"housing-prices.csv");
// Load the data into the data frame
var dataFrame = DataFrame.LoadCsv(dataPath);
DataFrames store data as a collection of columns. This makes it easy to interact with the data.
To get a preview of the column datatypes, run Info().
dataFrame.Info();
To get a summary of the data, run Description().
dataFrame.Description();
There are a variety of transformative options for data. The DataFrame and DataFrameColumn classes expose a number of useful APIs including binary operations, computations, joins, merges, and handling missing values.
For example, this data can be edited to compare historical prices to current prices accounting for inflation. You can apply a computation to all of the values and save the results in a new column.
dataFrame["ComputedPrices"] = dataFrame["HistoricalPrice"].Multiply(2);
Data can be sorted into groups from the values in a specific column.
var sortedDataFrame = dataFrame.GroupBy("Size");
Data can be filtered based on different equality metrics. This example uses a ElementWise equality function, and then filters based on the Boolean result column to get a new DataFrame with only the appropriate values.
PrimitiveDataFrameColumn<bool> boolFilter = dataFrame["CurrentPrice"].ElementwiseGreaterThan(200000);
DataFrame filteredDataFrame = dataFrame.Filter(boolFilter);
Consider the following raw data:
Id, Bedrooms
1, 1
2, 2
3, 3
4, 2
5, 3
6, 1
DataFrames can be constructed from individual data columns. Create a DataFrame from a list of the raw data.
var ids = new List<Single>() {1,2,3,4,5,6};
var bedrooms = new List<Single>() {1, 2, 3, 2, 3, 1};
var idColumn = new SingleDataFrameColumn("Id", ids);
var bedroomColumn = new SingleDataFrameColumn("BedroomNumber", bedrooms);
var dataFrame2 = new DataFrame(idColumn, bedroomColumn);
The two DataFrames can be merged based on the Id
value. The merge function takes both DataFrames and combine rows based on their Id
value.
dataFrame = dataFrame.Merge(dataFrame2, new string[] {"Id"}, new string[] {"Id"});
Results can be saved back into a .csv format.
DataFrame.SaveCsv(dataFrame, "result.csv", ',');
DataFrames work directly with ML.NET. DataFrame implements the IDataView and can be used to train a model.
Povratne informacije za .NET
.NET je projekat otvorenog koda. Izaberite vezu da biste pružili povratne informacije:
Događaj
Izgradite inteligentne aplikacije
17. mar 23 - 21. mar 23
Pridružite se seriji sastanaka kako biste izgradili skalabilna AI rešenja zasnovana na stvarnim slučajevima korišćenja sa kolegama programerima i stručnjacima.
Registrujte se odmahObuka
Putanja učenja
Get started with Microsoft Fabric - Training
Explore how to implement data analytics solutions on a single platform with Microsoft Fabric. Integrate, transform, and store data to train AI models and create insightful reports.
Certifikacija
Microsoft Certified: Fabric Data Engineer Associate - Certifications
As a Fabric Data Engineer, you should have subject matter expertise with data loading patterns, data architectures, and orchestration processes.
Dokumentacija
Load data from files and other sources - ML.NET
Learn how to load data for processing and training into ML.NET using the API. Data is stored in files, databases, JSON, XML or in-memory collections.
Train and evaluate a model - ML.NET
Learn how to build machine learning models, collect metrics, and measure performance with ML.NET. A machine learning model identifies patterns within training data to make predictions using new data.
Prepare data for building a model - ML.NET
Learn how to use transforms in ML.NET to manipulate and prepare data for additional processing or model building.