ML.NET C# predicting stock price using historical prices - c#

I am using C# and trying to figure out if I can create a way of returning a list of predicted future stock prices/movement by feeding in json data containing date, open, close, high, low, volume, adjusted close etc. (doesn't have to be too accurate for experimenting with code) using Microsoft's ML.NET.
Does anybody know how I could achieve this or have any useful links? I have been banging my head for a while trying to figure this out.
Thank you!
I am expecting a returned list of future dates and correlated predicted prices or perhaps a high, average and low stock target. I am not fussy, I am mainly trying to figure out how to work ML.NET for price prediction without using a csv.

ML.NET has forecasting and regression algorithms which might be appropriate for this scenario. Here is a sample using the ForecastBySSA algorithm.
Note that forecasting algorithms are univariate which means you can only use one column as a feature. Using regression algorithms means you'll have to perform some more feature engineering but you could use more features. Not the same problem you're trying to solve but here's a forecasting sample using regression algorithms.

Related

Statistic calculation

this is a question related to statistic calculation. The process that I will be going through is sampling survey. I will have a fluctuating sample on a daily basis.
I will write a program to process data. After the data is imported into the database. I will have to assign weighting to each group, to make the sample resemble actual ratio in the .
Can anyone tell me if there is any useful tools/ library that I can make use of for this function? i.e interpolation, extrapolation or weighted sample?
Although i will be writing this program in C#, solution in others language or software is welcomed too, e.g. R etc.
For statistical calculations in C# I recommend ILNumerics library.
ILNumerics home page

Get country code by latitude and longitude using NodaTime

Since NodaTime already has lat/long and country code data within the olson database, I was wondering if we can specify any lat/long (say any lat/long returned by GeoLocator.GetGeopositionAsync in windows store apps) and determine the timezone and country code from it?
Something similar to this: var zone = session.GetZoneForLocation(latitude, longitude); This is from https://github.com/mj1856/Raven.TimeZones
I am specifically looking at an offline solution like NodaTime and not using web services.
The lat/lon data that exists within NodaTime comes from the zone.tab file in the Olson data. This gives the location of the point on the map that the zone uses as a reference.
If that was the only data you had available, the best you could do for an arbitrary location would be to find the closest point. In some cases, this will give you an accurate time zone, but in many cases it will not.
Consider the following example (and please excuse my poor artwork)
The two squares represent different time zones, where the black dot in each square is the reference location, such as what you would find in zone.tab. The blue dot represents the location you are going to pass to the input query. Clearly, this location is within the orange zone on the left, but if we just look at closest distance to the reference point, it will resolve to the greenish zone on the right.
So zone.tab data (such as found in Noda Time) is not sufficient to perform this operation. Instead we need something that describes zones in terms of the shapes that define their boundaries, not just a single point. Fortunately, Eric Muller has been so kind to provide these shapes and put them in the public domain. You can find this data here.
My Raven.TimeZones project that you found does exactly that. It imports the data from Eric's shapefiles, and uses the geospatial features of RavenDB to index and query that data.
You can certainly use my implementation directly, or copy from it whatever parts you need. It works completely offline, making no web service calls. But it does require a license of RavenDB to operate.
If you are not able to use RavenDB, you can probably take a similar approach using any other database that supports complex spatial queries.
In particular - RavenDB cannot currently run in a pure WinRT environment, so you won't be able to use this directly in a Windows Store app. I'm uncertain if there are any embedded databases for WinRT that can perform geospatial queries. If anyone knows if any, please let us know.
Update
A consolidated list of time zone lookup methods can be found here.

calculating fft with complex number in c#

I use this formula to get frequency of a signal but I dont understand how to implement code with complex number? There is "i" in formula that relates Math.Sqrt(-1). How can I code this formula to signal in C# with NAduio library?
If you want to go back to a basic level then:
You'll want to use some form of probabilistic model, something like a hidden Markov model (HMM). This will allow you to test what the user says to a collection of models, one for each word they are allowed to say.
Additionally you want to transform the audio waveform into something that your program can more easily interpret. Something like a fast Fourier transform (FFT) or a wavelet transform (CWT).
The steps would be:
Get audio
Remove background noise
Transform via FFT or CWT
Detect peaks and other features of the audio
Compare these features with your HMMs
Pick the HMM with the best result about a threshold.
Of course this requires you to previously train the HMMs with the correct words.
A lot of languages actually provide Libraries for this that come, built in. One example, in C#.NET, is at this link. This gives you a step by step guide to how to set up a speech recognition program. It also abstracts you away from the low level detail of parsing audio for certain phenomes etc (which frankly is pointless with the amount of libraries there are about, unless you wish to write a highly optimized version).
It is a difficult problem nonetheless and you will have to use a ASR framework to do it. I have done something slightly more complex (~100 words) using Sphinx4. You can also use HTK.
In general what you have to do is:
write down all the words that you want to recognize
determine the syntax of your commands like (direction) (amount)
Then choose a framework, get an acoustic model, generate a dictionary and a language model compatible with that framework. Then integrate the framework into your application.
I hope I have mentioned all important things you need to do. You can google them separately or go to your chosen framework's tutorial.
Your task is relatively simple in terms of speech recognition and you should get good results if you complete it.

Need driving distance library/application I can talk to

We need to calculate driving distances for records in a SQL Server database, so I need to find some sort of library or program that will let me do so without connecting to the internet(if it has it's own database, great, if not, I know where to get data). I'm not too worried about calculation types right now, we're probably going to go with Djikstra's, but we just need something offline. Also, I will be dealing with multiple countries, though mostly USA.
So far, I haven't found anything that would work reliably, closest is MapPoint (per Marc Gravell), so I want to ask what offline solutions are available either to plug into, call from, or work next to my code (Delphi and .NET) to calculate driving distances? Thanks.
Options:
For a sensible number of locations, you could obtain (purchase, calculate, etc) a travel matrix between all locations - gets large as you increase the count, though
If you have the lat/long for each, you can do great-arc quite easily; but tends to get messy near lakes, oceans, etc
You could use an offline like MapPoint desktop, perhaps by storing a queue of unknown routes and processing those outside the db
Please check http://www.routeware.dk for RW Net. Developed with Delphi and can use TIGER for off-line calculations. Very fast for large scale matrix calculations.
btw: A better forum for such questions is https://gis.stackexchange.com/
Ok, after sleeping on the problem, I found a solution by using google to search on "vehicle routing software." So far I have found three options that look like they might work, and will be investigating them. Those are ALK Technologies' PCMiler, Telogis' Developer tools, and DNA Evolutions' JOpt.NET. Still plenty more companies to check out for developer tools on that search phrase. I think my main problem was I was using "Driving Distance" and "Route distance" as my search terms yesterday.
Edit: for what I'm looking for, Telogis seems to have the most complete function set.

Tuner application: How do find the frequency?

Greetings,
I am currently developing a tuner application using Silverlight/c# for class project. The problems i am having seem to be asked by quite a few people but not really answered. I have read a lot of forums and googled for hours but still cannot really grasp the code and math. What i have so far is thus:
Mic => audio input => audio samples are wrote to a memory stream => bytes converted to doubles then to complex numbers => FFT() which returns an array of complex numbers...
I have read about FFT/DFT/Autocorrelation/etc. It seems to me that FFT is the way i want to go for speed. I am, essentially, turning a chromatic tuner used in band/orchestra/etc into a online application so everything needs to be done real time. For now im just focusing on trying to understand the entire process.
Questions:
What is the correct method of converting the bytes wrote to the memory stream to complex numbers? This is partially answered here Convert Audio samples from bytes to complex numbers?, but i do not know which is the correct method for each one results in different values.
I understand the basics of FFT, but not exactly sure what the numbers represent at the different stages. For example, what exactly does the array of complex numbers represent when going into the fft algorithm, and what do they represent when leaving?
What other processing is required to find the freqency of the note being played after the FFT has been calculated?
I appreciate all the help, this project has proved to be more complicated than what i orginally researched! :/
Cheers and thanks!
Josh
1) Got nothin'
2) An FFT returns an array of values. Each array member contains the strength of the signal in that frequency band.
3) First, find the array member that has the strongest value. To dial in the exact frequency, you'll probably have to do some interpolation between the array members around the strongest bucket.
EDIT: Found this article. Looks like it breaks it down for you.

Categories