Accord .NETでモデリングする

まず、手始めに簡単な線形回帰を行ってみます。 #r "nuget:Accord" Installed package Accord version 3.8.0 #r "nuget:Accord.Statistics" Installed package Accord.Statistics version 3.8.0 using Accord.Statistics.Models.Regression.Linear; using System; double[] inputs = {80, 60, 10, 20, 30}; double[] outputs = {20, 40, 30, 50, 60}; var regression = new SimpleLinearRegression(); regression.Regress(inputs, outputs); var y = regression.Compute(85); var a = regression.Slope; var b = regression.Intercept; y 28.08823529411765 a -0.26470588235294107 b 50.58823529411764

4月 14, 2020 · 1 分 · 60 文字 · Me

Jupyter NotebookにC#をインストールする

.NET Core with Jupyter Notebooksにある通り、.NET CoreをJupyter Notebookから使えるようになったので、手元のWindows 環境でやってみました。Jupyter Notebookのインストールそのものは、Ububtu 18.04 環境上にJupyterとQ#環境を構築するあたりとか、その元とかが使えると思います。 基本的には dotnet tool install -g --add-source "https://dotnet.myget.org/F/dotnet-try/api/v3/index.json" Microsoft.dotnet-interactive とやって、.NET Interactiveをインストールして、Windows Terminalを再起動して、サーチパスを有効化し、 dotnet interactive jupyter installでjupyterのKernelをインストールしただけです。 あとは、おもむろにjupyter notebookでJupyter Notebookを起動。 System.Console.WriteLine("Foo"); とやって、Fooが出ることを確認できました。 うむ、すごく簡単。 次は、DataFrameで遊んでみよう。

3月 24, 2020 · 1 分 · 33 文字 · Me

Cognitive Servicesのテキスト分析にPowerShellから投げてみる

PowerShellからCognitive Servicesのネガポジ分析をたたいてみました。 $apiKey = “************************” $texts = @(“ColorfulのSSDめっちゃヤバいwww Galaxy S6や廃棄品のSSDから剥がしたフラッシュやIntelの偽物が搭載されているのが確認されてるらしいwww 安価なNVMe CN600もリマークチップを使ってるとのこと、、、 最近めっちゃ秋葉原で売ってるけど買わない方が良さそうだな、、、”) $headers = @{ ‘Ocp-Apim-Subscription-Key’ = $apiKey } $endPoint = “https://eastasia.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment” $texts | ForEach-Object { $text = $_ $obj = @{ documents = @(@{ language = “ja” id = “1” text = $text }) } $json = ConvertTo-Json $obj $result = Invoke-RestMethod -Uri $endPoint -Headers $headers -Body $json -ContentType ‘application/json; charset=utf-8’ -Method Post $items = $result.documents $item = $items[0] $item.score }

6月 5, 2018 · 1 分 · 73 文字 · Me

Watson APIのテキスト分析をPowerShellから叩く

PowerShellからWatsonのテキスト分析を叩いてみた。 $account = @{ “username” = **** “password” = **** } $spass = ConvertTo-SecureString $account.password -AsPlainText -Force $user = $account.username $cred = New-Object System.Management.Automation.PSCredential $user, $spass $endPoint = “https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-16” $text = “ColorfulのSSDめっちゃヤバいwww Galaxy S6や廃棄品のSSDから剥がしたフラッシュやIntelの偽物が搭載されているのが確認されてるらしいwww 安価なNVMe CN600もリマークチップを使ってるとのこと、、、 最近めっちゃ秋葉原で売ってるけど買わない方が良さそうだな、、、” $targets = @(“stocks”, “stocks”) $obj = @{ text = $text features = @{ sentiment = @{ } categories = @{ } } } $json = ConvertTo-Json $obj $result = Invoke-RestMethod $endPoint -Credential $cred -Body $json -Method Post -ContentType “application/json; charset=utf-8” $sentiment = $result.sentiment.document.score $category = $result.categories[0]

6月 5, 2018 · 1 分 · 83 文字 · Me