|
using a data mining technique means how form cluster.plz can u send me a source code for this
|
|
|
|
|
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Which hospital are you working for? I just want to know so that I make a point to never end up there.
|
|
|
|
|
The basic version of the algorithm is really very simple.
- guess k points that might be means of clusters. It matters how you do it, a simple trick is just pick some random samples.
- classify your data using the current means
- compute the means of the clusters thus formed, make them the new means
- repeat until it stops changing
- repeat all of the above with new initialization until you like the results (the update step gets caught in local minima)
These are all steps that anyone who can write code should be able to implement from scratch, there's nothing crazy in there.
|
|
|
|
|
I have the following:
MyService service = new MyService();
_services.Add(service);
Task.Factory.StartNew(() =>
{
service.Start();
}, service.CancellationTokenSource.Token)
.ContinueWith(task =>
{
switch (task.Status)
{
case TaskStatus.RanToCompletion:
AddStatus(string.Format("Service '{0}' completed", task.Id));
RemoveSelectedService(task);
break;
case TaskStatus.Canceled:
AddStatus(string.Format("Service '{0}' cancelled", task.Id));
RemoveSelectedService(task);
break;
case TaskStatus.Faulted:
AddStatus(string.Format("Service '{0}' errored", task.Id));
break;
}
});
In the ContinueWith how do I get a reference to the 'service' class?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Return it and pick it up from the task Result.
This space for rent
|
|
|
|
|
Return it from itself?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
If it works similar like a thread, then you can pass an object as a parameter; according to MSDN there is indeed an overload that provides exactly that.
Task.ContinueWith Method (System.Threading.Tasks)[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Either return it from the StartNew lambda and pick it up from the result, as Pete suggested:
Task.Factory.StartNew(() =>
{
service.Start();
return service;
}, service.CancellationTokenSource.Token)
.ContinueWith(task =>
{
var service1 = task.Result;
...
});
Or, since you're using a lambda method, you can reference it using the closure, in the same way as the StartNew delegate:
Task.Factory.StartNew(() =>
{
service.Start();
}, service.CancellationTokenSource.Token)
.ContinueWith(task =>
{
service.DoSomethingElse();
...
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i understand the both factory and factory method pattern. in factory pattern we create instance of my classed by another class function dynamically where i pass some parameter to another class function and based on that parameter another class function return right instance of class.
in factory method pattern we have to proceed one further step. in factory method pattern subclass create instance of my class. i do not find a scenario where people has to go for factory method pattern. so please some one come with a scenario where normal factory pattern will not be used rather people prefer to use factory method pattern.
here i am posting two set of code first one done by factory pattern and second one done by factory design pattern
1st set of code where factory pattern used
public enum Shipper
{
UPS = 1,
FedEx = 2,
Purolator = 3
}
public interface IShip
{
void Ship();
}
public class ShipperPurolator : IShip
{
public void Ship()
{
MessageBox.Show("Purolator ship start");
}
}
public class ShipperUPS : IShip
{
public void Ship()
{
MessageBox.Show("UPS ship start");
}
}
public class ShipperFexEx : IShip
{
public void Ship()
{
MessageBox.Show("FedEx ship start");
}
}
public class ShipperFactory
{
public static IShip CreateInstance(Shipper enumModuleName)
{
IShip objActivity = null;
switch (enumModuleName)
{
case Shipper.UPS:
objActivity = new ShipperUPS();
break;
case Shipper.FedEx:
objActivity = new ShipperFexEx();
break;
case Shipper.Purolator:
objActivity = new ShipperPurolator();
break;
default:
break;
}
return objActivity;
}
}
Calling this way
IShip objActivity = null;
private void btnUPS_Click(object sender, EventArgs e)
{
objActivity = ShipperFactory.CreateInstance(Shipper.UPS);
objActivity.Ship();
}
private void btnFedEx_Click(object sender, EventArgs e)
{
objActivity = ShipperFactory.CreateInstance(Shipper.FedEx);
objActivity.Ship();
}
private void btnPurolator_Click(object sender, EventArgs e)
{
objActivity = ShipperFactory.CreateInstance(Shipper.Purolator);
objActivity.Ship();
}
now same thing done by factory method pattern where i have to write more code to get the job done
public interface IShip
{
void Ship();
}
public class ShipperPurolator : IShip
{
public void Ship()
{
MessageBox.Show("Purolator ship start");
}
}
public class ShipperUPS : IShip
{
public void Ship()
{
MessageBox.Show("UPS ship start");
}
}
public class ShipperFedEx : IShip
{
public void Ship()
{
MessageBox.Show("FedEx ship start");
}
}
public interface IShipFactory
{
IShip GetShipper();
}
public class ShipperFexExFactory : IShipFactory
{
public IShip GetShipper()
{
return new ShipperFedEx();
}
}
public class ShipperUPSFactory : IShipFactory
{
public IShip GetShipper()
{
return new ShipperUPS();
}
}
public class ShipperPurolatorFactory : IShipFactory
{
public IShip GetShipper()
{
return new ShipperPurolator();
}
}
calling like this way
IShipFactory _IShipFactory = null;
private void btnUPS_Click(object sender, EventArgs e)
{
_IShipFactory = new ShipperUPSFactory();
_IShipFactory.GetShipper().Ship();
}
private void btnFedEx_Click(object sender, EventArgs e)
{
_IShipFactory = new ShipperFexExFactory();
_IShipFactory.GetShipper().Ship();
}
private void btnPurolator_Click(object sender, EventArgs e)
{
_IShipFactory = new ShipperPurolatorFactory();
_IShipFactory.GetShipper().Ship();
}
please tell me a solid scenario when people feel right to choose factory method pattern. thanks
tbhattacharjee
|
|
|
|
|
|
He doesn't like reading: it makes it difficult to be a Help Vampire.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It's like a stake through the heart.
This space for rent
|
|
|
|
|
Quote: He doesn't like reading
Yeah, and that is exactly why a few days ago I failed to understand his thread on hashing/encryption collected 30+ replies.
|
|
|
|
|
It surprised me as well. Granted, I did reply - but that was to warn people that he was a Help Vampire.
This space for rent
|
|
|
|
|
In our collective defence, most of 'em were to Gerry - who was trying to defend the indefensible without knowing anything about what he was saying.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
That is alright then
|
|
|
|
|
Tridip Bhattacharjee wrote: please tell me a solid scenario when people feel right to choose factory method pattern. thanks IDbConnection.CreateCommand();
Doesn't even take parameters
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
after searching google for Factory pattern definition i found it is
Factory pattern
In Factory pattern, we create object without exposing the creation logic. In this pattern,
an interface is used for creating an object, but let subclass decide which class to instantiate.
The creation of object is done when it is required.
The Factory method allows a class later instantiation to subclasses.
see my Factory pattern related code and there is no subclass which instantiate class object rather i have class with a static function which create & return class object.
so my question is that above definition is saying "subclass decide which class to instantiate" but in my code there is no subclass or child class rather a separate class create instance. is the above definition is for factory method pattern ?
here is my code
public enum Shipper
{
UPS = 1,
FedEx = 2,
Purolator = 3
}
public interface IShip
{
void Ship();
}
public class ShipperPurolator : IShip
{
public void Ship()
{
MessageBox.Show("Purolator ship start");
}
}
public class ShipperUPS : IShip
{
public void Ship()
{
MessageBox.Show("UPS ship start");
}
}
public class ShipperFexEx : IShip
{
public void Ship()
{
MessageBox.Show("FedEx ship start");
}
}
public class ShipperFactory
{
public static IShip CreateInstance(Shipper enumModuleName)
{
IShip objActivity = null;
switch (enumModuleName)
{
case Shipper.UPS:
objActivity = new ShipperUPS();
break;
case Shipper.FedEx:
objActivity = new ShipperFexEx();
break;
case Shipper.Purolator:
objActivity = new ShipperPurolator();
break;
default:
break;
}
return objActivity;
}
}
calling this way
IShip objActivity = null;
private void btnUPS_Click(object sender, EventArgs e)
{
objActivity = ShipperFactory.CreateInstance(Shipper.UPS);
objActivity.Ship();
}
private void btnFedEx_Click(object sender, EventArgs e)
{
objActivity = ShipperFactory.CreateInstance(Shipper.FedEx);
objActivity.Ship();
}
private void btnPurolator_Click(object sender, EventArgs e)
{
objActivity = ShipperFactory.CreateInstance(Shipper.Purolator);
objActivity.Ship();
}
please guide me regarding above definition.
thanks
tbhattacharjee
|
|
|
|
|
What you have there is fine. In the GoF (Gang of Four) definition, they are talking about the idea of having something like an abstract base class - the factory method will use this as the return type, but would create concrete versions of the classes that are subclassed off this. As you are using an interface instead (a better choice to my mind), this is your return type.
This space for rent
|
|
|
|
|
Tridip Bhattacharjee wrote: please guide me regarding above definition. Open this page[^], and scroll down to the answer that begins with "Let's understand difference between Factory and FactoryMethod with an example".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
See this MSDN example
If Task.Wait blocks, why would you ever want to use it?? If I'm in a WPF app and I launch a task from the main thread, it blocks the UI, so why bother using a thread? If I'm going to block the main thread, why not just put the thread's code in the UI to start with?
Someone please give me a real example of when I would really want to use Task.Wait.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You are assuming here that the only time that you would want to use a Task is off the UI thread. This isn't the case. As an example, suppose you wrote some code to index files in a particular folder - and you then want to finish the task only once the indexing has completed, you could very well create a top level task and then fire off multiple tasks inside - with a Wait on them completing.
This space for rent
|
|
|
|
|
So, Task A spawns 3 child tasks, then waits for all 3 to finish.
In this case you would want Task A to run async, correct?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|