Skip to content

Instantly share code, notes, and snippets.

View sudipto80's full-sized avatar
🎯
Focusing

SUDIPTA MUKHERJEE sudipto80

🎯
Focusing
View GitHub Profile
@sudipto80
sudipto80 / kNN.fs
Created January 22, 2016 09:03
Identifying Digits with kNN
open System.IO
open System
open System.Windows.Forms
open System.Drawing
//The type that represents each row of the training
//or the test dataset
type Entry = {Label :string; Values : int list}
//Calculates Squared Euclidean distance between pixel
@sudipto80
sudipto80 / anomaly.fs
Created January 22, 2016 19:14
Anomaly Detection
//Finds the median
let median numbers =
let sorted = List.sort numbers
let n = float numbers.Length
let x = int (n/2.)
let mutable result = 0.0
if (float numbers.Length) % 2. = 0.0 then result <- float (numbers.[x] +
numbers.[x-1]) / 2.0
else result <- float numbers.[x]
result
@sudipto80
sudipto80 / sentiment.fs
Created January 22, 2016 19:29
Sentiment Analysis
open System.Text.RegularExpressions
type SentiWordNetEntry = {POS:string; ID:string; PositiveScore:string; NegativeScore:string; Words:string}
let sentiWordList = System.IO.File.ReadAllLines(@"SentiWordNet_3.0.0_20130122.txt")
|> Array.filter (fun line -> not (line.StartsWith("#")))
|> Array.map (fun line -> line.Split '\t')
|> Array.map (fun lineTokens -> {POS = lineTokens.[0];
ID = lineTokens.[1];
PositiveScore = lineTokens.[2].Trim();
@sudipto80
sudipto80 / linearRegress.fs
Created January 22, 2016 19:42
Linear Regression
#load "...\packages\MathNet.Numerics.FSharp.3.10.0\MathNet.Numerics.fsx"
open MathNet.Numerics.LinearAlgebra
open System.IO
let velocities = vector[23.;4.;5.;2.]
//let y = matrix [[1.;3.]
// [1.;5.]
// [1.;4.]]
@sudipto80
sudipto80 / code.cs
Created February 1, 2016 08:42
Example for API Mining
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
namespace ConsoleApplication1
{
class Program
{
@sudipto80
sudipto80 / LanguageParser.cs
Created February 2, 2016 09:07
Roslyn LanguageParser.cs
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
@sudipto80
sudipto80 / code2.cs
Created February 2, 2016 11:04
SingletonInput1
/// <summary>
/// Sample singleton object.
/// </summary>
public sealed class SiteStructure
{
/// <summary>
/// This is an expensive resource.
/// We need to only store it in one place.
/// </summary>
object[] _data = new object[10];
@sudipto80
sudipto80 / code.cs
Created February 2, 2016 11:08
Singleton2
using System;
using System.Collections.Generic;
namespace DoFactory.GangOfFour.Singleton.NETOptimized
{
class MainApp
{
static void Main()
{
}
@sudipto80
sudipto80 / code3.cs
Created February 2, 2016 11:13
SingletonInput3
public sealed class APILookup
{
private static readonly APILookup _instance = new APILookup();
private Dictionary<string, int> _lookup;
private APILookup()
{
try
{
_lookup = Utility.GetLookup();
@sudipto80
sudipto80 / Facade1.cs
Created February 2, 2016 11:56
Facadeinput
using System;
namespace DoFactory.GangOfFour.Facade.RealWorld
{
/// <summary>
/// MainApp startup class for Real-World
/// Facade Design Pattern.
/// </summary>
class MainApp
{
/// <summary>