Thursday, October 20, 2011

Build an Artificial Neural Network (ANN)

I want to create a artificail neural network to give me trade reccomendations and something to sell with my TradesRunner automated trading program.  The program I am using for a root progam is called Encog.  In order to implement my NN, I need to teach myself C#, Visual Studio and Encog.  I built the first program and it seems to work.  When I get it running, I decide to prove that it works.  So I decide if my NN really works, it should be able to predict a sine wave.  Here is what I got:

So if I look at this picture, here are my takeaways:
  • The prediction does show a sine wave (of sorts).
  • The amplitude to the positive is not what it should be (approximately half).
  • The lower amplitude is only a third and also seems 'blunted'.
  • The prediction trails the actual.
Overall, I am thinking this is a good thing, it is better than nothing and now gives me something to work on going forward.

Saturday, May 2, 2009

Day 6 in China; Part III:














































Day 5 in China; Part II: So you want to go to the farm...

Now that the meal is done, it's time to make the trip to where food comes from. We start off at the local market. The idea is we should follow the route the food travels to get to the market. That means we are going to take the local travel routes that the locals take.
The look is very 'market' and the smell and feel. Just like hometown any place. We observe the veggie row, the fish row and some guys playing cards. An interesting side line here. My wife wanted me to get an authentic Mah Jongg set to bring home. To my surprise, those were not to be found. Yes they had the trinket ones, but not the authentic ones. Why? The government outlawed the game in the 70's because it was thought to be a waste of time and gambling. It is allowed now, but it is still under ground for the most part.

We ride the bus to travel to 'the farm'. I did not get a bus picture. I'm really disappointed because it was pretty cool. The system was easy to follow, but you needed to understand the code. For us it was get on the 54 bus and go to the end. Easy enough.

We get to the river crossing and buy a token (0.50 yewan or about 8 cents).

We get in line to load onto the boat.
When one group gets off, they open the gates.

And we get on. People, bikes and mopeds. You don't think about it, but crossing the water on a scooter on the highway bridges is not an option. This is how they do it.


This is where we want to go (across the river).
And this is what it looks like when we try to cross the river. Tough going. The river is just consumed with traffic. It's as bad on the river is it is on the road.

Thursday, March 19, 2009

Day 4 in China; Part IV: And that's a wrap

Time to make it back to the railroad. One of the interesting things is how many people have taken my picture. I don't think I look that odd...do I?

When I posed for this picture, there were a whole bunch of Chinese people that wanted to take my picture and get their picture with me. It’s a lot of fun.


Here’s my driver. Figured I could at least get a picture of him to memorialize my trip. We head back to the railway station to wait the train. We exchange phone numbers and I get out. Total damage, 138 RMB or ¥138 which is $9.20 USD. Wow!


I get something to drink (0.5L Sprite for ¥3.5 or 52¢. As I’m sitting here I walk around a bit, but I stick out so I sit to observe. It’s interesting how just sitting with the locals allows me to disappear into the background. KFC is big here.

Now I am recounting a situuation I debated for several days as to whether I should discuss this or let it pass. I decided to discuss it. I was approached by a beggar woman. ‘No.’ I shake my head. She persists. No. Shake my head. Persists. No. Persists. This woman won’t give up. I lower my head. She knees down in front of me. I think about getting up and walking away. No. Shake my head. She persists. She won’t stop….

My pain was her poverty. I also know, she is in the business to beg. I was singled out for the full court press. Why? I’m white…duh! She is good at her business. For me, the pain could have gone away for ¥1 ($0.15). I still wrestle with this. I had many a conversation with my colleagues on this trip after that encounter. One friend, Ravi has an interesting point of view. He is from India. Our conversation on the subject has haunted me:
“You feel moved, right?” he asked.
“Yes.” I respond quickly and firmly. “I could have easily given her ¥1.”
“When she left you, did she continue begging down the row?”
“Yes.”
“Did they give her any money?”
"No."
“You know it’s a business, right. They know it. You know it down inside.”
I know he’s right.
“Are you moved enough to bring her home to feed her, to clothe her?”
Sigh………..
Okay, so when Jesus said, “You will always have the poor with you.” Was he talking to me about this moment? How about next time? What about the rest of my life? A moment in time, I will reflect on for my life.

I spent a portion of my time decoding my ticket. It appears there is a car identified on the ticket and a seat on that car.
Thirty minutes before I have to leave I make my way to the waiting room. I am on car 11, seat 1…I think. I use the toilet. A very interesting experience (sorry, no photos). You stand up on a stainless steel walkway in front of a stainless steel panel and drain. There is cold water to wash your hands, but no paper or electric dryer. Just don’t shake anyone’s hand for a while.


The train is called. A sea of people move to the gate. There is no pushing per se, just close. You move with the crowd. This picture just doesn't do the scene justice. Personal space in China is nonexistent. No one is overly concerned or pushy, we just have to put 16 cars of people with 60 people on each car (960 people) onto the track so we are ready to board the instant the train arrives. This is great practice for the Amazing Race. I wonder if Phil is watching my blog?


As I arrive at the track, there are numbers for each car. You stand in line at your number. I am in car 11, so I stand behind the 11.
The air is nice and cool, there is construction for a new station (I think) or something very large. I have never seen so much scaffolding in a single city in my life. The expensive jobs use steel scaffolding and the less expensive ones use bamboo. If you fell, it would take weeks for you to bounce off of all the bars and finally hit the ground the webbing of the scaffolding is soooooo tight. There are five huge cantilever cranes in the background on this job. I made the right decision to take this trip. I wish I would have planned better so I could see more. I am glad I didn’t plan better or I would have missed the adventure.

Everyone in this country has uniforms. It can be a bit scary if you are intimidated by uniforms. But I mean EVERYONE. Why? They don’t have to clean those clothes. The company, or government, or business cleans them. Makes sense. The train employee uniforms are very nice. Sharp looking!
(A movie goes here, but they don't seem to load good in China. Hopefully you can see this one!)

The train arrives. We board. We’re off. This is a very efficient operation. Several hundred people got off. We boarded. Almost 1,000 people are on their way. The train is clean, quiet, very comfortable with foot rests and tables. There are restrooms on the odd-numbered cars.
Along the ride we pass fishing villages, farms and construction. It appears they build temporary housing for workers on the construction. They are building something along the rail tracks. Either road or a mag train. Not sure. It’s getting dark now, and I will get back to the railroad station after sunset.

We stop at Kunshan station. People get off. People get on. Everyone has a seat. Very efficient operation. The people on the train are very subdued. There is a light chatter, but very quiet. I have noticed this on a lot of the transportation systems in China. I think the phrase ‘loud Americans’ applies here. A well dressed lady with a cart travels down the spacious aisle. She is selling goods from her cart, talking as she walks. I surmise she is saying “Something to drink? Something to eat?” She stops at my seat, removes a coke and says something. I smile, shake my head no, she smiles back and is off. I am thinking she did this because A…I don’t understand what is transpiring as she walks down the aisle so she is going to give me a chance, or B…figures I would buy seeing as no one else does. I’m going with option A.

Don’t these people know they are in communist China, and their life is bad, and they have no future, and their political rulers are corrupt, and they don’t all speak the same language in this country? (Sound like anywhere else?)

At 210km/hr two uniformed young ladies come through collecting trash. My set mate texts a message. Back to reading her magazine. I glance a look….LIKE I COULD READ WHAT IT SAYS! At least the pictures are nice. The train stops…Shanghai? Nope, cattle…HA HA. I don’t know.
A few more minutes and we are in Shanghai.
I exit the station, get a cab and make my way to Karaoke night with the class. It was a good day. I'm home.

Wednesday, March 18, 2009

Day 5 in China; Part I: So you want to tour....

Before we begin, you should know, I was able to upload the movies for Day 1, Part II. They are for one F-A-S-T moving train.

******

Today was a nice day for visiting China. We stated with breakfast at the hotel. This is pretty much like any other 5 star hotel breakfast with a bit of a flare for the Chinese flavor. (Like I would know what a 5 star hotel is supposed to be like.) With the recession, good hotels are available at great rates! Us poor college kids finally get a break!


We boarded a bus to travel to Shanghai Bio Chip (SBC). The company is collecting samples of tumors in the gestation track of Asian people. They store the 4-micron slices in a ‘bank’ and are investigating various solutions to tissue research, human genome effort, and advancing science. They received a 40 million grant from the government last year to help fund their efforts. There are only two such facilities in china, one in Beijing, and the one in Shanghai. Competition between the cities seems to be quite evident.


This is the site in a model. Pretty nice model.


They turned the water on for us. Maybe conserving electricity.


We rode the bus to a hotel for a box lunch. Now these are box lunches!

Then it was off for some personal investigation. Like this bike shop I stopped by to see what was up. How did I know it was a bike shop? By the white line around the shop!!! Duh!! Now if you look at this shop, other than the issue with rain, he has it all! Pumps, leak detecting tank, tool rack, and a mobile supply cabinet containing: locks, new tires, inner tubes, seats and no repair shop would be complete without....a BOOM BOX on the top! Really cool.



College kids need a place to shop. Here it is. For those of you that do not read Chinese the sign reads "Pedestrian Street".


And what do they shop for? Why books, of course! I'm not sure what the books are about, but those faces sure look familiar!

Day 4 in China; Part III: Still in Suzhou, but better now

Now I'm feeling pretty darn good. I made it to the town, I navigated the city and we are heading back to the train station. All is well....



Now it appears my driver has determined I am a tourist. I may have hit upon something here. Can I trust him? He motions for something…my notebook? No. My map? No. Money? No. “Woo Woo..” Does he want my train ticket? YES! He looks at the ticket, checks his clock and has determined I have time to go visit some places.



We visit a local Buddhist temple. That’s him sitting on the hill. No…I did not walk the steps to get up there, but It would have been a nice hike. Next time, I should plan better. Maybe even know where I am going? Maybe? I was unable to find out from the internet what this statue was. It’s too bad I didn’t have time to go up there. It looks VERY impressive!


We are near a pagoda in the distance. Turns out when I got back I find out this is the Yunyan Pagoda, or Huqiu Tower, a tower that is now leaning due to lack of foundational support (half soil, half rock), built during the latter part of the Five Dynasties and Ten Kingdoms era (907-960 AD).

We find another pagoda which turns out to be the Beisi Pagoda of Suzhou, built between 1131 and 1162 during the Song Dynasty (with later renovations), 76 m (243 ft) tall. I didn’t actually visit the pagodas because my time is limited. If I miss the train back to Shanghai, I am spending the night. Not good.

The city is very nice. It’s clean, organized, the roads are well laid out with lanes for cars, lanes for scooters and bikes, and a side walk. The hustle and bustle of Shanghai is in the distance. People are industrious yet the pace seems more like what a normal US city would be like. I think I am in the real China now. I could be very comfortable living in this community, and even a smaller one. All is good.

My driver checks my ticket again and suggest we take a detour. I’m game. He says I have “two periods” before I need to leave. I figure this is two hours. If I am back an hour before departure, I’m good. So far I’ve spent $20 USD and I’m in a cab with a person that has my best interest in mind making a few bucks touring me around the city. He’s not going to dump me out in the street because I still owe him money. I love capitalism!

We take the detour. What a stop!! It’s like 5 minutes south of the train station. He just pulls over on the road (a four lane), in the middle of a bridge and stops. He tells me to go under the bridge and walk and he’ll be on the other side of the road when I get back. This is a bit weird, but I can walk to the train station from here! Him and I are doing a pretty good job communicating now. His English has improved dramatically! And my Chinese? What can I say? I’m a Rosetta Stone mega-man!

It’s a water village! The streets are really cool. The water is great. They look at me with some really interesting looks. It might have something to do with me being an oddity…tall, handsome, white guy!


The streets have very nice quaint little shops in them. I stop look and no one is trying to hawk anything! I just look. I decide to buy an item in one of the shops and have to wait for service. WOW! This is very nice. I took a lot of pictures here, but it’s so hard to put them into facebook. I can send them to anyone that wants to see them. It was a nice quaint place to visit.

Monday, March 16, 2009

Day 4 in China; Part II: I'm Concerned...A LOT!

He gives up, kind of gets the idea I am just wanting to get over by the large lake. We start traveling…meter is ticking. He calls someone. Now I am on the phone with a lady who speaks pretty good English.
“Where are you wanting the driver to take you?” she asks.
“I don’t know the name. I just want to go to the water village.”
“What water village?”
“I don’t know, just the water village.”
“How do you expect the driver to get you there, if you don’t know where you’re going?”
“I don’t know, I just wanted to go to the water village.”
The driver says "I smoke, you smoke? I smoke!" He lights up a cigarette and whipes his brow. The tempereature is 27C. He's hot. I'm hot. My phone lady is hot. We each have a different HOT.
“But sir, if the driver doesn’t know where you want to go, how can he take you there?” My phone girl is trying not to say I am stupid, but she is stumbling across some words that sure sound like she thinks I'm stupid.
“Okay, just tell him to take me back to the railway station.”
“Okay, give me the driver.”
We’re on the interstate, the meter is running and he gets over in the right lane. I already have my ticket and it is for 17:53. I’ve got a REALLY long wait on my hands. A REALLY LONG WAIT!


“Wait! WAIT! There's the water. There’s a park! Take me over there!” The driver starts heading over there. I am now happy. I found water. There seems to be some Chinese houses there. This must be it.



Now I’m a bit concerned. When he drops me off, how am I going to get a ride back? How am I going to know what time it is? We pass the Suzhou Health College. Very nice. The road is starting to get a bit funky here. We make the lake. I have two hours to get back to the station. The driver volunteers to wait while I take pictures. That could be answer to my first prayer, because there are absolutely NO cabs in this area. Just the locals.




I start to walk around and take some shots. I am thinking this is lunch here for some locals. a sort of local fish market to purchase goodies for the evening meal. The choices are turttle, small fish, or snails. He will clean them on the spot. I pass. I hope to be able to NOT fix my own supper. I start to wonder. Have I got a way to let people know how to come and get me? I told four people the name of the city I was going to visit. I dont how to say 'Stupid lost American. Can you help me be UNLOST??!!. It's like telling someone I am in Overland Park (the city is about that size) and if I'm not back by nine, come and find me. I won't know exactly where I am, but you can come and get me. I press on.

Okay, so the driver decides to write me a note (pictured upside down to make the chinese harder for you to read) after letting me walk around a bit. It seems a bit long for "Yankee go home!". I found out later the note has something to do with the bridge. It is actually very very old and of historical significance.
He turns out to be a pretty good capitalist. He is volunteering to wait while I take some pictures and walk around. The tab is at 70 RMB ($10 USD) right now. If he drops me off, he gets nothing for his trip back to the station. If he stays with me, he pays for the trip back and we're both happy. He doubles his wages for the trip.

So I didn't find that stinking water garden or water village or whatever you want to call it after all, BUT...I experienced China! The coyotes are not howling anymore. I feel releaved that I don't return empty handed. Time to go back to the railway station and wait for my ride home.
Since my driver left me a note, I will leave him a note. I draw a rough map of the US and where I am from. I make sure I put Tonganoxie there, not just Kansas City. After all, a very detailed map in the back of a cab in China should be a piece of cake!