| How to plot a decision region with only 2 feature? Posted: 14 Nov 2021 07:49 AM PST If I train a machine learning model on a dataset that consist of more than 2 feature, can I plot a decision region graphic respect of only the two feature? if yes, how? Thanks. I know only this way: def plot_decision_regions(x, y, classifier, test_idx=None, resolution=0.02): markers = ('s', 'x', 'o', '^', 'v') colors = ('red', 'blue', 'lightgreen', 'grey', 'cyan') cmap = ListedColormap(colors[:len(np.unique(y))]) x1_min, x1_max = x[:, 0].min() - 1, x[:, 0].max() + 1 x2_min, x2_max = x[:, 1].min() - 1, x[:, 1].max() + 1 xx1, xx2 = np.meshgrid(np.arange(x1_min, x1_max, resolution), np.arange(x2_min, x2_max, resolution)) z = classifier.predict(np.array([xx1.ravel(), xx2.ravel()]).T) z = z.reshape(xx1.shape) plt.contourf(xx1, xx2, z, alpha=0.03, cmap=cmap) plt.xlim(xx1.min(), xx1.max()) plt.ylim(xx2.min(), xx2.max()) for idx, cl in enumerate(np.unique(y)): plt.scatter(x=x[y == cl, 0], y=x[y == cl, 1], alpha=0.8, c=colors[idx], marker=markers[idx], label=cl, edgecolors='black') if test_idx: x_test, y_test = x[test_idx, :], y[test_idx] plt.scatter(x_test[:, 0], x_test[:, 1], c='', edgecolor='black', alpha=1.0, linewidth=1, marker='o', s=110, label='test set') plot_decision_regions(x=x, y=y, classifier=knn, test_idx=range(105, 150)) |
| RedHat 8.x install KDE Posted: 14 Nov 2021 07:49 AM PST I'm pretty new to RedHat in workstation version, and I would like to install KDE in RHEL8, Normally I did apt install kde-full and that's all - it looks like in redhat it's a little complicated. What I did: add epel repos to redhat add codeready builder and using : dnf groupinstall " I have: "KDE Plasma Workspaces" so using "dnf groupinstall KDE Plasma Workspaces" I have a lot of errors mostly about qt5: [root@localhost yum.repos.d]# dnf groupinstall "KDE Plasma Workspaces" Updating Subscription Management repositories. Last metadata expiration check: 0:00:36 ago on Sun 14 Nov 2021 10:46:49 AM EST. Error: Problem 1: package qt5-qtwebengine-5.12.8-1.el8.x86_64 requires libQt5Gui.so.5(Qt_5.12.5_PRIVATE_API)(64bit), but none of the providers can be installed - cannot install both qt5-qtbase-gui-5.12.5-4.el8.x86_64 and qt5-qtbase-gui-5.15.2-3.el8.x86_64
- cannot install both qt5-qtbase-gui-5.12.5-6.el8.x86_64 and qt5-qtbase-gui-5.15.2-3.el8.x86_64
- cannot install both qt5-qtbase-gui-5.12.5-8.el8.x86_64 and qt5-qtbase-gui-5.15.2-3.el8.x86_64
- package kdeplasma-addons-5.18.4.1-1.el8.x86_64 requires libQt5WebEngineCore.so.5()(64bit), but none of the providers can be installed
- package kdeplasma-addons-5.18.4.1-1.el8.x86_64 requires libQt5WebEngineCore.so.5(Qt_5)(64bit), but none of the providers can be installed
- package kdeplasma-addons-5.18.4.1-1.el8.x86_64 requires libQt5WebEngine.so.5()(64bit), but none of the providers can be installed
- package kdeplasma-addons-5.18.4.1-1.el8.x86_64 requires libQt5WebEngine.so.5(Qt_5)(64bit), but none of the providers can be installed
- cannot install the best candidate for the job
- conflicting requests Problem 2: package qt5-qtwebkit-5.212.0-0.42.alpha3.el8.x86_64 requires libQt5Quick.so.5(Qt_5.12.5_PRIVATE_API)(64bit), but none of the providers can be installed
- package qt5-qtwebkit-5.212.0-0.42.alpha3.el8.x86_64 requires qt5-qtdeclarative(x86-64) = 5.12.5, but none of the providers can be installed
- cannot install both qt5-qtdeclarative-5.12.5-1.el8.x86_64 and qt5-qtdeclarative-5.15.2-2.el8.x86_64
- package kwebkitpart-1.4.0-0.6.20190110.el8.x86_64 requires libQt5WebKit.so.5()(64bit), but none of the providers can be installed
- package kwebkitpart-1.4.0-0.6.20190110.el8.x86_64 requires libQt5WebKitWidgets.so.5()(64bit), but none of the providers can be installed
- package kwebkitpart-1.4.0-0.6.20190110.el8.x86_64 requires libQt5WebKitWidgets.so.5(Qt_5)(64bit), but none of the providers can be installed
- package kwebkitpart-1.4.0-0.6.20190110.el8.x86_64 requires libQt5WebKit.so.5(Qt_5)(64bit), but none of the providers can be installed
- cannot install the best candidate for the job
- conflicting requests Problem 3: problem with installed package libadwaita-qt5-1.2.1-3.el8.x86_64
- package libadwaita-qt5-1.2.1-3.el8.x86_64 requires libQt5Core.so.5(Qt_5.15)(64bit), but none of the providers can be installed
- package qt5-qtspeech-5.12.8-1.el8.x86_64 requires libQt5Core.so.5(Qt_5.12.5_PRIVATE_API)(64bit), but none of the providers can be installed
- package qt5-qtspeech-5.12.8-1.el8.x86_64 requires qt5-qtbase(x86-64) = 5.12.5, but none of the providers can be installed
- cannot install both qt5-qtbase-5.15.2-3.el8.x86_64 and qt5-qtbase-5.12.5-4.el8.x86_64
- cannot install both qt5-qtbase-5.15.2-3.el8.x86_64 and qt5-qtbase-5.12.5-6.el8.x86_64
- cannot install both qt5-qtbase-5.15.2-3.el8.x86_64 and qt5-qtbase-5.12.5-8.el8.x86_64
- package kmouth-19.12.2-1.el8.x86_64 requires libQt5TextToSpeech.so.5()(64bit), but none of the providers can be installed
- package kmouth-19.12.2-1.el8.x86_64 requires libQt5TextToSpeech.so.5(Qt_5)(64bit), but none of the providers can be installed
- conflicting requests
- cannot install both qt5-qtbase-5.12.5-4.el8.x86_64 and qt5-qtbase-5.15.2-3.el8.x86_64
- cannot install both qt5-qtbase-5.12.5-6.el8.x86_64 and qt5-qtbase-5.15.2-3.el8.x86_64
- cannot install both qt5-qtbase-5.12.5-8.el8.x86_64 and qt5-qtbase-5.15.2-3.el8.x86_64 Problem 4: problem with installed package adwaita-qt5-1.2.1-3.el8.x86_64
- package adwaita-qt5-1.2.1-3.el8.x86_64 requires libQt5Core.so.5(Qt_5.15)(64bit), but none of the providers can be installed
- package qt5-qtspeech-5.12.8-1.el8.x86_64 requires libQt5Core.so.5(Qt_5.12.5_PRIVATE_API)(64bit), but none of the providers can be installed
- package qt5-qtspeech-5.12.8-1.el8.x86_64 requires qt5-qtbase(x86-64) = 5.12.5, but none of the providers can be installed
- cannot install both qt5-qtbase-5.15.2-3.el8.x86_64 and qt5-qtbase-5.12.5-4.el8.x86_64
- cannot install both qt5-qtbase-5.15.2-3.el8.x86_64 and qt5-qtbase-5.12.5-6.el8.x86_64
- cannot install both qt5-qtbase-5.15.2-3.el8.x86_64 and qt5-qtbase-5.12.5-8.el8.x86_64
- package konqueror-libs-19.12.2-1.el8.x86_64 requires libQt5TextToSpeech.so.5()(64bit), but none of the providers can be installed
- package konqueror-libs-19.12.2-1.el8.x86_64 requires libQt5TextToSpeech.so.5(Qt_5)(64bit), but none of the providers can be installed
- package konqueror-19.12.2-1.el8.x86_64 requires libKF5Konq.so.6()(64bit), but none of the providers can be installed
- package konqueror-19.12.2-1.el8.x86_64 requires libkdeinit5_kfmclient.so()(64bit), but none of the providers can be installed
- package konqueror-19.12.2-1.el8.x86_64 requires libkdeinit5_konqueror.so()(64bit), but none of the providers can be installed
- package konqueror-19.12.2-1.el8.x86_64 requires libkonquerorprivate.so.5()(64bit), but none of the providers can be installed
- package konqueror-19.12.2-1.el8.x86_64 requires konqueror-libs(x86-64) = 19.12.2-1.el8, but none of the providers can be installed
- conflicting requests
- cannot install both qt5-qtbase-5.12.5-4.el8.x86_64 and qt5-qtbase-5.15.2-3.el8.x86_64
- cannot install both qt5-qtbase-5.12.5-6.el8.x86_64 and qt5-qtbase-5.15.2-3.el8.x86_64
- cannot install both qt5-qtbase-5.12.5-8.el8.x86_64 and qt5-qtbase-5.15.2-3.el8.x86_64 (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
|
| How to use UnionType in graphql-laravel? Posted: 14 Nov 2021 07:49 AM PST My problem here is select * for table and this disables the with or select functions and makes the n+1 problem that the query decides if I have a relationship with another table. It also disables the GraphQL properties that reduce query class ProductsQuery extends Query { protected $attributes = [ 'name' => 'products', ]; public function type(): Type { // return Type::nonNull(GraphQL::paginate('Product')); return Type::nonNull(GraphQL::type('ProductPaginateOrList')); } public function args(): array { return [ // start paginate 'paginate' => [ 'name' => 'paginate', 'type' => Type::boolean(), 'rules' => ['boolean'], 'defaultValue' => true, ], 'paginateLimit' => [ 'name' => 'paginateLimit', 'type' => Type::int(), 'rules' => ['required_if:paginate,true'], 'defaultValue' => 15, ], 'page' => [ 'name' => 'page', 'type' => Type::int(), 'rules' => ['required_if:paginate,true'], ], // end paginate ]; } public function resolve($root, array $args, $context, ResolveInfo $info, SelectFields $fields) { $select = $fields->getSelect(); $with = $fields->getRelations(); return Product::query() ->select($select) ->with($with) ->when($args['paginate'], function ($q) use ($args) { return $q->paginate($args['paginateLimit'], ['*'], 'page', $args['page']); }, function ($q) { return $q->get(); }); } } class ProductPaginateOrList extends UnionType { protected $attributes = [ 'name' => 'ProductPaginateOrList', 'description' => 'Products with paginator or collection of products', ]; public function types(): array { return [ GraphQL::paginate('Product'), GraphQL::wrapType( 'Product', 'ProductData', DataType::class ) ]; } public function resolveType($root): Type { if ($root instanceof LengthAwarePaginator) { return GraphQL::paginate('Product'); } elseif ($root instanceof Collection) { return GraphQL::wrapType( 'Product', 'ProductData', DataType::class ); } return null; } } class DataType extends ObjectType { public function __construct(string $typeName, string $customName = null) { $name = $customName ?: $typeName . 'Data'; $config = [ 'name' => $name, 'fields' => $this->getDataFields($typeName), ]; $underlyingType = GraphQL::type($typeName); if (isset($underlyingType->config['model'])) { $config['model'] = $underlyingType->config['model']; } parent::__construct($config); } protected function getDataFields(string $typeName): array { return [ 'data' => [ 'type' => GraphQLType::listOf(GraphQL::type($typeName)), 'description' => 'List of items', 'resolve' => function ($data) { return $data; }, 'selectable' => true, ], ]; } } Versions: graphql-laravel Version: 7.2 Laravel Version: 8.61 PHP Version: 8 The problem in details! |
| How do I get For loops to repeat, in order to have multiple values for variables? Posted: 14 Nov 2021 07:49 AM PST Constructing a code for a project and I expected the loop to repeat and give multiple values for later defined variables in an array, but it just gives one value. I am very new to python so I appreciate any help. An=np.array([51,101,201,301,501])#No. agents t=1400#me steps MM=9#agent memory Mi=1 #steps rep=5#repetitions sty={'ro','gx','b+','k*','m^','r+','go'} for agentcount in np.arange(0,5): #count over agents N=An[agentcount] for M in np.arange(Mi,MM+1): for crep in range(1,rep+1): win=(np.random.rand(M,1)>0.5).astype(int) #winning record s1=(np.random.rand(2**M,N)>0.5).astype(int) #random strat s2=(np.random.rand((2**M),N)>0.5).astype(int) #alternative strat payout=np.zeros([2,N])#empty payout record for ct in np.arange(1,t+1): cc=np.abs((1+ np.dot((2**(np.arange(0,M))),win)))#picks next strat nex1=s1[cc-1,:] nex2=s2[cc-1,:] nexts=[[nex1],[nex2]] for cn in np.arange(0,N+1): #better strat if payout[0,cn-1]>payout[0,cn-1]: Next=nex1 else: Next=nex2 Act=np.sum(Next)/N winning=(Act>0.5).astype(int) winr=[[winning],[win]] Act=Act-0.5*2 V=np.var(Act)*N alpha=2*M/N plt.loglog(alpha,(np.mean(V)),style=sty) I have been taught to use indentations for different sections of the loops, but I cant seem to get multiple values for Act, V and alpha. |
| SwiftUI alignment of "rating" views in two separate rows in Form for macOS and iOS Posted: 14 Nov 2021 07:49 AM PST Writing a Multiplatform app initially for macOS and iOS that uses a master detail view structure and within the detail view is a Form and many Sections, one of which contains two structs that represent a user's rating (of food) for enjoyment and consumption. Here is the code for the enjoyment rating... struct Rating: View { @Environment(\.colorScheme) var colourScheme @Binding var rating: Int var body: some View { HStack { Text("Enjoyment") .padding(.trailing, 12.0) #if os(iOS) Spacer()
|
No comments:
Post a Comment