Skip to content

Instantly share code, notes, and snippets.

View samueleresca's full-sized avatar

Samuele Resca samueleresca

View GitHub Profile
open Microsoft.ML
open Microsoft.ML
open Microsoft.ML.Data
open Microsoft.ML.Transforms.Text
let stopwords = [|"ourselves"; "hers"; "between"; "yourself"; "but"; "again"; "there"; "about"; "once"; "during"; "out"; "very"; "having"; "with"; "they"; "own"; "an"; "be"; "some"; "for"; "do"; "its"; "yours"; "such"; "into"; "of"; "most"; "itself"; "other"; "off"; "is"; "s"; "am"; "or"; "who"; "as"; "from"; "him"; "each"; "the"; "themselves"; "until"; "below"; "are"; "we"; "these"; "your"; "his"; "through"; "don"; "nor"; "me"; "were"; "her"; "more"; "himself"; "this"; "down"; "should"; "our"; "their"; "while"; "above"; "both"; "up"; "to"; "ours"; "had"; "she"; "all"; "no"; "when"; "at"; "any"; "before"; "them"; "same"; "and"; "been"; "have"; "in"; "will"; "on"; "does"; "yourselves"; "then"; "that"; "because"; "what"; "over"; "why"; "so"; "can"; "did"; "not"; "now"; "under"; "he"; "you"; "herself"; "has"; "just"; "where"; "too"; "only"; "myself"; "which"; "those"; "i"; "after"; "few"; "whom"; "t";"ll"; "being"; "if"
open XPlot.Plotly
songLyrics
|> Seq.map(fun row -> row.Genre)
|> Seq.countBy id |> Seq.toList
|> Chart.Pie
|> Chart.WithTitle "Dataset by Genre"
|> Chart.WithLegend true
songLyrics
let trainDataPath = Path.Combine("../","Data","lyrics.csv")
let msft = CsvFile.Load(File.Open(trainDataPath, FileMode.Open), separators = ",", quote = '"', hasHeaders= true)
let songLyrics =
msft.Rows
|> Seq.filter (fun row -> not(row.GetColumn "lyrics" |> String.IsNullOrEmpty))
|> Seq.filter (fun row -> not(String.Equals(row.GetColumn "lyrics", "[Instrumental]", StringComparison.OrdinalIgnoreCase)))
|> Seq.map (fun row -> { Song = (row.GetColumn "song")
Artist = (row.GetColumn "artist")
Genre = (row.GetColumn "genre")
let trainDataPath = Path.Combine("./","Data","lyrics.csv")
let msft = CsvFile.Load(File.Open(trainDataPath, FileMode.Open), separators = ",", quote = '"', hasHeaders= true)
let songLyrics =
msft.Rows
|> Seq.filter (fun row -> not(row.GetColumn "lyrics" |> String.IsNullOrEmpty))
|> Seq.map (fun row -> { Song = (row.GetColumn "song")
Artist = (row.GetColumn "artist")
Genre = (row.GetColumn "genre")
Lyrics = (row.GetColumn "lyrics").Replace(Environment.NewLine, ", ")
open System
open System.Linq
open System.IO
open MathNet.Numerics
open MathNet.Numerics.Distributions
open MathNet.Numerics.LinearAlgebra
open MathNet.Numerics.Random
open FSharp.Data
[<CLIMutable>]
#load "Paket.fsx"
Paket.Package
["XPlot.Plotly"
"MathNet.Numerics"
"MathNet.Numerics.FSharp"
"FSharp.Data"
"Microsoft.ML"]
#load "XPlot.Plotly.Paket.fsx"
index song year artist genre lyrics
0 ego-remix 2009 beyonce-knowles Pop Oh baby, how you doing[...]
1 then-tell-me 2009 beyonce-knowles Pop playin' everything so easy[..]
type LyricsInput =
{
Song : string
Artist : string
Genre : string
Lyrics : string
Year: int
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug lambda locally",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "/Users/samuele.resca/.dotnet/tools/.store/amazon.lambda.testtool-2.1/0.9.0/amazon.lambda.testtool-2.1/0.9.0/tools/netcoreapp2.1/any/Amazon.Lambda.TestTool.dll",
"args": [],
dotnet serve --help
dotnet-serve 1.1.0-build.88+04e32cdef73c0e47b4fc74e35b5912b505cf2622
A simple command-line HTTP server
Usage: dotnet serve [options]
Options:
--version Show version information
-d|--directory <DIR> The root directory to serve. [Current directory]