Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making MF to be a part of ML.NET #1263

Merged
merged 49 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
eba36bd
Complie trainer (interface) and predictor of LibMF
wschin Oct 12, 2018
b615e5c
Add native files and make them compiled
wschin Oct 12, 2018
a733492
Make MF command line working (can do train and test)
wschin Oct 13, 2018
a3ecdd7
Merge branch 'master' into portmf
wschin Oct 13, 2018
9a776b0
Implement IEstimator and ITransformer for MF
wschin Oct 16, 2018
1ecde85
Make naive test running
wschin Oct 17, 2018
0f33f45
Merge branch 'portmf' of github.com:wschin/machinelearning into portmf
wschin Oct 17, 2018
f3dfc43
Add toy MF data set (~750 lines. 3 numbers per line.)
wschin Oct 17, 2018
a2d37ae
Add two tests and enable SSE
wschin Oct 17, 2018
3eb9f14
SSE3 is not supported by default (need to change SSE code so we disab…
wschin Oct 18, 2018
ec56fb0
Merge branch 'master' into portmf
wschin Oct 18, 2018
2048832
Honor recents changes on Schema
wschin Oct 18, 2018
4766500
Address some comments. Hopefully this time it builds without errors.
wschin Oct 18, 2018
c277c3b
Address comments
wschin Oct 18, 2018
cf7e664
Continue addressing comments
wschin Oct 18, 2018
fc8ec2b
Make LIBMF a submodule
wschin Oct 18, 2018
9f64dd2
No need to have copyright because LIBMF is submodule now
wschin Oct 19, 2018
721879a
Add doc strings for public functions
wschin Oct 19, 2018
7fe705b
Reference native part as a package
wschin Oct 20, 2018
3f2ca23
Simplify one line in CMake for LIBMF
wschin Oct 22, 2018
edbb953
Merge branch 'master' into portmf
wschin Oct 22, 2018
502c736
Use MLContext to calculate regression loss
wschin Oct 22, 2018
a5eeeb7
Try initialize submodules before build
wschin Oct 22, 2018
7672470
Revert "Try initialize submodules before build"
wschin Oct 22, 2018
6944f74
Try pull submodule again
wschin Oct 22, 2018
91b421c
Try to find malloc.h on Mac
wschin Oct 22, 2018
af14614
Fix namespace of FFM
wschin Oct 22, 2018
2b9afc4
Rename LIBMF to MatrixFactorization
wschin Oct 23, 2018
30708d3
Rename files because Linux build is not able to parse their paths cor…
wschin Oct 23, 2018
9dcad28
Put LIBMF's DLL into another directory rather than Microsoft.ML
wschin Oct 23, 2018
de6bdef
Rename LIBMF to MatrixFactorizationNative
wschin Oct 23, 2018
1d3502e
Specify platform-dependent baselines and fix a package name
wschin Oct 23, 2018
5867136
Make two attributes internal and change the Nuget name of LIBMF
wschin Oct 23, 2018
b0f541e
Move submodule update to yml files
wschin Oct 23, 2018
9dd8835
Address some comments
wschin Oct 23, 2018
2d60a6f
Address comments
wschin Oct 24, 2018
9c332ef
Address comments
wschin Oct 24, 2018
4440c32
Try not to have submodule update in yml. Azure should just work.
wschin Oct 24, 2018
d2d1bf8
Use the nearest channel to do check and assert
wschin Oct 24, 2018
aac40db
Switch back to Host in constructor because env would be used to initi…
wschin Oct 24, 2018
1b199dd
Ctrl+R+G aka sort usings
wschin Oct 24, 2018
01e73a5
Merge two tests and remove an empty line
wschin Oct 24, 2018
cc9ccb2
Massively renaming
wschin Oct 24, 2018
f06d094
Conduct renaming for a missing piece
wschin Oct 24, 2018
eafdcf8
Minor name changes
wschin Oct 24, 2018
00f642d
Add NOTICE file for the use of external packages
wschin Oct 25, 2018
6931444
Change package name
wschin Oct 25, 2018
83b5bb3
Merge branch 'master' into portmf
wschin Oct 25, 2018
e8aab70
remove empty lines
wschin Oct 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Microsoft.ML.sln
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.Samples", "doc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ML.SamplesUtils", "src\Microsoft.ML.SamplesUtils\Microsoft.ML.SamplesUtils.csproj", "{11A5210E-2EA7-42F1-80DB-827762E9C781}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ML.Recommend", "src\Microsoft.ML.Recommend\Microsoft.ML.Recommend.csproj", "{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}"
wschin marked this conversation as resolved.
Show resolved Hide resolved
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -501,6 +503,14 @@ Global
{11A5210E-2EA7-42F1-80DB-827762E9C781}.Release|Any CPU.Build.0 = Release|Any CPU
{11A5210E-2EA7-42F1-80DB-827762E9C781}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU
{11A5210E-2EA7-42F1-80DB-827762E9C781}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Debug-Intrinsics|Any CPU.ActiveCfg = Debug-Intrinsics|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Debug-Intrinsics|Any CPU.Build.0 = Debug-Intrinsics|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release|Any CPU.Build.0 = Release|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release-Intrinsics|Any CPU.ActiveCfg = Release-Intrinsics|Any CPU
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3}.Release-Intrinsics|Any CPU.Build.0 = Release-Intrinsics|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -556,6 +566,7 @@ Global
{4B101D58-E7E4-4877-A536-A9B41E2E82A3} = {AED9C836-31E3-4F3F-8ABC-929555D3F3C4}
{ECB71297-9DF1-48CE-B93A-CD969221F9B6} = {DA452A53-2E94-4433-B08C-041EDEC729E6}
{11A5210E-2EA7-42F1-80DB-827762E9C781} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
{C8E1772B-DFD9-4A4D-830D-6AAB1C668BB3} = {09EADF06-BE25-4228-AB53-95AE3E15B530}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {41165AF1-35BB-4832-A189-73060F82B01D}
Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.ML.Console/Microsoft.ML.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
<ProjectReference Include="..\Microsoft.ML.Sweeper\Microsoft.ML.Sweeper.csproj" />
<ProjectReference Include="..\Microsoft.ML.TensorFlow\Microsoft.ML.TensorFlow.csproj" />
<ProjectReference Include="..\Microsoft.ML.Transforms\Microsoft.ML.Transforms.csproj" />
<ProjectReference Include="..\Microsoft.ML.Recommend\Microsoft.ML.Recommend.csproj" />

<NativeAssemblyReference Include="FastTreeNative" />
<NativeAssemblyReference Include="CpuMathNative" />
<NativeAssemblyReference Include="FactorizationMachineNative" />
<NativeAssemblyReference Include="LdaNative" />
<NativeAssemblyReference Include="SymSgdNative" />
<NativeAssemblyReference Include="LibMFWrapper" />
</ItemGroup>

</Project>
</Project>
93 changes: 93 additions & 0 deletions src/Microsoft.ML.Recommend/IMIValueMapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//------------------------------------------------------------------------------
// <copyright company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

using System;
using Microsoft.ML.Runtime.Data;

namespace Microsoft.ML.Runtime.Recommend
wschin marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// Interface for mapping a two input value (of the two indicated ColumnTypes) to
/// an output value (of an indicated ColumnType). This interface is commonly implemented
/// by predictors. Note that the input and output ColumnTypes determine the proper
/// type arguments for GetMapper, but typically contain additional information like
/// vector lengths.
/// </summary>
public interface IMIValueMapper
wschin marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// The type of the input value for the matrix column index.
/// </summary>
ColumnType InputXType { get; }

/// <summary>
/// The type of the input value for the matrix row index.
/// </summary>
ColumnType InputYType { get; }

/// <summary>
/// The type of the output value, that is, the type of the matrix elements.
/// </summary>
ColumnType OutputType { get; }

/// <summary>
/// Get a delegate used for mapping from inputs to output values. Note that the delegate
/// should only be used on a single thread - it should NOT be assumed to be safe for concurrency.
/// </summary>
ValueMapper<TXIn, TYIn, TOut> GetMapper<TXIn, TYIn, TOut>();
}

/// <summary>
/// This is the interface for the 'items selection' mapper. It takes the user's ID, features and per-item affinities,
/// and produces ranked list of candidates.
///
/// The interface is extensive, but the actual models will ignore some (or all) of the inputs. For example:
/// - the 'always suggest most popular items' model will ignore all inputs.
/// - the matrix factorization will ignore all the inputs except the user ID.
/// - SAR will ignore user ID and features and only read the item history.
/// - Matchbox in 'user to item' mode will use user ID and features and ignore the item history.
/// </summary>
/// <param name="userId">The user ID</param>
/// <param name="userFeatures">The user feature vector.</param>
/// <param name="items">The vector of items purchased by the user.</param>
/// <param name="weights">For each item in <paramref name="items"/>, the user's 'affinity' to the item.</param>
/// <param name="recommendedItems">Output. The ranked list of candidates.</param>
/// <param name="scores">Output, parallel to <paramref name="recommendedItems"/>. The scores of the ranked candidates.</param>
public delegate void UserHistoryToItemsMapper(
ref uint userId, ref VBuffer<Single> userFeatures, ref VBuffer<uint> items, ref VBuffer<Single> weights,
ref VBuffer<uint> recommendedItems, ref VBuffer<Single> scores);

/// <summary>
/// The interface for the 'user history -> items' recommender.
/// In the end-to-end recommendation pipeline, this predictor can be used both as a standalone recommender, and as a
/// candidate selection model. In the second case, the recommended items will then be featurized and ranked by downstream
/// component.
/// </summary>
public interface IUserHistoryToItemsRecommender: IPredictor
{
/// <summary>
/// The number of user features. 0 means variable size, -1 means that the algorithm ignores the user features.
/// </summary>
int UserFeaturesSize { get; }

/// <summary>
/// The type of the user ID. This will be a U4 key or null, if the algorithm doesn't care about the user ID.
/// </summary>
KeyType UserIdType { get; }

/// <summary>
/// The type of the item ID, both inputs and outputs. This will be a U4 key.
/// </summary>
KeyType ItemIdType { get; }

/// <summary>
/// Returns a mapper to invoke for item recommendations.
/// </summary>
/// <param name="recommendationCount">Maximum number of recommendation to return.</param>
/// <param name="includeHistory">Whether to recommend items in the user's history.</param>
UserHistoryToItemsMapper GetRecommendMapper(int recommendationCount, bool includeHistory);
}
}
Loading