is there a cellnetanalyzer package for python? to generate boolean model
i am working on a project about biosystems analysis with python.I transformed experimental data to a bio network. Now i am trying to transform my data/Network to a Boolean model but i couldn't find a package/tool in python similar to "cellnetanalyzer" in matlab. is there a package in python similar to cellnetanalyzer that will allow me to do so?
See also questions close to this topic
-
Error non-linear-regression python curve-fit
Hello guys i want to make non-linear regression in python with curve fit this is my code:
#fit a fourth degree polynomial to the economic data from numpy import arange from scipy.optimize import curve_fit from matplotlib import pyplot import math x = [17.47,20.71,21.08,18.08,17.12,14.16,14.06,12.44,11.86,11.19,10.65] y = [5,35,65,95,125,155,185,215,245,275,305] # define the true objective function def objective(x, a, b, c, d, e): return ((a)-((b)*(x/3-5)))+((c)*(x/305)**2)-((d)*(math.log(305))-math.log(x))+((e)*(math.log(305)-(math.log(x))**2)) popt, _ = curve_fit(objective, x, y) # summarize the parameter values a, b, c, d, e = popt # plot input vs output pyplot.scatter(x, y) # define a sequence of inputs between the smallest and largest known inputs x_line = arange(min(x), max(x), 1) # calculate the output for the range y_line = objective(x_line, a, b, c, d, e) # create a line plot for the mapping function pyplot.plot(x_line, y_line, '--', color='red') pyplot.show()
this is my error :
Traceback (most recent call last): File "C:\Users\Fahmi\PycharmProjects\pythonProject\main.py", line 16, in popt, _ = curve_fit(objective, x, y) File "C:\Users\Fahmi\PycharmProjects\pythonProject\venv\lib\site-packages\scipy\optimize\minpack.py", line 784, in curve_fit res = leastsq(func, p0, Dfun=jac, full_output=1, **kwargs) File "C:\Users\Fahmi\PycharmProjects\pythonProject\venv\lib\site-packages\scipy\optimize\minpack.py", line 410, in leastsq shape, dtype = _check_func('leastsq', 'func', func, x0, args, n) File "C:\Users\Fahmi\PycharmProjects\pythonProject\venv\lib\site-packages\scipy\optimize\minpack.py", line 24, in _check_func res = atleast_1d(thefunc(((x0[:numinputs],) + args))) File "C:\Users\Fahmi\PycharmProjects\pythonProject\venv\lib\site-packages\scipy\optimize\minpack.py", line 484, in func_wrapped return func(xdata, params) - ydata File "C:\Users\Fahmi\PycharmProjects\pythonProject\main.py", line 13, in objective return ((a)-((b)(x/3-5)))+((c)(x/305)**2)-((d)(math.log(305))-math.log(x))+((e)(math.log(305)-(math.log(x))**2)) TypeError: only size-1 arrays can be converted to Python scalars
thanks before
-
beautifulsoup (webscraping) not updating variables when HTML text has changed
I am new to python and I cant understand why this isn't working, but I've narrowed down the issue to one line of code.
The purpose of this bot is to scrape HTML from a website (using beautiful and post to discord when the text changes. I use FC2 and FR2 (flightcategory2 and flightrestrictions2) as memory variables for the code to check against every time it runs. If they're the same, the code waits for _ minutes and checks again, if they're different it posts it.
However when running this code, the variables "flightCategory" "flightRestrictions" change the first time the code runs, but for some reason stop changing when the HTML text on the website changes. the line in question is this if loop.
if 1==1: # using 1==1 so this loop constantly runs for testing, otherwise I have it set for a time flightCategory, flightRestrictions = und.getInfo()
When debugging mode, the code IS run, but the variables in the code don't update, and I am confused as to why they would update the first time the code is run, but not sequential times. This line is critical to the operation of my code.
Here's an abbreviated version of the code to make it easier to read. I'd appreciate any help.
FC2 = 0 FR2 = 0 flightCategory = "" flightRestrictions = "" class UND: def __init__(self): page = requests.get("http://sof.aero.und.edu") self.soup = BeautifulSoup(page.content, "html.parser") def getFlightCategory(self): # Takes the appropriate html text and sets it to a variable flightCategoryClass = self.soup.find(class_="auto-style1b") return flightCategoryClass.get_text() def getRestrictions(self): # Takes the appropriate html text and sets it to a variable flightRestrictionsClass = self.soup.find(class_="auto-style4") return flightRestrictionsClass.get_text() def getInfo(self): return self.getFlightCategory(), self.getRestrictions() und = UND() while 1 == 1: if 1==1: #using 1==1 so this loop constantly runs for testing, otherwise I have it set for a time flightCategory, flightRestrictions = und.getInfo() (scrape the html from the web) if flightCategory == FC2 and flightRestrictions == FR2: # if previous check is the same as this check then skip posting Do Something elif flightCategory != FC2 or flightRestrictions != FR2: # if any variable has changed since the last time FC2 = flightCategory # set the comparison variable to equal the variable FR2 = flightRestrictions if flightRestrictions == "Manager on Duty:": # if this is seen only output category Do Something elif flightRestrictions != "Manager on Duty:": Do Something else: print("Outside Time") time.sleep(5) # Wait _ seconds. This would be set for 30 min but for testing it is 5 seconds. O
-
Need to reload vosk model for every transcription?
The vosk model that I'm using is vosk-model-en-us-aspire-0.2 (1.4GB). Every time need quite amount of time to load the vosk model. Is it necessary to recreate the vosk object for every time? It take many time to load the model, if we only load model once. It can save up at least half of the time.
-
Specific Fields for Specific User types in Django
I'm trying to come up with a better structure for handling user data in a django app. Currently, There are two kinds of users in the app, individual and organization. There is data specific to an individual and data specific to an organization. For example, an individual can have a first and last name while a organization only has their organization name.
This is how the model currently looks
class CustomUser(AbstractUser): first_name = models.CharField(_('first name'), max_length=30, blank=True) # from AbstractUser last_name = models.CharField(_('last name'), max_length=150, blank=True) # from AbstractUser organization_name = models.CharField(_('organization name'), max_length=180, blank=True) is_individual = models.BooleanField(default=False) is_organization = models.BooleanField(default=False)
Is there a way specific fields can be set up for specific user types? Something like:
Individual -- first_name -- last_name # more data concerning individuals Organization -- organization_name # more data concerning organizations
-
I can't display data in django template
So, i can't display data from my model in this template. In base.html it works great, but in this template is not working. I see too much posts on this site and i cant solve my problem. I write the render in too many ways but don't work and i'dont understand.
More information about my problem: Still not working. I work with slugs and in each of thems django only load the data of that slug. But if i put a for to load data from my model django dont display that infomation
views.py
from django.http import HttpResponse from django.shortcuts import render from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView from .models import Post, PostView, Like, Comment class PostListView(ListView): model = Post class PostDetailView(DetailView): model = Post class PostCreateView(CreateView): model = Post class PostUpdateView(UpdateView): model = Post class PostDeleteView(DeleteView): model = Post def change_view(request): todo = Post.objects.all context = { 'todo': todo } return render(request, "index.html", context)
models.py
from django.db import models from django.contrib.auth.models import AbstractUser from django.shortcuts import reverse from ckeditor.fields import RichTextField class User(AbstractUser): pass def __str__(self): return self.username class Post (models.Model): title = models.CharField(max_length=100) content = RichTextField(blank=True, null=True) thumbnail = models.ImageField() publish_date = models.DateTimeField(auto_now_add=True) last_updated = models.DateTimeField(auto_now=True) author = models.ForeignKey(User, on_delete=models.CASCADE) slug = models.SlugField() def __str__(self): return self.title return render(request, "post_detail.html", locals()) def get_absolute_url(self): return reverse("detail", kwargs={ 'slug': self.slug }) class Comment (models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) timestamp = models.DateTimeField(auto_now_add=True) content = models.TextField() def __str__(self): return self.user.name class PostView(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) timestamp = models.DateTimeField(auto_now_add=True) def __str__(self): return self.user.username class Like(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) def __str__(self): return self.user.username
index.html (in the final)
<!DOCTYPE html> <html lang="en"> <head> {% load static %} <meta charset="UTF-8"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="{% static 'css/main.css' %}"> </head> <body> <nav id="nav" class="navbar navbar-custom"> <div id="contbutton" class="container-fluid"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation"> <span><img src="{% static 'images/menuthreelinesbuttoninterfacesymbol_79952.png' %}" width="40px"></span> </button> </div> <div id="contlogo" class="container-fluid"> <img id="logonav" src="{% static 'images/Logo%20png%20amarillo.png' %}" width="10%"> </div> </nav> <div class="collapse" id="navbarToggleExternalContent"> <div class="bg-dark p-4"> <h5 class="text-white h4">Collapsed content</h5> <span class="text-muted">Toggleable via the navbar brand.</span> </div> </div> <div class="row"> <div class="col-md-9" style="padding: 0; margin: 0;"> {% block content %} {% endblock content %} </div> <div class="col-md-3" style="margin: 0; padding:0;"> <div class="col-md-12 contproxriv"> <div class="col-md-12 proxriv"> <div class="tipopartido"> <h5>Torneo clausura</h5> </div> <div id="escudos"> <img src="{% static 'images/WhatsApp_Image_2020-12-20_at_04.17.10-removebg-preview.png' %}" width="50px"> <h5>VS</h5> <img src="{% static 'images/WhatsApp_Image_2020-12-20_at_04.17.10-removebg-preview.png' %}" width="50px"> </div> <div id="nombres"> <h5 class="nomequipo">PEÑ</h5> <h5 class="fecha">25/12</h5> <h5 class="nomequipo">PEÑ</h5> </div> <div class="laprevia"> <a>La previa</a> </div> </div> </div> </div> </div> {% for pos in todo %} <div style="background-color: red; height: 200px; width: 200px;"></div> <h1 style="color: white;">{{ pos.title }}</h1> {% endfor %} </body> <script> $(function() { $('p').addClass('itemsubtitle'); }); </script>
-
Django forms widgets Textarea is directly set to type hidden but need it visible
My problem is i set a form from a model to change the value of the field "description" of this model :
Model :
class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) birth_date = models.DateField(null=True, blank=True) profile_img = models.ForeignKey(Image,on_delete=models.CASCADE,related_name='images',null=True) description = models.TextField()
Form :
class ChangeUserDescription(ModelForm): class Meta: model = Profile fields = ['description'] widgets = { 'description': forms.Textarea() } labels = { 'description':'Description' }
template :
<form method="post"> {% csrf_token %} {{ form }} <button type="submit">Save changes</button> </form>
But in result of this code I obtain this :
<input type="hidden" name="csrfmiddlewaretoken" value="brsd4oO0qhMw2K8PyCIgSgEMqy7QFvEjTHaR6wTJmyWffJaCX5XyOMDLrGldZ3ji"> <button type="submit">Save changes</button>
The issue is that i get : type="hidden" in the input whereas i want it to be visible and i do not specified in the widgets that it must be hidden.
-
the variable is set to false inside my method, once the method runs it should change to True. But it does not
def checkPassword (password): upper = False lower = False number = False special = False for i in range (len(password)): if ((ord(password[i]) >= 65) and (ord(password[i]) <= 90)): upper = True elif ((ord(password[i]) >= 97) and (ord(password[i]) <= 122)): lower = True elif ((ord(password[i]) >= 0) and (ord(password[i]) <= 9)): number = True elif ((ord(password[i]) >= 0) and (ord(password[i]) <= 9)) : special = True if ((upper == True) and (lower == True) and (number == True) and (special == True)): print ("Your password is strong") else: print ("Your password is not strong. Make sure to make it a mix between upper and lower case letters, number, and special characters.") def main(): password = input("Enter a password: ") checkPassword (password)
Input:
running99*FAST
Output:
Your password is not strong. Make sure to make it a mix between upper and lower case letters, number, and special characters.
Problem: This password should come back as a strong password but it does not. I honestly don't know what I did wrong.
P.S. I am using the ASCII table to identify whether the letters are lowercase, uppercase, or numbers, and special characters.
-
Why dosen't my boolean change its value to true after meeting the conditions?
I'm trying to make a simple customer registration system and a certain textfield has a label beside it that changes whenever it validates a good birthday format(mm/dd/yyyy) I did a switch statement to invalidate if they got the format wrong, but the boolean value I have set remains to be false even though the conditions are met for it to be true
int month = 0, day, year; Boolean vmonth = false, vday = false, vyear = false; for(int x = 1; x<=txt_customerbday.getText().length(); x++){ if(txt_customerbday.getText().length() != 10){ lbl_bdaycheck.setForeground(Color.red); lbl_bdaycheck.setText("Bad Format"); } else if(10 == txt_customerbday.getText().length() && vyear == true && vmonth == true && vday == true){ lbl_bdaycheck.setForeground(Color.green); lbl_bdaycheck.setText("Good Format"); }
Above is the code that will change the label if the conditions are met
if(txt_customerbday.getText().length() == 2){ month = Integer.parseInt(txt_customerbday.getText().substring(0)); System.out.print(month); if(month > 12){ vmonth = false; }else{ vmonth = true; System.out.print(vmonth); } }
The code above is the validation of the month (ignore the print statement I just did that to check their values)
if(txt_customerbday.getText().length() == 5){ day = Integer.parseInt(txt_customerbday.getText().substring(3,5)); System.out.print(day); System.out.print(vday); switch(month){ case 1: if(day > 31 || day <= 0){ vday = false; }else{ vday = true; } break; case 2: if(day > 28 || day <= 0){ vday = false; }else{ vday = true; } break; case 3: if(day > 31 || day <= 0){ vday = false; }else{ vday = true; } break; case 4: if(day > 30 || day <= 0){ vday = false; }else{ vday = true; } break; case 5: if(day > 31 || day <= 0){ vday = false; }else{ vday = true; } break; case 6: if(day > 30 || day <= 0){ vday = false; }else{ vday = true; } break; case 7: if(day > 31 || day <= 0){ vday = false; }else{ vday = true; } break; case 8: if(day > 31 || day <= 0){ vday = false; System.out.print(vday); }else{ vday = true; System.out.print(vday); } break; case 9: if(day > 30 || day <= 0){ vday = false; }else{ vday = true; } break; case 10: if(day > 31 || day <= 0){ vday = false; }else{ vday = true; } break; case 11: if(day > 30 || day <= 0){ vday = false; }else{ vday = true; } break; case 12: if(day > 31 || day <= 0){ vday = false; }else{ vday = true; } break; default: vday = false; break; } System.out.print(vday); }
The code above is the code for the day validation this is the one where I think I have the problem
if(txt_customerbday.getText().length() == 10){ year = Integer.parseInt(txt_customerbday.getText().substring(6,10)); System.out.print(year); vyear = true; }
The last one is unfinished but this is for the year validation
-
Determine if values are different
Let's say I have 4 variables
bool value1 = false; bool value2 = false; bool value3 = true; bool value4 = false;
and they all don't have the same value (all are true
||
all are false)I have found 2 approaches, anyway none of them looks easy to understand.
bool areDifferent = !(value1 == value2 == value3 == value4);
and
bool areDifferent = new[] { value1, value2, value3, value4 }.Distinct().Count() > 1;
Question: Is there a other approach, which is better in terms of readability / understandability?
-
How can I plot cubes in R?
Can you please help me understand this methodology called "Bambachian Mega Guild" (Bambach et al., 2007). This methodology tries to locate the Tiering, Feeding and Motility variables of the species according to the percentage of their appearance within a 3D cube. I want to try to understand which package to use to make this plot in R, since the truth is that I am not very clear about how to design these cubes as you can see them in the attached image.
Bush, A. M., Bambach, R. K., & Daley, G. M. (2007). Changes in theoretical ecospace utilization in marine fossil assemblages between the mid-Paleozoic and late Cenozoic. Paleobiology, 33(01), 76–97. doi:10.1666/06013.1
-
Implementing hybrid Particle Swarm Optimization in CNNs? (And, general questions about the algorithms as a whole)
So, I'm kind of new to working with Neural Networks (I use Keras w/ the TensorFlow backend). My background in math spans just deep enough to understand the concept behind Gradient Descent optimization. I'm not confident enough to work with numbers and symbolic math.
I was recently reading about PSO (another optimization technique called Particle Swarm Optimization). I've been building a CNN to classify lung disease types. So far, I've understood the following:
Gradient Decent:
- Minimizes the cost function (finds a minimum of the cost function)
- Starts at some randomly initialized position and looks for the steepest gradient
- Cost function must be differentiable (slopes = gradient)
- Usually settles down in one minimum which could be a local or global minimum
I understand Gradient Descent well but am confused on why PSO is a simpler approach. Here is what I know about PSO:
Particle Swarm Optimization:
- Minimizes cost function
- Multiple particles start at different locations on this cost function
- Particles look for minimums but each particle is affected by the swarm
- This means particles don't settle into a single local minimum and can move out of minimums based on swarm behavior
- Improves the chance of finding a global minimum
- Cost function DOES NOT have to be differentiable?
Why does this make sense? If the particles (my understanding of a particle is an instance of a model with randomly initialized weights, etc, which means it has a different position on the cost function). This essentially makes more model instances to train vs. gradient descent which trains one. Correct my understanding of a particle if what I just said is utter nonsense...
Why does the cost function not have to be differentiable? The particles are looking for a minimum and therefore need to go in direction of the steepest gradient downward.
How can one implement PSO in a CNN? I was looking at a library called Pyswarms which left me further frustrated since Pyswarms doesn't seem to be usable as an optimizer for CNNs.
(P.S. I am visualizing a cost function as a 3 variable function).
-
Keras for testing if a time series is rhythmic or not
I want to use Keras (or any other library that can deal with ANN) in order to test whether a time series is rhythmic or not (and hopefully tell what the amplitude and phase are too).
I have a dataset that I can use for learning and testing the model. each series has 12 samples.
I am familiar with basic ML algorithms. But my problem is that in this case, the features are not independent of one another, I mean - each sample is based on the previous one.