 Dyma'r gwelwch yn cymdeithasol, ond yn ddiddordeb iddyn nhw'n gweithio cysylltu yma yma. Fy ddweud y clywed ar y cyfnod ymlaen, mae chi'n mynd i ddweud? Rwy'n ddweud y ddwy'r cyfnod, a rwy'n ddweud y gweithio, mae hynny'n ddweud hynny'n gwlad am lŵr. Rwy'n ddweud y cysylltu, wedi'u gennym, mae'n ddweud ymlaen. Dyma'r gweld. Diolch i chi'n gweithio'r gweld. Felly mae'n gweithio'r gweld. Onw'r bwysig yn gweithgwyd i'r meddwl. Felly, ac rwy'n meddwl yw'r ffordd yw'r meddwl, rwy'n meddwl yw'r meddwl yw'r meddwl. Mae'n meddwl ychydig, rydyn ni'n gwybod. Fawr! Wnaeth ychwanegu. Rydyn ni'n gweithgwyd. Fawr, gweithgwyd! Rydyn ni'n gweithgwyd i'w meddwl. Fawr, gweithgwyd. Rydyn ni'n gweithgwyd. Rydyn ni'n gweithgwyd i'w meddwl i'w meddwl. I will point out that up until about two hours ago I wasn't going to do this today, so there's anything wrong with this, I apologise completely. So basically I'm going to talk about type 2 fuzzy logic, which is essentially fuzzy fuzzy logic. So is anyone here who's ever used fuzzy logic before in electronic engineering or for things like searching, that sort of thing? That's great, so I'm guessing you've used type 1 if you haven't used type 2, but you don't know it's called type 1, so that was a stupid question. So what you guys used fuzzy logic for? Brilliant, cool. So that's kind of the one of the main fundamental uses of it as I'll cover. Okay, so this should be quite interesting for you because I'm going to tell you that everything you've been doing is wrong basically. Cool. Right, so just a quick note, there will be audience participation, and I really love audience participation. As I said, if I start to speak too fast, please just, I don't know, let's have a symbol thumb up, it means I'm talking too fast. I won't point out that you said it, I'll just try and slow down. If there's any questions at any point, just stick a hand up and I'll try and answer them. And I will be getting some people up on stage to kind of demonstrate some principles, and I will ask them stupid questions. So hopefully that's all okay. The kind of stuff, just why you should listen to me when I'm talking about type 2 fuzzy logic, because I know this guy, I'm not this guy, but I do know this guy. This is Professor Bob Jong, he's currently at the University of Nottingham, he was previously another university, and he's written a paper called Type 2 fuzzy logic made simple, which is arguably a very bad title because that paper makes no sense. But it has over a thousand citations now. Basically it's a big deal. He's really kind of unified the field. And I've just done a thesis under him on the same topic with his supervision. So hopefully I know somewhat what I'm on about. Also I'm on computer file talking about fuzzy logic. They did this to me, I don't know why. So there's any questions remaining after? Come and talk to me, I'll give you the link to this video and hopefully it'll clear some things up. So I'm going to try and present it much more fun and kind of informally. Oh sorry, thank you, I wasn't paying attention. Much more fun and informally how it's normally presented. So this is actually a page from Type 2 fuzzy logic made simple. It's a great paper, it does explain a lot if you understand what this means. Which when I first started fuzzy logic I didn't understand what that means. So there's going to be a lot of very big images like this one. So to talk about fuzzy logic we first need to talk about crisp logic or boolean logic. So all of you probably know what this is. This is true and false zeros and ones. So for example the bits in a computer, they can only be one or zero, right? Everyone gets this. But there's certain things that don't quite work with this. And you may not even realise it. So let's try and give one. Because someone will give me an example of something which can be classified by true and false. Anyone want to talk? It's really windy up there. What's that? Dead or alive. Dead or alive. That's very fuzzy in itself. Because you've got different types of dead in the life, right? You could be very ill. Then you're arguably closer to being dead than other people. So that's something that could be very fuzzy. So it's like these sort of things. Humanity is inherently uncertain. They're inherently vague. We don't have a clue what we're talking about half the time. Half of our language means different things to different people. So as a prime example of this. Oh, wrong slide. That's a slide later. So someone called Lock Vizade kind of realised this around 1975. When he introduced something called fuzzy set theory. And basically what fuzzy set theory seeks to do is to allow us to classify and talk about the uncertainties that are inherent in human language and vagueness and how to deal with uncertainties in data and how to deal with uncertainties in the way we model things. And he completely revolutionised the field. You might be able to see there he's actually sitting next to a rather large trophy. This is one of many awards he's won over his lifetime for his work in this field of things, particularly artificial intelligence. So go back to crisp sets and boolean logic. This is what you may be used to. So a Venn diagram is a typical example of a set. We have a set A and B. If we're talking true and false, something may be true in set A and may be false in set B. And then we come to the union of these sets. So this could be, I don't know. If you're in my talk or in EMF. So you might be in my talk. That makes no sense because you can't be in my talk and not in EMF. Unless you've got a day ticket. You know, our sets work. Cool. So let's talk about the weather. Weather's cool. Weather is a really good example of how bad the human language is and how uncertain how vagate it is. So if I were to look outside and describe the weather right now, I'd probably say it's looking pretty nasty and this wind is really distracting. But pretty nasty or not very nice or nice or sunny. These don't really mean a lot. They're not temperature. They're not wind speed. Computers can't act on this information. So we need a way of dealing with this. And essentially what fuzzy sets and fuzzy logic tries to do. So when you start getting things like this, they get fuzzy to a point where you can't tell what they are and computers can't use that information. So we have this idea of membership. So with membership, in crisp sets, the sets you're used to, boolean sets, you have zeros and ones, what we do in fuzzy sets is widen that interval to all the values between zero and one. So for example, if you're dealing with a hype, you might have someone who, for example me, I'm about 5'8, so I'm not exactly tall, but I'm not exactly short. So I might be 0.65 tall, for example. At this point, you need to be very careful, because that sounds somewhat like probability. It's a completely different concept. This measures vagueness, whereas probability measures likelihood. So we build sets out of this information instead. But then you need a way of classifying that. You need a way of saying that, take a value and then give us a membership function. So that thing at the beginning, that said the degree of truth of indicating the membership of this talk to awesome is solid one, basically meant that there is a fuzzy set, one. You give a talk in, and it gives how true the set is to be in one, to be in awesome. My talk is definitely in awesome. So I did that with the membership function. So these have different shapes. Here's one of them. This is a triangle membership function. This is a triangle membership function. So basically what this does is we take in an input value, which is the x-axis, and out you'd get a value that's on the y-axis, a membership. So this could be anything. This could be height. So I could put in, oh no, it can't be height. It could come down. This could be temperature. This could be the fuzzy set of comfortable. So the set itself is actually represented by the function. You don't need anything else to represent a set. You don't need the input values. You just need to know the domain they come from. So if we're dealing with temperature, if I'm saying that this represents how comfortable a temperature is, I don't need to know all the possible values I'm going to enter. I just need to know that I'm dealing with temperatures. So I could put a temperature in. Find that, for example, if I put in maybe some temperature along this range, it will come out about 0.6. You can use these to build increasingly complex systems. So here we've got multiple ones. The interesting thing about fuzzy sets as opposed to Boolean sets is you can have differing membership values in differing sets. So this is looking at amount of grey levels in light. So we can have dark, grey and bright. You can see very clearly that we can have overlapping ones here. So we can actually classify the amount of different substances in certain sets. So you might ask where this is useful. This has actually been incredibly widely used in industry since about the 80s. So the main example is if you're on a washing machine, it uses fuzzy logic an awful lot. So there's a lot of fuzziness in the washing machine. For example, the dirtiness of the water, how warm the water is as it comes through and all this sort of thing. How fast it should spin. It needs to know how fast it should spin, whether it should flush more hot water through. All of these things. It has to take a lot of very imprecise measurements from how the wash is going to do that. So we start to build fuzzy systems that act on that. So to actually make a fuzzy system, a system that can take some values, use a fuzzy set, use a fuzzy membership function and give you a result. We have to have rules. That's when you start to get slightly complicated looking things like this. So basically what this is doing is this has got a collection of fuzzy membership functions. A range in a rule like format. So we have if them rules and on the left, the antecedent, that's the bit after the if, the bit that you, the boolean section. You measure how much something belongs to a membership set. So you could say for example, if person is tall, then do an action. But the thing that will come out of doing that, the thing that will come out of applying person to tall will be a membership value. So it'd be 0.65 for example. And then with that, you apply a minimum function to the consequence, which is a thing on the right near the then. So if it's in the washing machine, you would take water temperature, say is water warm, then action. So the action, if it's warm, maybe not to increase temperature. If it's cold, it may be to increase the temperature. So once you've done that, you then get a set out of the rules. And with that rule, you can then come out of the result set. So we're going to demonstrate this, these ideas and kind of why this makes sense by victimising my friends who unfortunately come along today. Thank you very much, guys. So can I have you guys up on stage? And another tall gentleman. You're drinking a beer, so I won't do you. Anyone who's tall? Let's have Dan. Yay, I'm glad you came. Thanks, Christian. I know I didn't see him. Cool. So if you want to arrange yourself some height order, I'm sure you know how you are. Sam, what are you doing now? Come on, man. All right. We'll leave you alone. It's not going to work very well with only three of them, but that would do. Cool. It's fine, Sam. Don't worry. Cool. Right. So it kind of does a recap of things we've gone on. Let's first try and classify these people strictly in Boolean sets. So we're going to deal with a linguistic variable. That is a word that we use in English that may mean something. So let's deal with height. Height is a linguistic variable. We need to assign some value to this. So we have linguistic values. These could be tall, short, these sort of things. But those things don't really mean anything. So if we want to do that now with Boolean logic, we'd have to decide a crisp cut of point where some of these people were tall or short. And that doesn't necessarily make sense. For example, if we take Sid and Sam, we may arbitrarily decide that cut in half, Sam is tall and Sid is short. But it's probably a centimeter difference between them. That's just madness. They shouldn't be such a clear cut-off. It might make slightly more sense between Sam and Simon. But again, if someone is perhaps a centimeter shorter than Simon, they would be classified as tall, while on the other side, they're classified as short. Just absolute nonsense. So we're going to do it with a membership function instead. If we just imagine that Sid is probably 160 centimeters, I don't know how tall people are in centimeters. Let's just go with it. 160 and Dan is 220. That metric imperial, I'm English. Let's go with that. OK, so we have to now construct a membership function for it. And this is where we run into our first problem. So let's have someone... This is scary. Let's have someone suggesting for an audience. So, if you are going to decide... So say we had a trapezium. So you've got a point where it's at zero, and a point where it goes up to one, and then it stays at one, and then it comes down. If you were to decide where the first point would be, where someone would first start becoming, let's say, tall, which kind of... This is going to be at one of those feet. Where would you set that? Where would you decide that, for example, out of these four, where would you decide that there was tallness? Anyone want to choose something? Go on. OK, cool. We'll put our first point in between Sam and Simon. So, at this point, we've got a membership function, it takes in their height, and then it's setting that in between Sam and Simon, it will raise up to one. So, if Sam is 160 and Simon's 180, we'll start to get increasing membership values. So, Sam will be zero at one tall, and then 165 will be 0.2, 167 will be 0.3, et cetera, until it gets up to one. But the problem here is, what makes you an expert in that field? Why do you know how to do that? It is complete and utter hypocrisy. Cool. OK, you guys can sit down. So, I actually need the visual example. Thank you. Right. And this is kind of the... Wait, let me get away. This is kind of the main thing that Lotfi's already realised again, and he realised this very, very quickly, in actually 1978. The problem with membership functions... So, what we're saying with type 1 fuzzy sets is that you have uncertainty and we have vagueness, and we need a way of dealing with that. So, you make a membership function that signs truth values, but the person who constructs that membership function... Why does he know any better? That membership function is still crisp. Once we've defined it, it can't be redefined. You give it a value, and a crisp membership... a crisp truth value still comes out. So, what we in fact need is fuzzy, fuzzy sets. We need sets that take a value and then have the truth values, but each one of those truth values then has a truth value, indicating how true that value could be. So, this is madness. It's really cool, it's really helpful, and it's much more accurate, but it's very hard to represent. So, here is one way of representing it. So, this area of shading in green is a footprint of uncertainty, which basically means this is the area on our function where there is now another membership function coming out of it. So, essentially what you have is a X value, an X axis which is your input data, a Y axis which is your truth values, and then out of that comes another axis which is in fact a type 1 fuzzy set, the fuzzy sets I've been talking about between different truth values. This looks very nice, it looks like it deals with a problem, but then straight away there are some issues. How would we actually draw a graph to get some data from this? There are unfortunately many ways of representing them, even to the point now where people are starting to cut these up into layers, and none of them really solves a problem because it's very, very complex and we can't really deal with it. Then we have additional problems in that we start to think then, if we're saying that we can't trust people to make the membership function, so once the membership function is made, they themselves are certain so it's no longer fuzzy, we need to make a new membership function for that membership function, but then the new one is now crisply defined and is no longer fuzzy, so we need to go further and then you get type 3 fuzzy logic. The computational requirements for type 2 are already huge, so type 3 is probably unfeasible, and then you think type 3 is actually pretty crisp but the third level so now we need, and it just goes on and on. There aren't actually people working on type N fuzzy logic where they do just think whether it's possible to continue going and gradually get more fuzzy. So as this picture shows, the only way to really deal with type 2 fuzzy logic is to start discretising it because the computational requirements are too big. When you've got 3D sets and you need to get membership functions in all these sets, there's an operation called Centroid which is how you actually get the value out of this. To do this on a completely continuous type 2 set, this doesn't work, is that a thumb or time? Cool. Cool. The computational requirements are too huge. So we have to start counting up which lowers our accuracy. So really type 2 fuzzy logic is kind of one huge research question. When you ask how can you use this today, the answer is it's kind of an open research question. If you ask why would you use it today, the answer is it's kind of an open research question. If you ask how would you construct a fuzzy set, it's kind of an open research question. But there are people using it and it also gets used a lot. So robotics is actually one area where it's kind of very well defined. There's a guy called Christian Wagner who has developed a Java library called Juzy which allows you to make type 2 fuzzy logic systems and they are relatively computationally sane. He used a site called Zed Slices the cake. So he cuts it and allows you to specify how much you want it cut to make it computationally sensible. So I'm kind of a summary. Fuzzy logic is amazing. It doesn't work in the real world because it doesn't measure vagueness. But with type 2 fuzzy logic we can get that. But it's all very fuzzy really. We don't know how to use it. But there is a way you can help which is kind of why I want to do this talk today. We need more people writing real world software that uses fuzzy logic and he has examples online. Fuzzy logic is very much an engineering and research discipline. There's lots and lots of people using it for years and years. But none of that code seems to be on GitHub or open source and no one can get hold of it and there's no libraries for it. There's these things called toolkits which are mostly made for MATLAB and cost about $400 for a licence. It's madness. So there are certain open source initiatives now trying to get this. So for example there's a house called library called Huzzy which I developed from my thesis. I'm a juzzy. Pull it on GitHub and contribute. If you've got any knowledge of set theory or fuzzy logic at all please come in and try and help us make this moving forward research area. Especially if you're very good with parallelism. I hope that all my sense would love some questions. So yeah, thank you very much for listening. Before I leave the stage are there any questions? Okay guys, if you have any questions for Joe we're taking them in sets of 3 so please don't be shy with your questions and we'll go from there. Is there anyone at all? Yes we have one. This line is kind of blinding me but I can see. So that talk was kind of I didn't know how techy everyone would be so don't feel afraid to ask techy questions I have kind of gone for a lower level. Hi there. Is there any limit to the well if you do fuzzy to the power of N you've got fuzzy and then fuzzy squared what's stopping you there? In principle can't this just be extended can you know however long? Yes in principle it can. Which is why some people are working on this is the type N fuzzy logic as I mentioned. There's slight complications with how you start to represent the set operations so for example conjunction, disjunction complement etc are all very well defined and people have discovered these for type 2 fuzzy logic as you get to the higher fuzzy sets there's some issue of how do we actually do these and there's even more issue of how do we do these sanely. So if you look at type 2 fuzzy logic now essentially what you have to do is cut that into an infinite number of the type 1 sets and then so if we're doing disjunction we take a type 2 type 2 sets cut them into an infinite number of type 1 sets and then disjunction those obviously it's not possible with the infinite so we have to apply some level of discretisation so it's just thinking of the same way to do this which is why some type 2 is starting to creep into usage now anything above type 2 isn't really there's nothing stopping you doing it it's just mad. Does anyone else have a question here? Anyone at all? You can test your maths chops. No? We've got one over there. Have you got any examples of interesting software that you've seen using fuzzy logic? For type 1 fuzzy logic is everywhere again washing machine cameras a really cool one for type 1 is actually which in itself is hard to explain because it involves fuzziness is blurriness in cameras like cameras being out of focus a lot of autofocusing in cameras actually uses fuzzy logic to determine whether an area of the image is out of focus or fuzzy so that's a cool application for type 2 there is one really interesting one which is it's being used quite a lot in medical research so one of the cool ones is kind of detecting whether a elderly person has fallen over obviously that's inherently already a fuzzy problem because they might be bending down to do their shoelace up but then you've also got uncertain measurements so you don't know exactly what they're doing because there's some uncertainty there and you don't know you have some delay with your data because you're trying to get real time accelerometer data so there's two levels of uncertainty which kind of lends itself very well to type 2 fuzzy logic and they have actually got the system working it can effectively recognise whether a person lowering to the ground is a fall or whether they're just doing it sensibly so that's quite a cool application Anyone want to be have the honour of the final question Anyone at all? No, I think Just one over there, yes Does fuzzy logic have a potential to cause problems if you decide to use fuzzy logic when you shouldn't use it? Yes So the issue of using fuzzy logic where you shouldn't is very much one of whether you're dealing with uncertainty or vagueness this is kind of why type 2 started being used because a lot of people were using type 1 to deal with uncertainty but because of the fact that your membership functions are clearly and crisply defined it's not uncertainty, it deals with its vagueness so if you use type 1 to model uncertainty it's kind of inherently dangerous and if you're not actually dealing with the uncertainty it's an accurate model which is where you need to start thinking about type 2 because type 2 can deal with uncertainty if that made any sense the difference between vagueness and uncertainty is kind of an odd concept OK Just before we're about to finish I believe his name is Dan A lot of the stuff you're talking about with fuzzy logic about being able to decide for a washing machine what temperature it should set things at impact if I was trying to build something like that I'd look at constraint programming so how does the fuzzy logic stuff OK, so it's essentially it's kind of like constructing an expert system it's essentially a nice way of packaging up so you get a fuzzy logic controller that basically takes in some input value that is a crisp value so say temperature or weight of the load in the washing machine you have a base of rules so these are if them rules are the form of you've got a fuzzy set and a fuzzy value on the right and that's the consequence so you do it in places you want to use an expert system so you've got a knowledge base built up of if them rules you take some value you apply it to these rules and you get an answer out that kind of tells you how to that tells you what the result is from those rules versus constraint programming there's a lot of different solutions to the same thing so if you've got a fuzzy video someone pointed out that why can't you just do this with a load of conditionals and the answer is you can it's a nicer model so if you've got a large database of rules if you want to change something you don't have to change all the individual data you just update your membership function so it's kind of just good software programming practice you've got everything compacted in different areas and you can change a few things I'm not sure that answered the question at all probably didn't but oh we just have one more question now wow they keep coming out now helpful so I was just thinking when you were talking about in the washing machine when you said you might have a kind of membership value of 0.65 for too cold and then obviously your action is heat it up how do you then decide which action to take so you can't run 0.65 of a heating action you've got to either run it or not what you actually have on the consequence side of the rule so in the action is another fuzzy set so we would have a fuzzy set for example to increase the flow of hot water and what then happens is the fuzzy set from the consequence of 0.65 that is used to apply some action to the change set so there's kind of two actions that a university used it's either a scale or a truncate so we might decide to multiply all values along that graph by 0.65 we might just cut it off at 0.65 when you end up the actual output from that rule is in itself a fuzzy set and this is where we need to apply defuzzification which is usually a site called the centroid algorithm which basically takes the kind of centre of gravity of the set and that will then be the value we apply to use the action so getting the actual output value as a value can use is a stuff called defuzzification basically okay guys Joe is the last person in this stage speaking so please put your hands together for him very much coming